done
This commit is contained in:
@@ -30,7 +30,7 @@ public class MinigameManager : NetworkBehaviour
|
||||
public float safeZoneShrinkTime = 30;
|
||||
float safeZoneShrinkSpeed;
|
||||
[SerializeField] private PickupSetting[] PickupItems;
|
||||
public GameObject starPrefab;
|
||||
// public GameObject starPrefab;
|
||||
// public int maxMoons, maxStars = 100;
|
||||
// public int maxTweps = 2;
|
||||
public Transform pickupItemsParent;
|
||||
@@ -45,20 +45,32 @@ public class MinigameManager : NetworkBehaviour
|
||||
UpdateMaterialValues();
|
||||
|
||||
safeZoneShrinkSpeed = mapRadius / safeZoneShrinkTime;
|
||||
|
||||
defaultJoyPos = joystick.transform.GetChild(0).GetComponent<RectTransform>().localPosition;
|
||||
SwitchUISides();
|
||||
|
||||
|
||||
}
|
||||
Vector2 defaultJoyPos;
|
||||
|
||||
public void SwitchUISides(){
|
||||
if(ControlSettings.ControlIsOnRight){
|
||||
joystick.anchorMin = new Vector2(0,0);
|
||||
joystick.anchorMax = new Vector2(0.5f, 1);
|
||||
|
||||
btn_boost.anchorMin = new Vector2(1,0);
|
||||
btn_boost.anchorMax = new Vector2(1,0);
|
||||
btn_boost.position = new Vector2(Screen.width-100, btn_boost.position.y);
|
||||
btn_boost.position = new Vector2(Screen.width-150, btn_boost.position.y);
|
||||
Vector2 newDef = new Vector2(defaultJoyPos.x, defaultJoyPos.y);
|
||||
|
||||
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
|
||||
}else{
|
||||
joystick.anchorMin = new Vector2(0.5f,0);
|
||||
joystick.anchorMax = new Vector2(1f, 1);
|
||||
btn_boost.anchorMin = new Vector2(0,0);
|
||||
btn_boost.anchorMax = new Vector2(0,0);
|
||||
btn_boost.position = new Vector2(100, btn_boost.position.y);
|
||||
Vector2 newDef = new Vector2(-joystick.transform.GetChild(0).GetComponent<RectTransform>().localPosition.x, joystick.transform.GetChild(0).GetComponent<RectTransform>().localPosition.y);
|
||||
btn_boost.position = new Vector2(150, btn_boost.position.y);
|
||||
Vector2 newDef = new Vector2(-defaultJoyPos.x, defaultJoyPos.y);
|
||||
|
||||
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
|
||||
}
|
||||
@@ -237,11 +249,27 @@ public class MinigameManager : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
GameObject RandomStar { get{
|
||||
int i = Random.Range(0,5);
|
||||
int c = 0;
|
||||
GameObject selected = null;
|
||||
foreach(PickupSetting pickup in PickupItems){
|
||||
if(pickup.Prefab.name.ToLower().Contains("star")){
|
||||
selected = pickup.Prefab;
|
||||
if(c == i){
|
||||
return pickup.Prefab;
|
||||
break;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
return selected;
|
||||
}}
|
||||
void SpawnStars(int amount, Vector3 focusedPosition){
|
||||
for(int i=0; i < amount;i++){
|
||||
Vector3 newPosition = getRandomPointInCirlce((Vector3)focusedPosition, 10);
|
||||
GameObject newStar = Instantiate(starPrefab, pickupItemsParent);
|
||||
GameObject newStar = Instantiate(RandomStar, pickupItemsParent);
|
||||
NetworkServer.Spawn(newStar);
|
||||
newStar.GetComponent<PickupItem>().Reposition(newPosition);
|
||||
}
|
||||
|
||||
@@ -126,6 +126,10 @@ public class PickupItem : NetworkBehaviour
|
||||
|
||||
public enum PickupType{
|
||||
Star,
|
||||
Star2,
|
||||
Star3,
|
||||
Star4,
|
||||
Star5,
|
||||
Moon1,
|
||||
Moon2,
|
||||
Moon3,
|
||||
|
||||
@@ -11,7 +11,7 @@ public class RankedSplash : MonoBehaviour
|
||||
statusTxt.text = "Waiting for confirmation";
|
||||
}
|
||||
bool allConnected= false;
|
||||
string rules = @"1.Last one standing or the first to \ncollect 30 moons wins!
|
||||
string rules = @"1.Last one standing or the first to collect 30 moons wins!
|
||||
2.Stay in safe zone to survive
|
||||
3.Safe-Zone gets shrinked in 5 mins
|
||||
4.Have fun!";
|
||||
@@ -20,11 +20,12 @@ public class RankedSplash : MonoBehaviour
|
||||
// if(AutoConnect.instance.isClient){return;}
|
||||
if(MinigameManager.instance ==null){return;}
|
||||
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
|
||||
if(players.Length >= playerCountRequired){
|
||||
if(players.Length >= playerCountRequired && players[0].ready && players[1].ready){
|
||||
//Start the match!
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
if(!MinigameManager.instance.RankedGameStarted){
|
||||
|
||||
if(!allConnected && players.Length < playerCountRequired){
|
||||
|
||||
@@ -17,6 +17,7 @@ public class RocketUpgradePanel : MonoBehaviour
|
||||
// RocketLevel CurrentLevel,NextLevel;
|
||||
|
||||
string selectedRocket;
|
||||
public ParticleSystem[] fullscreenFX;
|
||||
|
||||
// public bool Affordable => DBmanager.Metal >= NextLevel.metalCost && DBmanager.Coins >= NextLevel.goldCost;
|
||||
|
||||
@@ -138,7 +139,11 @@ public class RocketUpgradePanel : MonoBehaviour
|
||||
AudioManager.instnace.UpgradeRocket();
|
||||
// Hide();
|
||||
Show(selectedRocket);
|
||||
UpgradeEffect.top_instance.Show(txtSpeed.rectTransform.position);
|
||||
//UpgradeEffect.top_instance.Show(txtSpeed.rectTransform.position);
|
||||
foreach(ParticleSystem particle in fullscreenFX)
|
||||
{
|
||||
particle.Play();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -157,7 +162,11 @@ public class RocketUpgradePanel : MonoBehaviour
|
||||
// Hide();
|
||||
Show(selectedRocket);
|
||||
|
||||
UpgradeEffect.top_instance.Show(txtBoostConsumption.rectTransform.position);
|
||||
// UpgradeEffect.top_instance.Show(txtBoostConsumption.rectTransform.position);
|
||||
foreach (ParticleSystem particle in fullscreenFX)
|
||||
{
|
||||
particle.Play();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -175,7 +184,11 @@ public class RocketUpgradePanel : MonoBehaviour
|
||||
|
||||
// Hide();
|
||||
Show(selectedRocket);
|
||||
UpgradeEffect.top_instance.Show(txtEnergyGain.rectTransform.position);
|
||||
// UpgradeEffect.top_instance.Show(txtEnergyGain.rectTransform.position);
|
||||
foreach (ParticleSystem particle in fullscreenFX)
|
||||
{
|
||||
particle.Play();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using TMPro;
|
||||
using System;
|
||||
|
||||
public class SceneDataHolder : MonoBehaviour
|
||||
{
|
||||
public Transform trailCollidersParent;
|
||||
@@ -27,9 +29,9 @@ public class SceneDataHolder : MonoBehaviour
|
||||
public void OnBoostDown(){
|
||||
SceneData.OnBoostDown.Invoke();
|
||||
}
|
||||
|
||||
DateTime lastShownTime;
|
||||
public void ShowDeadscreen(int xpEarned, int metalEarned, double survivalTime){
|
||||
if(AdsManager.instance!=null){AdsManager.instance.ShowInterestitial();}
|
||||
|
||||
deadScreen.SetActive(true);
|
||||
xpEarnings.SetActive(xpEarned > 0); metalEarnings.SetActive(metalEarned > 0);
|
||||
xpEarnings.GetComponentInChildren<TMP_Text>().text = xpEarned.ToString();
|
||||
@@ -45,6 +47,15 @@ public class SceneDataHolder : MonoBehaviour
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async void ShowAds(){
|
||||
if(MinigameManager.instance.isRanked){
|
||||
if(AdsManager.instance!=null && (DateTime.Now - lastShownTime).Minutes > 10){
|
||||
AdsManager.instance.ShowInterestitial();
|
||||
lastShownTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ public class SkinShopManager : MonoBehaviour
|
||||
item.OnSelectionChanged(data.name);
|
||||
}
|
||||
|
||||
AudioManager.instnace.UIClick();
|
||||
}
|
||||
|
||||
void onEquip(){
|
||||
|
||||
@@ -49,13 +49,14 @@ public class SpaceshipControllerSolo : MonoBehaviour
|
||||
public void CollectPickup(PickupItemSolo.PickupType type){
|
||||
switch(type){
|
||||
case PickupItemSolo.PickupType.Moon:
|
||||
AudioManager.instnace.CollectMoon();
|
||||
AudioManager.instnace.CollectMoon(1,1);
|
||||
trailMgr.trail.time += TrailIncrementRate;
|
||||
MoonsCollected++;
|
||||
break;
|
||||
|
||||
case PickupItemSolo.PickupType.Star:
|
||||
AudioManager.instnace.CollectStar();
|
||||
AudioManager.instnace.CollectMoon(1,1);
|
||||
|
||||
|
||||
trailMgr.trail.time += TrailIncrementRate/2f;
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public class SpaceshipController : NetworkBehaviour
|
||||
[SerializeField]private int RubberBandsCount;
|
||||
public GameObject DeathEffect;
|
||||
public GameObject debrisEffect;
|
||||
// public GameObject boostStartEffect;
|
||||
public ParticleSystem[] boostStartEffect;
|
||||
public ParticleSystem[] boostEffects;
|
||||
// public GameObject PickupEffect;
|
||||
|
||||
public float distanceFromCenter = 0;
|
||||
@@ -138,14 +141,21 @@ public class SpaceshipController : NetworkBehaviour
|
||||
{
|
||||
Debug.Log($"Add scores {newScores - oldScores}, (total: {newScores})");
|
||||
}
|
||||
|
||||
bool isBoostAvailable {get{ return trailTime > minTrailTime;}}
|
||||
void OnTrailTimeChanged(float oldValue, float newValue)
|
||||
{
|
||||
trailMgr.trail.time = newValue;
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
bool isBoostAvailable = trailTime > minTrailTime;
|
||||
SceneData.holder.boostBtn.gameObject.SetActive(isBoostAvailable);
|
||||
|
||||
// SceneData.holder.boostBtn.gameObject.SetActive(isBoostAvailable);
|
||||
SceneData.holder.boostBtn.transform.GetChild(0).gameObject.SetActive(isBoostAvailable);
|
||||
SceneData.holder.boostBtn.transform.GetChild(0).GetChild(0).gameObject.SetActive(trailTime > maxTrailTime/2f);
|
||||
SceneData.holder.boostBtn.transform.GetChild(0).GetChild(1).gameObject.SetActive(trailTime > maxTrailTime* 0.8f);
|
||||
SceneData.holder.boostBtn.transform.GetChild(0).GetChild(2).gameObject.SetActive(trailTime >= maxTrailTime);
|
||||
SceneData.holder.boostBtn.transform.GetChild(0).Find("Slider").GetComponent<Image>().fillAmount = Mathf.Clamp(0.73f - ((trailTime /maxTrailTime)*0.73f),0f,0.73f);
|
||||
|
||||
|
||||
if (!isBoostAvailable && boosting)
|
||||
{
|
||||
CmdSetBoosting(false);
|
||||
@@ -155,8 +165,10 @@ public class SpaceshipController : NetworkBehaviour
|
||||
|
||||
void OnBoostDown()
|
||||
{
|
||||
if(!isBoostAvailable){return; }
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
|
||||
AudioManager.instnace.Boost();
|
||||
if (isServer)
|
||||
{
|
||||
@@ -168,6 +180,10 @@ public class SpaceshipController : NetworkBehaviour
|
||||
}
|
||||
|
||||
CameraFollower.instance.ShakeBoost();
|
||||
// GameObject fx = EffectPool.Spawn(boostStartEffect, transform.position);
|
||||
foreach(ParticleSystem particle in boostStartEffect){
|
||||
particle.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,10 +372,11 @@ public class SpaceshipController : NetworkBehaviour
|
||||
return val;
|
||||
}
|
||||
}
|
||||
public float MovementSmoothnessFactor = 0.1f;
|
||||
void HandleTick(){
|
||||
curBufferIndex = bufferIndex;
|
||||
if(isLocalPlayer){
|
||||
HandleInput(input);
|
||||
// HandleInput(input);
|
||||
|
||||
InputState curInputState = new InputState(){Tick=currentTick, Input = input};
|
||||
PlayerState curState = new PlayerState(){Tick=currentTick, Position= transform.position, Rotation = transform.rotation};
|
||||
@@ -369,6 +386,11 @@ public class SpaceshipController : NetworkBehaviour
|
||||
// transform.Translate(transform.forward * input.y);
|
||||
// transform.Rotate(transform.up * input.x);
|
||||
UpdateStates(currentTick, NetworkTime.rtt, input, curState.Position, curState.Rotation);
|
||||
|
||||
body.position = targetState.Position;
|
||||
body.rotation = targetState.Rotation;
|
||||
// body.position = Vector3.Lerp(body.position,targetState.Position,MovementSmoothnessFactor * movingSpeed);
|
||||
// body.rotation = Quaternion.Lerp(body.rotation, targetState.Rotation,MovementSmoothnessFactor*movingSpeed);
|
||||
}else if (isServer){
|
||||
HandleInput(m_Input);
|
||||
RpcUpdateOnClient(body.position, body.rotation, m_Input);
|
||||
@@ -383,7 +405,13 @@ public class SpaceshipController : NetworkBehaviour
|
||||
if(isLocalPlayer){CameraFollower.UpdateFrame();}
|
||||
|
||||
float stateError = clientStateBuffer[bufferIndex].Difference(serverStateBuffer[latencyBufferIndex]);
|
||||
|
||||
foreach(ParticleSystem boostEffect in boostEffects){
|
||||
if(boostEffect.isEmitting && !boosting){
|
||||
boostEffect.Stop();
|
||||
}else if(!boostEffect.isEmitting && boosting){
|
||||
boostEffect.Play();
|
||||
}
|
||||
}
|
||||
if(isServer){
|
||||
InputState curServerInputState = new InputState(){Tick=currentTick, Input = m_Input};
|
||||
PlayerState curServerState = new PlayerState(){Tick=currentTick, Position = transform.position, Rotation = transform.rotation};
|
||||
@@ -469,7 +497,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
[ClientRpc]
|
||||
void RpcUpdateOnClient(Vector3 m_position, Quaternion m_rotation, Vector2 _input){
|
||||
if(isLocalPlayer){
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
targetState = new PlayerState(){Position = m_position, Rotation = m_rotation};
|
||||
}
|
||||
@@ -638,7 +666,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
// scaleMultiplier += 0.05f;
|
||||
moonsCollected++;
|
||||
Scores += 2;
|
||||
}else if(type == PickupItem.PickupType.Star){
|
||||
}else {
|
||||
IncreaseTrail(trailIncrementRate / 2f);
|
||||
Scores += 1;
|
||||
}
|
||||
@@ -663,7 +691,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
MinigameManager.instance.GainMetals(gainedEnergy);
|
||||
}
|
||||
|
||||
AudioManager.instnace.CollectMoon();
|
||||
AudioManager.instnace.CollectMoon(trailTime,maxTrailTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user