private void SetPlatformForLevelOfDifficulty() { _sprRend = GetComponent <SpriteRenderer>(); switch (SceneManager.GetActiveScene().name) { case "1": break; case "2": _health = Mathf.CeilToInt(Random.Range(1, 4)); _sprRend.color = gameMgr.instance().GetLifeColor(_health - 1); break; case "3": _health = Mathf.CeilToInt(Random.Range(1, 4)); _sprRend.color = gameMgr.instance().GetLifeColor(_health - 1); if (Random.Range(0, 8) == 0) { _bonusType = (Bonus.BonusType)Random.Range(1, 6); } break; } }
//Public methods public void CreateBonusByBonusType(Bonus.BonusType bonusType, Vector3 position, Quaternion rotation) { Bonus bonusGO = Instantiate(bonusTemplate, position, rotation); bonusGO.SetBonusType(bonusType); bonusGO.gameObject.SetActive(true); }
void OnGUI() { GUI.skin = GameConfig.GetInstance().skin; GameConfig conf = GameConfig.GetInstance(); for (int i = 0; i < conf.players.Count; ++i) { GUI.Label(new Rect(20, (Screen.height / 2) * (1 - i) + 20, 120, 80), "Player " + (conf.players[i] + 1)); Control control = players[i].GetComponent <Control>(); Bonus.BonusType type = control.GetBonusType(); Debug.Log("Type : " + type); Rect texRect = new Rect(20, (Screen.height / 2) * (1 - i) + 100, 100, 100); if (type == Bonus.BonusType.Ink) { GUI.DrawTexture(texRect, inkTex); } else if (type == Bonus.BonusType.Bomb) { GUI.DrawTexture(texRect, bombTex); } } }
int GetBonusIndex(Bonus.BonusType bType) { for (int i = 0; i < m_AppliedBonuses.Count; i++) { if (m_AppliedBonuses[i].GetBonusType() == bType) { return(i); } } return(-1); }
private void spawnBonus() { if (UnityEngine.Random.value < 0.3) { Array values = Enum.GetValues(typeof(Bonus.BonusType)); System.Random random = new System.Random(); Bonus.BonusType randomType = (Bonus.BonusType)values.GetValue(random.Next(values.Length)); GameObject powerup = Instantiate(bonus); powerup.transform.position = this.transform.position; powerup.SendMessage("setType", randomType); powerup.SendMessage("startMovement"); } }
internal void ReceiveBonus(Bonus.BonusType bonusType) { switch (bonusType) { case Bonus.BonusType.Armor: damageable.UpgradeArmor(); break; case Bonus.BonusType.FireRate: fireManager.fireRate *= 1.5f; break; case Bonus.BonusType.CannonUpgrade: fireManager.UpgradeLevel(); break; case Bonus.BonusType.Health: damageable.Regen(20f); break; case Bonus.BonusType.Life: GameManager.Instance.GainLife(); break; case Bonus.BonusType.Shield: StartCoroutine(Shield(shieldTime)); break; case Bonus.BonusType.Speed: StartCoroutine(SpeedBoost()); break; case Bonus.BonusType.ClearAll: foreach (var enemy in GameObject.FindObjectsOfType <Enemy>()) { enemy.GetComponent <Damageable>().Die(); } break; case Bonus.BonusType.FullRegen: damageable.Regen(100f); break; case Bonus.BonusType.CrazyBomb: StartCoroutine(CrazyBomb(crazyBombTime)); break; default: break; } }
public void applyBonus(Bonus.BonusType type) { switch (type) { default: score.SendMessage("addPoints", 50); break; case Bonus.BonusType.EXPAND: StartCoroutine(expand()); break; case Bonus.BonusType.SPEED: StartCoroutine(speedup()); break; } }
void UpdateColor(Bonus.BonusType bType) { switch (bType) { case BonusType.Acceleration: m_Renderer.color = Color.grey; break; case BonusType.Deacceleration: m_Renderer.color = Color.cyan; break; case BonusType.Ball: m_Renderer.color = Color.red; break; case BonusType.PlatfromIncrease: m_Renderer.color = Color.magenta; break; } }
void HandleSpeedBonuses(AppliedBonus bonus, Bonus.BonusType bonusToDeactivate) { int deactIdx = GetBonusIndex(bonusToDeactivate); if (deactIdx >= 0 && m_AppliedBonuses[deactIdx].isActivated()) { m_AppliedBonuses[deactIdx].ActivateBonus(false); } int actIdx = GetBonusIndex(bonus.GetBonusType()); if (actIdx >= 0) { if (m_AppliedBonuses[actIdx].isActivated()) { m_AppliedBonuses[actIdx].ActivateBonusTime(); } else { m_AppliedBonuses[actIdx].ActivateBonus(true); } } else { m_AppliedBonuses.Add(bonus); bonus.ActivateBonus(true); bonus.AddTimeElapseListener(BonusTimeUp); } if (bonus.GetBonusType() == Bonus.BonusType.Acceleration) { SetBallsSpeed(Ball.INC_SPEED); } else { SetBallsSpeed(Ball.DEC_SPEED); } }
public AppliedBonus(Bonus.BonusType bType) { m_BonusType = bType; }