public override void Tick() { base.Tick(); if (IsConstructing) { if (Timer.GetRemainingSeconds(Level.Avatar.LastTick) <= 0) { FinishConstruction(); } } if (IsBoosted) { if (BoostTimer.GetRemainingSeconds(Level.Avatar.LastTick) <= 0) { IsBoosted = false; } } if (IsGearing) { if (Timer.GetRemainingSeconds(Level.Avatar.LastTick) <= 0) { FinishConstruction(); } } }
public new JObject Save(JObject jsonObject) { jsonObject.Add("bv", BuilderVillage); jsonObject.Add("lvl", UpgradeLevel); if (IsGearing) { jsonObject.Add("gearing", IsGearing); jsonObject.Add("const_t", Timer.GetRemainingSeconds(Level.Avatar.LastTick)); jsonObject.Add("const_t_end", Timer.EndTime); } if (IsConstructing) { jsonObject.Add("const_t", Timer.GetRemainingSeconds(Level.Avatar.LastTick)); jsonObject.Add("const_t_end", Timer.EndTime); } if (IsBoosted) { jsonObject.Add("boost_t", BoostTimer.GetRemainingSeconds(Level.Avatar.LastTick)); jsonObject.Add("boost_t_end", BoostTimer.EndTime); } if (Locked) { jsonObject.Add("locked", true); } base.Save(jsonObject); return(jsonObject); }
private void Start() { gameMaster = GameObject.FindGameObjectWithTag(Utilities.GAME_MASTER_TAG).GetComponent<GameMaster>(); boostTimer = GetComponentInChildren<BoostTimer>(); startDialog = GetComponentInChildren<StartDialog>(); HUD = GetComponentInChildren<HUD>(); joystickController = GetComponentInChildren<JoystickController>(); string currentSceneName = SceneManager.GetActiveScene().name; int currentLvl = int.Parse(currentSceneName.Substring(3)); lvlText.text = "Level " + currentLvl; alertText.GetComponent<CanvasRenderer>().SetAlpha(0); }
void Update() { for (int i = boostActions.Count - 1; i >= 0; i--) { BoostTimer bt = (BoostTimer)boostActions[i]; switch (bt.booster) { case Booster.FORWARD: rb.AddRelativeForce(new Vector2(boostForwardForce, 0)); break; case Booster.BACKWARD: rb.AddRelativeForce(new Vector2(-boostBackwardForce, 0)); break; case Booster.LEFT: rb.AddRelativeForce(new Vector2(0, boostSideForce)); break; case Booster.RIGHT: rb.AddRelativeForce(new Vector2(0, -boostSideForce)); break; default: break; } bt.Update(Time.deltaTime); } if (stabilzeTravelDirection) { Vector3 vectorToTarget = (transform.position + new Vector3(rb.velocity.normalized.x, rb.velocity.normalized.y, 0)) - transform.position; float angle = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg; Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * angularSpeed); } }