Example #1
0
 public static bool IsClosestPlayerWest(Player source)
 {
     Player target = GetClosest(source);
     if (target.GetPosition().X < source.GetPosition().X)
     {
         return true;
     }
     return false;
 }
Example #2
0
 public void Update(Player player)
 {
     if (m_isTemporary)
     {
         m_lifeTime--;
         if (m_lifeTime <= 0)
         {
             m_isActive = false;
             Undo(player);
         }
     }
 }
Example #3
0
 private static Player GetClosest(Player source)
 {
     List<float> s_distances = new List<float>();
     foreach (Player target in s_players)
     {
         s_distances.Add(Math.Abs(target.GetPosition().X-source.GetPosition().X)+Math.Abs(target.GetPosition().Y-source.GetPosition().Y));
     }
     float leastDistance = float.PositiveInfinity;
     Player result = null;
     for (int ii = 0; ii < s_distances.Count(); ii++)
     {
         if (s_distances[ii] != 0)
         {
             if (s_distances[ii] < leastDistance)
             {
                 leastDistance = s_distances[ii];
                 result = s_players[ii];
             }
         }
     }
     return result;
 }
Example #4
0
 public static void Add(Player player)
 {
     s_players.Add(player);
 }
Example #5
0
 public virtual void Undo(Player player)
 {
 }
Example #6
0
 public virtual void Apply(Player player)
 {
 }
Example #7
0
 public bool Unregister(GameplayObject component)
 {
     switch (component.GetAssetType())
     {
         case SpriteType.BOMB:
             m_drawableComponents.Remove(m_bomb);
             m_bomb = null;
             break;
         case SpriteType.PLAYER_WALK:
             m_drawableComponents.Remove(m_player);
             m_player = null;
             break;
         case SpriteType.PLAYER_STAND:
             m_drawableComponents.Remove(m_player);
             m_player = null;
             break;
         case SpriteType.DIRT_FLOOR:
             m_drawableComponents.Remove(m_environmentTile);
             m_environmentTile = null;
             break;
         case SpriteType.EXPLOSION:
             m_drawableComponents.Remove(m_explosion);
             m_explosion = null;
             break;
         case SpriteType.WALL:
             m_drawableComponents.Remove(m_wall);
             m_wall = null;
             break;
         case SpriteType.CRATE:
             m_drawableComponents.Remove(m_crate);
             m_crate = null;
             break;
         case SpriteType.POWERUP:
             m_drawableComponents.Remove(m_powerup);
             m_powerup = null;
             break;
         default:
             throw new Exception("An unhandled type was detected in BoardTile.");
     }
     //Console.Write(GetDebugLog());
     return true;
 }
Example #8
0
 public bool Register(GameplayObject component)
 {
     if (!Contains(component.GetAssetType()))
     {
         switch (component.GetAssetType())
         {
             case SpriteType.BOMB:
                 m_bomb = (Bomb)component;
                 m_drawableComponents.Add(m_bomb);
                 break;
             case SpriteType.PLAYER_WALK:
                 m_player = (Player)component;
                 m_drawableComponents.Add(m_player);
                 break;
             case SpriteType.PLAYER_STAND:
                 m_player = (Player)component;
                 m_drawableComponents.Add(m_player);
                 break;
             case SpriteType.DIRT_FLOOR:
                 m_environmentTile = (EnvironmentTile)component;
                 m_drawableComponents.Add(m_environmentTile);
                 break;
             case SpriteType.EXPLOSION:
                 if (!IsTypeRegistered(SpriteType.WALL))
                 {
                     m_explosion = (Explosion)component;
                     m_drawableComponents.Add(m_explosion);
                 }
                 break;
             case SpriteType.WALL:
                 m_wall = (Wall)component;
                 m_drawableComponents.Add(m_wall);
                 break;
             case SpriteType.CRATE:
                 m_crate = (Crate)component;
                 m_drawableComponents.Add(m_crate);
                 break;
             case SpriteType.POWERUP:
                 m_powerup = (Powerup)component;
                 m_drawableComponents.Add(m_powerup);
                 break;
             default:
                 throw new Exception("An unhandled type was detected in BoardTile.");
         }
         return true;
     }
     return false;
     //Console.Write(GetDebugLog());
 }