public static bool IsClosestPlayerWest(Player source) { Player target = GetClosest(source); if (target.GetPosition().X < source.GetPosition().X) { return true; } return false; }
public void Update(Player player) { if (m_isTemporary) { m_lifeTime--; if (m_lifeTime <= 0) { m_isActive = false; Undo(player); } } }
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; }
public static void Add(Player player) { s_players.Add(player); }
public virtual void Undo(Player player) { }
public virtual void Apply(Player player) { }
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; }
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()); }