コード例 #1
0
        protected void TargetIsDead(Placeable p)
        {
            //Debug.Log("My target " + p.name + " is dead", gameObject);
            state = States.Idle;

            target.OnDie -= TargetIsDead;

            timeToActNext = lastBlowTime + attackRatio;
        }
コード例 #2
0
        private void OnPlaceableDead(Placeable p)
        {
            p.OnDie -= OnPlaceableDead; //remove the listener

            switch (p.pType)
            {
            case Placeable.PlaceableType.Unit:
                Unit u = (Unit)p;
                RemovePlaceableFromList(u);
                u.OnDealDamage      -= OnPlaceableDealtDamage;
                u.OnProjectileFired -= OnProjectileFired;
                UIManager.RemoveHealthUI(u);
                StartCoroutine(Dispose(u));
                break;

            case Placeable.PlaceableType.Building:
            case Placeable.PlaceableType.Castle:
                Building b = (Building)p;
                RemovePlaceableFromList(b);
                UIManager.RemoveHealthUI(b);
                b.OnDealDamage      -= OnPlaceableDealtDamage;
                b.OnProjectileFired -= OnProjectileFired;
                StartCoroutine(RebuildNavmesh());     //need to fix for normal buildings

                //we don't dispose of the Castle
                if (p.pType != Placeable.PlaceableType.Castle)
                {
                    StartCoroutine(Dispose(b));
                }
                break;

            case Placeable.PlaceableType.Obstacle:
                StartCoroutine(RebuildNavmesh());
                break;

            case Placeable.PlaceableType.Spell:
                //TODO: can spells die?
                break;
            }
        }
コード例 #3
0
        private void OnCastleDead(Placeable c)
        {
            cinematicsManager.PlayCollapseCutscene(c.faction);
            c.OnDie -= OnCastleDead;
            gameOver = true; //stops the thinking loop

            //stop all the ThinkingPlaceables
            ThinkingPlaceable thkPl;

            for (int pN = 0; pN < allThinkingPlaceables.Count; pN++)
            {
                thkPl = allThinkingPlaceables[pN];
                if (thkPl.state != ThinkingPlaceable.States.Dead)
                {
                    thkPl.Stop();
                    thkPl.transform.LookAt(c.transform.position);
                    UIManager.RemoveHealthUI(thkPl);
                }
            }

            CPUOpponent.StopActing();
        }