예제 #1
0
    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();
        }
    }
예제 #2
0
 public void TryRemoveEnemyLockingOnToUs(PlayerScript enemy)
 {
     if (Enemies.ContainsKey(enemy))
     {
         Enemies.Remove(enemy);
         OnStoppedBeingLockedOnByEnemy(enemy);
     }
 }
예제 #3
0
        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));
        }
예제 #4
0
 public Entity GetEntityByKey(string key)
 {
     if (Players.ContainsKey(key))
     {
         return(Players[key]);
     }
     if (Enemies.ContainsKey(key))
     {
         return(Enemies[key]);
     }
     return(null);
 }
예제 #5
0
        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));
        }
예제 #6
0
        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;
                }
            }
        }
예제 #7
0
        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);
        }