AddVictim() public method

public AddVictim ( Victim victim ) : void
victim Victim
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Recieve a hit at a certain damange and returns if the building was destroyed
        /// </summary>
        /// <returns>0 = building wad destroyed. Positive values represent the building's remaining health</returns>
        protected virtual float RecieveHit(float Damage, Tornado tornado)
        {
            float tempvar = this.GroundHealth - Damage; //How much damage we would do negative is overkill

            switch (this.state)
            {
                case State.Ground:
                    if (tempvar <= 0)
                    {
                        if (soundHit != "" && Damage > 0)
                            SoundEffectEngine.Play(soundHit, SoundEffectEngine.Priority.Normal);
                        //INFO: Inform object it is dead change state to flying and get picked up by tornado

                        this.GroundHealth = 0;
                        this.tornado = tornado;
                        this.state = State.Flying;
                        Victim newVictim = this.Clone();
                        newVictim.requestRemoveFromMegaTile = true;
                        newVictim.megatile = null;
                        tornado.AddVictim(newVictim);
                        this.state = State.Stump;
                        //if (megatile != null)
                        //{
                            this.requestRemoveFromMegaTile = removeFromMegaTileOnDeath;
                        //}
                    }
                    else
                    {
                        this.GroundHealth = tempvar;
                    }
                    break;
            }

            return tempvar;
        }