private void SetGameOver() { isGameOver = true; cardManager.IsActive = false; // Stop the spawners ActivateSpawners(false); for (int i = Targets.transform.childCount - 1; i >= 0; i--) { Transform child = Targets.transform.GetChild(i); Target tgt = child.GetComponent <Target>(); tgt.Speed = 0.0f; Badguy bad = child.GetComponent <Badguy>(); if (bad != null) { bad.IsAttacking = false; } } CloseCurtain(CurtainLeft); CloseCurtain(CurtainRight); gameUI.GameOverPanel.SetActive(true); }
public void SetKind(Kind kind) { TargetKind = kind; Badguy badguy = GetComponent <Badguy>(); Transform badXfrm = transform.Find("badguy"); Transform duckXfrm = transform.Find("duck"); Transform nunXfrm = transform.Find("nun"); badguy.enabled = kind == Kind.Badguy; if (badXfrm != null) { badXfrm.gameObject.SetActive(kind == Kind.Badguy); } if (duckXfrm != null) { duckXfrm.gameObject.SetActive(kind == Kind.Duck); } if (nunXfrm != null) { nunXfrm.gameObject.SetActive(kind == Kind.Nun); } }
public void BadguyCleared(Badguy badguy) { if (badguy.EnemyType == Wave.enemyType) { enemiesKilled++; AddScore(SCORE_WAVE_KILLENEMY, "Killed Enemy"); } if (badguy.EnemyType == Wave.EnemyType.Asteroid) { Asteroid ab = badguy as Asteroid; if (ab.ChunksRemaining == 3) { AddScore(SCORE_ASTEROIDHIT_3, "Asteroid destroyed"); } else if (ab.ChunksRemaining == 2) { AddScore(SCORE_ASTEROIDHIT_2, "Asteroid crushed"); } else if (ab.ChunksRemaining == 1) { AddScore(SCORE_ASTEROIDHIT_1, "Asteroid exploded"); } } }
void OnTriggerEnter(Collider other) { bool isHit = false; float damage = 0; if (healthController.IsAlive) { ProjectileEnemy projectile = other.gameObject.GetComponent <ProjectileEnemy>(); if (projectile != null) { projectile.Die(); damage = projectile.damage; isHit = true; } else { Badguy b = other.gameObject.GetComponent <Badguy>(); if (b != null) { damage = b.healthController.Health; } } } if (isHit) { healthController.Damage(damage); GameDirector.Explosion(transform.position, 0.2f); } }
static void Main(string[] args) { // 定义一个 Dictionary Dictionary <string, Badguy> badguys = new Dictionary <string, Badguy>(); // 添加元素 Badguy bg1 = new Badguy("liudiwen", 88); Badguy bg2 = new Badguy("miemie", 90); badguys.Add("liudiwen", bg1); badguys.Add("miemie", bg2); // 访问 // 若使用下标,则要保证 key 存在 // 或使用 TryGetValue 方法 //Console.WriteLine(badguys["qqqq"]); // exception invoke Console.WriteLine(badguys["liudiwen"]); Badguy tmp = null; if (badguys.TryGetValue("miemie", out tmp)) { Console.WriteLine(tmp); } else { Console.WriteLine("no miemie"); } }
private void OnBadguyKilled(Badguy badguy) { if (onBadguyKilled != null) { onBadguyKilled.Invoke(badguy.EnemyType); } levelController.BadguyCleared(badguy); }
protected virtual void RemoveBadguy(Badguy badguy) { poolManager.DisableObject(badguy); badguy.Die(); if (onBadguyKilled != null) { onBadguyKilled.Invoke(badguy); } CheckAllBadguysCleared(); }
private void Start() { List <Badguy> badguys = new List <Badguy>(); badguys.Add(new Badguy("Harver", 50)); badguys.Add(new Badguy("Magneto", 100)); badguys.Add(new Badguy("Pip", 5)); //badguys.Count;//用於總數量 //RemoveAt用移除 Insert badguys.Sort();//依賴IComparable foreach (Badguy guy in badguys) { Debug.Log(guy.name + " " + guy.power); } badguys.Clear(); //------------------------- Dictionary <string, Badguy> badguys2 = new Dictionary <string, Badguy>(); Badguy bg1 = new Badguy("Harvey2", 50); Badguy bg2 = new Badguy("Magneto2", 100); badguys2.Add("gangster", bg1); badguys2.Add("mutant", bg2); Badguy magneto = badguys2["mutant"]; Badguy temp = null; if (badguys2.TryGetValue("birds", out temp)) { } else { } }