Category5.Victim.HitCheck C# (CSharp) Метод

HitCheck() защищенный Метод

Try and damage our victims with our stats
protected HitCheck ( Victim groundObject ) : void
groundObject Victim
Результат void
        protected virtual void HitCheck(Victim groundObject)
        {
            if (groundObject.state == State.Ground)
            {
                float diameter = 0.0f;
                if (bounds.Width > bounds.Height)
                {
                    diameter = bounds.Width;
                }
                else
                {
                    diameter = bounds.Height;
                }

                Rectangle2D collideBox = new Rectangle2D(this.bounds.Center.X - (diameter / 2.0f), this.bounds.Center.Y - (diameter / 2.0f), diameter, diameter);

                switch (state)
                {
                    case State.Flying:
                        if (collideBox.Rectangle.Intersects(groundObject.bounds.Rectangle)) //we need to add damage
                        {
                            SoundEffectEngine.Play(soundHit,SoundEffectEngine.Priority.Normal);

                            float damageDone = getDamage(groundObject);

                            float resdamage = groundObject.RecieveHit(damageDone, this.tornado);

                            if (resdamage > 0)
                            {
                                this.TornadoHealth = 0; //If we can't kill the ground
                            }

                            if (this.TornadoHealth <= 0)
                            {
                                state = State.Exploding;
                            }
                        }
                        break;
                }
            }
        }