예제 #1
0
    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);
    }
예제 #2
0
    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);
        }
    }
예제 #3
0
    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");
            }
        }
    }
예제 #4
0
    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);
        }
    }
예제 #5
0
    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");
        }
    }
예제 #6
0
    private void OnBadguyKilled(Badguy badguy)
    {
        if (onBadguyKilled != null)
        {
            onBadguyKilled.Invoke(badguy.EnemyType);
        }

        levelController.BadguyCleared(badguy);
    }
예제 #7
0
    protected virtual void RemoveBadguy(Badguy badguy)
    {
        poolManager.DisableObject(badguy);
        badguy.Die();

        if (onBadguyKilled != null)
        {
            onBadguyKilled.Invoke(badguy);
        }

        CheckAllBadguysCleared();
    }
예제 #8
0
    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
        {
        }
    }