IEnumerator BreakCar() { int time = Random.Range(3, 6); yield return(new WaitForSeconds(time)); breakOn = true; speed = 0; brokenButton = GuiManager.instance.InstantiateUIButton(); brokenButton.SetOnClick(UnbreakCar); brokenButton.SetOffset(new Vector3(0, 24, 0)); // brokenButton.SetOffset(new Vector3(0, 128, 0)); brokenButton.SetImage(breakSprite); brokenButton.ShowText(false); brokenButton.target = transform; isBroken = true; firePart = GameObject.Instantiate(particleFire, transform.position, Quaternion.identity); if (!brokenMessage) { brokenMessage = true; brokenInstruction = GuiManager.instance.InstantiateUIInstructionEmpty(); brokenInstruction.SetText("TAP TO FIX CAR"); brokenInstruction.Show(false, false, true); brokenInstruction.target = transform; brokenInstruction.SetOffset(new Vector3(0, 172, 0)); GameManager.instance.ManageTime(0); yield return(new WaitForSecondsRealtime(5)); GameManager.instance.ManageTime(1); } Debug.Log("eNTRO A ROMPERESE"); }
public void OnEndArrive() { if (!rewardSended) { rewardSended = true; float rewardMult = Mathf.Clamp(5 - timeBreak, 0, 5); int r = (int)(reward * rewardMult); UISituation endReward = GuiManager.instance.InstantiateUISituation(); endReward.Show(false, false, true); endReward.SetText("+" + r); endReward.SetOffset(-direction); endReward.SetPos(transform.position + new Vector3(0, 2, 0)); Color col; if (rewardMult <= 1) { col = Color.red; } else if (rewardMult > 1 && rewardMult < 3.5f) { col = Color.yellow; } else { col = Color.green; } endReward.SetTextColor(col); endReward.Anim(); Destroy(endReward.gameObject, 1); GameManager.instance.OnCarPassed(r, carType); } spawner.currentCars.Remove(gameObject); OnDie(); }