예제 #1
0
        public void Collision(Harmful harmful) // Gère les collisions entre nuisibles lorsqu'ils sont sur la même case
        {
            if (harmful._state == state.Dead || _state == state.Dead)
            {
                return;
            }

            if (_state == state.Zombie)     // Un nuisible applique le state et la vitesse du zombie si il est touché
            {
                harmful._state = state.Zombie;
                harmful._speed = Zombie._speed;
            }
            else if (harmful._state != state.Zombie && this.GetType() != harmful.GetType())
            {
                Random Kill = new Random();
                if (Kill.Next(0, 2) == 0)        // Random entre 0 et 2 non compris pour décider qui meurt entre le rat et le pigeon
                {
                    harmful._state = state.Dead;
                }
                else
                {
                    this._state = state.Dead;
                }
            }
        }
예제 #2
0
 public bool IsSameCase(Harmful harmful)   // Check que la position entre deux nuisibles est la même pour les collisions
 {
     return(this._position.X == harmful._position.X && this._position.Y == harmful._position.Y);
 }