public void SpawnPlayer(int playerId, int modelToSpawn, Vector3 pos) { Debug.Log($"Instantiating player {playerId} at pos {pos} that picked {modelToSpawn}"); _spawnedModels++; UpdateConnectionStatus(playerId); if (playerId == ServerID) { //THIS IS LOCAL PLAYER Debug.Log($"Instantiating Local"); SpawnPoint = pos; Manager.InstantiateLocalPlayer(modelToSpawn, pos); } else if (TeamMates.ContainsKey(playerId)) { //TEAMMATE Debug.Log($"Instantiating TeamMate"); Manager.InstantiateTeamMate(playerId, modelToSpawn, pos); } else if (Enemies.ContainsKey(playerId)) { //ENEMY Debug.Log($"Instantiating Enemy"); Manager.InstantiateEnemy(playerId, modelToSpawn, pos); } else { Application.Quit(); } }
public void TryRemoveEnemyLockingOnToUs(PlayerScript enemy) { if (Enemies.ContainsKey(enemy)) { Enemies.Remove(enemy); OnStoppedBeingLockedOnByEnemy(enemy); } }
public static Enemy GetEnemy(string name) { Enemy enemyToCopy = DefaultEnemy; if (Enemies.ContainsKey(name)) { enemyToCopy = Enemies[name]; } return(enemyToCopy == null ? null : new Enemy(null, enemyToCopy.Sprite, enemyToCopy.HitboxRadius, enemyToCopy.Scale, enemyToCopy.Speed, enemyToCopy.Health, enemyToCopy.Armor, enemyToCopy.Damage, enemyToCopy.LayerDepth)); }
public Entity GetEntityByKey(string key) { if (Players.ContainsKey(key)) { return(Players[key]); } if (Enemies.ContainsKey(key)) { return(Enemies[key]); } return(null); }
public Entity RemoveEnemy(Position pos) { ImmutableDictionary <Position, int> tmpo = Obstacles, tmpe = Enemies; if (Obstacles.ContainsKey(pos)) { tmpo = Obstacles.Remove(pos); } if (Enemies.ContainsKey(pos)) { tmpe = Enemies.Remove(pos); } return(UpdateWith(obstacles: tmpo, enemies: tmpe)); }
public static void Add(string name, Enemy enemy) { if (!Enemies.ContainsKey(name)) { Enemies.Add(name, enemy); if (enemy.HitboxRadius > LargestEnemyHitboxRadius) { LargestEnemyHitboxRadius = enemy.HitboxRadius; } if (DefaultEnemy == null) { DefaultEnemy = enemy; } } }
public List <Position> AdjacentToEnemy(Position pos) { List <Position> adjacent = new List <Position>(); if (Enemies.ContainsKey(new Position(pos.Y, pos.X + 1))) { adjacent.Add(new Position(pos.Y, pos.X + 1)); } if (Enemies.ContainsKey(new Position(pos.Y, pos.X - 1))) { adjacent.Add(new Position(pos.Y, pos.X - 1)); } if (Enemies.ContainsKey(new Position(pos.Y + 1, pos.X))) { adjacent.Add(new Position(pos.Y + 1, pos.X)); } if (Enemies.ContainsKey(new Position(pos.Y - 1, pos.X))) { adjacent.Add(new Position(pos.Y - 1, pos.X)); } return(adjacent); }