prod 1
This commit is contained in:
@@ -13,7 +13,7 @@ public class CameraFollower : MonoBehaviour
|
||||
public float smoothness = 0.1f;
|
||||
public CameraUpdateMode updateMode;
|
||||
public static CameraFollower instance{get; private set;}
|
||||
public static void UpdateFrame()=> instance.HandleFrame();
|
||||
public static void UpdateFrame() {if(instance.updateMode == CameraUpdateMode.Manual){ instance.HandleFrame();}}
|
||||
void Awake(){
|
||||
instance=this;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public class KillfeedMgr : MonoBehaviour
|
||||
}
|
||||
|
||||
public void AddNewEntry(string message){
|
||||
return;
|
||||
for(int i =0; i < pool.Count; i++){
|
||||
if(!pool[i].gameObject.activeSelf){
|
||||
pool[i].SetEntry(message,entryAliveTime);
|
||||
|
||||
@@ -37,6 +37,10 @@ public class MinigameManager : NetworkBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
defaultJoyPos = joystick.transform.GetChild(0).GetComponent<RectTransform>().localPosition;
|
||||
|
||||
SwitchUISides();
|
||||
|
||||
// if(!DBmanager.LoggedIn){SceneManager.LoadScene(0);}
|
||||
SceneData.GameManager = this;
|
||||
instance = this;
|
||||
@@ -46,33 +50,62 @@ public class MinigameManager : NetworkBehaviour
|
||||
|
||||
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-150, btn_boost.position.y);
|
||||
Vector2 newDef = new Vector2(defaultJoyPos.x, defaultJoyPos.y);
|
||||
if(isRanked){
|
||||
if(ControlSettings.ControlIsOnRight){
|
||||
RectTransform canvasRect = joystick.root.GetComponent<RectTransform>();
|
||||
joystick.anchorMin = new Vector2(0f,0);
|
||||
joystick.anchorMax = new Vector2(0.5f, 1);
|
||||
joystick.localPosition = new Vector2(-canvasRect.sizeDelta.x /4f,0);
|
||||
Vector2 newDef = new Vector2(defaultJoyPos.x, defaultJoyPos.y);
|
||||
|
||||
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
|
||||
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
|
||||
|
||||
btn_boost.anchorMin = new Vector2(0,0);
|
||||
btn_boost.anchorMax = new Vector2(0,0);
|
||||
btn_boost.localPosition = new Vector2(150, btn_boost.localPosition.y);
|
||||
Debug.Log(btn_boost.localPosition);
|
||||
}else{
|
||||
RectTransform canvasRect = joystick.root.GetComponent<RectTransform>();
|
||||
joystick.anchorMin = new Vector2(0.5f,0);
|
||||
joystick.anchorMax = new Vector2(1f, 1);
|
||||
joystick.localPosition = new Vector2(canvasRect.sizeDelta.x /4f,0);
|
||||
Vector2 newDef = new Vector2(-defaultJoyPos.x, defaultJoyPos.y);
|
||||
|
||||
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
|
||||
|
||||
btn_boost.anchorMin = new Vector2(0,0);
|
||||
btn_boost.anchorMax = new Vector2(0,0);
|
||||
btn_boost.localPosition = new Vector2(150-(canvasRect.sizeDelta.x/2f), btn_boost.localPosition.y);
|
||||
Debug.Log(btn_boost.localPosition);
|
||||
}
|
||||
}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(150, btn_boost.position.y);
|
||||
Vector2 newDef = new Vector2(-defaultJoyPos.x, defaultJoyPos.y);
|
||||
if(ControlSettings.ControlIsOnRight){
|
||||
Debug.Log("Switching to right");
|
||||
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-150, btn_boost.position.y);
|
||||
Vector2 newDef = new Vector2(defaultJoyPos.x, defaultJoyPos.y);
|
||||
|
||||
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
|
||||
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(150, btn_boost.position.y);
|
||||
Vector2 newDef = new Vector2(-defaultJoyPos.x, defaultJoyPos.y);
|
||||
|
||||
joystick.GetComponent<Joystick>().SetDefaultPosition(newDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +148,11 @@ public class MinigameManager : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(RankedGameStarted && players.Length < 2){
|
||||
//Forfeited!
|
||||
winnerId = (int)players[0].netId;
|
||||
// players[0].WonRanked();
|
||||
}
|
||||
if(RankedGameStarted){
|
||||
if(timeElapsed > safeZoneCoolTime){
|
||||
if(!shrinkStarted){
|
||||
@@ -144,11 +181,7 @@ public class MinigameManager : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
if(RankedGameStarted && players.Length < 2){
|
||||
//Forfeited!
|
||||
winnerId = (int)players[0].netId;
|
||||
// players[0].WonRanked();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnMapRadisuChanged(float oldVal, float newVal){
|
||||
@@ -309,9 +342,15 @@ public class MinigameManager : NetworkBehaviour
|
||||
{
|
||||
StartCoroutine(setRespawn(player));
|
||||
}
|
||||
|
||||
|
||||
public void Restart(){
|
||||
if(SceneData.localPlayer.GetComponent<SpaceshipController>().dead){
|
||||
SetRespawn(SceneData.localPlayer);
|
||||
// SetRespawn(SceneData.localPlayer);
|
||||
AdsManager.SetOnInterestitialClosed(()=>{SetRespawn(SceneData.localPlayer);});
|
||||
if(!SceneData.holder.ShowAds()){
|
||||
SetRespawn(SceneData.localPlayer);
|
||||
}
|
||||
}else{
|
||||
Debug.LogError("You aren't dead, you can't restart unless you are dead.");
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ public class PickupItem : NetworkBehaviour
|
||||
active=false;
|
||||
// gameObject.SetActive(false);
|
||||
StartCoroutine(MoveToPlayer(playerPos));
|
||||
SceneData.GameManager.DeactivatePickupItem(this);
|
||||
}
|
||||
|
||||
IEnumerator MoveToPlayer(Transform position){
|
||||
@@ -105,6 +104,8 @@ public class PickupItem : NetworkBehaviour
|
||||
ParticleSystem particle = EffectPool.Spawn(PickupEffect, transform.position).GetComponent<ParticleSystem>();
|
||||
particle.startColor = type.GetColor();
|
||||
}
|
||||
SceneData.GameManager.DeactivatePickupItem(this);
|
||||
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,20 @@ public class SceneDataHolder : MonoBehaviour
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async void ShowAds(){
|
||||
public void ShowAd(){
|
||||
ShowAds();
|
||||
}
|
||||
public bool ShowAds(){
|
||||
|
||||
if(MinigameManager.instance.isRanked){
|
||||
if(AdsManager.instance!=null && (DateTime.Now - lastShownTime).Minutes > 10){
|
||||
AdsManager.instance.ShowInterestitial();
|
||||
lastShownTime = DateTime.Now;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -170,6 +170,7 @@ public class SkinShopManager : MonoBehaviour
|
||||
|
||||
void onUpgrade(){
|
||||
upgradePanel.Show(selectedSkin.name);
|
||||
AudioManager.instnace.UIPopup();
|
||||
}
|
||||
|
||||
public void onBuy(){
|
||||
|
||||
@@ -180,13 +180,21 @@ public class SpaceshipController : NetworkBehaviour
|
||||
}
|
||||
|
||||
CameraFollower.instance.ShakeBoost();
|
||||
Vibrate();
|
||||
|
||||
// GameObject fx = EffectPool.Spawn(boostStartEffect, transform.position);
|
||||
foreach(ParticleSystem particle in boostStartEffect){
|
||||
particle.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Vibrate(){
|
||||
#if UNITY_ANDROID
|
||||
if(ControlSettings.HapticEnabled){
|
||||
Handheld.Vibrate();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void OnBoostUp()
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
@@ -312,6 +320,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
int lastClientUpdateTime = 0;
|
||||
Vector3 lineCorrection;
|
||||
float scale => Mathf.Clamp(1 + (trailTime * _scaleMultiplier), 1, 10);
|
||||
long lastTime ;
|
||||
void Update()
|
||||
{
|
||||
if (MinigameManager.instance.isRanked && !MinigameManager.instance.RankedGameStarted) { return; }
|
||||
@@ -343,6 +352,12 @@ public class SpaceshipController : NetworkBehaviour
|
||||
DBmanager.SetMostTime((int)survivalTime);
|
||||
}
|
||||
SceneData.SetTimerTxt(survivalTime);
|
||||
|
||||
body.position = Vector3.Lerp(body.position,targetState.Position,MovementSmoothnessFactor * movingSpeed * Vector2.Distance(targetState.Position, body.position));
|
||||
body.rotation = Quaternion.Lerp(body.rotation, targetState.Rotation,MovementSmoothnessFactor*movingSpeed);
|
||||
Debug.Log(lastTime - currentTick);
|
||||
lastTime = targetState.Tick;
|
||||
CameraFollower.UpdateFrame();
|
||||
}
|
||||
|
||||
timer += Time.deltaTime;
|
||||
@@ -387,8 +402,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
// 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 = 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){
|
||||
@@ -402,7 +417,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
// HandleInput(m_Input);
|
||||
// }
|
||||
}
|
||||
if(isLocalPlayer){CameraFollower.UpdateFrame();}
|
||||
// if(isLocalPlayer){CameraFollower.UpdateFrame();}
|
||||
|
||||
float stateError = clientStateBuffer[bufferIndex].Difference(serverStateBuffer[latencyBufferIndex]);
|
||||
foreach(ParticleSystem boostEffect in boostEffects){
|
||||
@@ -478,6 +493,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
}
|
||||
[ClientRpc]
|
||||
void RpcRubberband(Vector3 m_position, Quaternion m_rotation){
|
||||
return;
|
||||
PlayerState serverState = new PlayerState(){Tick=0, Position = m_position, Rotation = m_rotation};
|
||||
PlayerState clientState = new PlayerState(){Tick=0, Position = transform.position, Rotation = transform.rotation};
|
||||
float diff = serverState.Difference(clientState);
|
||||
@@ -608,7 +624,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
[ClientRpc]
|
||||
void RpcShowDeathEffect(Vector2 position){
|
||||
EffectPool.Spawn(DeathEffect, position);
|
||||
EffectPool.Spawn(debrisEffect, position).GetComponent<DebrisEffect>().Play();
|
||||
// EffectPool.Spawn(debrisEffect, position).GetComponent<DebrisEffect>().Play();
|
||||
}
|
||||
|
||||
void OnKill()
|
||||
@@ -624,7 +640,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
[ClientRpc]
|
||||
void RpcOnKill()
|
||||
{
|
||||
|
||||
Vibrate();
|
||||
}
|
||||
|
||||
void OnKillsChanged(int oldVal, int newVal)
|
||||
@@ -700,6 +716,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
{
|
||||
|
||||
MinigameManager.instance.SpawnLeftoverPickups(transform.position, (int)((float)Scores / 4f));
|
||||
|
||||
RpcShowDeathEffect(transform.position);
|
||||
Debug.Log($"Sending death signal to {pname} by {killer}");
|
||||
|
||||
@@ -739,6 +756,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
if (MinigameManager.instance.winnerId <= 0)
|
||||
{
|
||||
Debug.LogError("Winner ID not synced yet");
|
||||
checkWinner(1000);
|
||||
}
|
||||
if (MinigameManager.instance.winnerId != netId)
|
||||
{
|
||||
@@ -757,6 +775,24 @@ public class SpaceshipController : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
async void checkWinner(int delay){
|
||||
await System.Threading.Tasks.Task.Delay(delay);
|
||||
|
||||
if (MinigameManager.instance.winnerId != netId)
|
||||
{
|
||||
//LOSER!
|
||||
MinigameManager.instance.rankedSummary.ShowLoss();
|
||||
AudioManager.instnace.MinigameLost();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MinigameManager.instance.rankedSummary.ShowWin();
|
||||
AudioManager.instnace.MinigameWon();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ShowRankedResults()
|
||||
{
|
||||
while (MinigameManager.instance.winnerId <= 0)
|
||||
|
||||
Reference in New Issue
Block a user