private void Start()
    {
        lr         = GetComponentInChildren <LineRenderer>();
        npcManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <NPCManager>();
        switch (myClasse)
        {
        case classe.GUNNER:
        {
            Alliee a = new Gunner(gameObject, npcManager);
            npcManager.AddAlliee(a);
            me = a;
            break;
        }

        case classe.SNIPER:
        {
            Alliee a = new Sniper(gameObject, npcManager);
            npcManager.AddAlliee(a);
            me = a;
            break;
        }

        case classe.SPECIALIST:
        {
            Alliee a = new Specialist(gameObject, npcManager);
            npcManager.AddAlliee(a);
            me = a;
            break;
        }

        case classe.CANNONFODDER:
        {
            Ennemy e = new CannonFodder(gameObject, npcManager);
            npcManager.AddEnnemy(e);
            me = e;
            break;
        }

        case classe.RUNNER:
        {
            Ennemy e = new Runner(gameObject, npcManager);
            npcManager.AddEnnemy(e);
            me = e;
            break;
        }

        case classe.BOSS:
        {
            Ennemy e = new Boss(gameObject, npcManager);
            npcManager.AddEnnemy(e);
            me = e;
            break;
        }

        default:
            throw new System.ArgumentException("Invalid classe.");
        }
        rb = GetComponent <Rigidbody>();
    }
Exemple #2
0
        private Enemy CreateEnemyFromDef(EnemyDef definition)
        {
            Enemy enemy = null;

            if (definition.EnemyType == "cannon_fodder")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, 250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "cannon_fodder_low")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, -250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "cannon_fodder_straight")
            {
                enemy = new Cruiser(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));
                enemy.Path = new Path(_pathPoints, 16);
            }
            else if (definition.EnemyType == "asteroid")
            {
                enemy = new Asteroid(_textureManager, _effectsManager, _playerCharacter);

                Random random = new Random();
                double y      = random.Next((int)_bounds.Top, (int)_bounds.Bottom);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, y, 0));
                _pathPoints.Add(new Vector(-1400, y, 0));

                enemy.Path = new Path(_pathPoints, 20);
            }
            else if (definition.EnemyType == "up_1")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(500, -375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, 200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "down_1")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(500, 375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, -200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "boss")
            {
                enemy = new Boss(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(300, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else
            {
                System.Diagnostics.Debug.Assert(false, "Uknown enemy type.");
            }

            return(enemy);
        }