Exemplo n.º 1
0
    /// <summary>
    /// a杀死b
    /// </summary>
    /// <param name="a"></param>
    /// <param name="d"></param>
    public void UnitDead(FightUnit a, FightUnit d)
    {
        if (!d.parentGroup.fightUnits.Contains(d))
        {
            return;
        }
        d.parentGroup.fightUnits.Remove(d);
        if (d.parentGroup.fightUnitsBak.Count > 0)
        {
            FightUnit b = d.parentGroup.fightUnitsBak[0];
            d.parentGroup.fightUnitsBak.RemoveAt(0);
            d.parentGroup.fightUnits.Add(b);
            b.gameObject.SetActive(true);
            b.transform.localPosition = d.transform.localPosition;
        }
        if (d.parentGroup.fightUnits.Count == 0)
        {
            if (d.parentGroup.group == FightGroup.GroupType.Mine)
            {
                GameOver();
            }
            else
            {
                if (enemyGroup.wave == DungeonManager.enemyWave.Count)
                {
                    Win();
                }
                else
                {
                    MoveToNext();
                }
            }
        }
        GameObject obj = Instantiate(dieEffect) as GameObject;

        obj.transform.position = d.transform.position;
        obj.transform.parent   = a.mTrans.parent;
        HealthUIManager.instance.RemoveHealthBar(d);
        StartCoroutine(DestroyUnit(d));
        if (d.OnDead != null)
        {
            d.OnDead(a);
        }
        if (a.OnKillEnemy != null)
        {
            a.OnKillEnemy(d);
        }
    }