Пример #1
0
 public EnemyCannon(Game game, Tank Tank, Enemy enemy)
     : base(game)
 {
     tank = Tank;
         this.enemy = enemy;
         this.game = game;
 }
Пример #2
0
        private void start()
        {
            badGuys = new Enemy[NUMBER_OF_ENEMYS];


            player = new Player(this, Content, graphics, UnitTypes.PlayerType.TankPlayer);
            player.tank.setPosition(player.tank.Orientation.Translation + new Vector3(300, 0, 150));
            player.WorldTrees = trees;
            #region  Constructor Physic
            space = new Space();
            EnemyCannonBall.EnemyCannonBallCollisionGroup = new CollisionGroup();
            Enemy.EnemyTankCollisionGroup = new CollisionGroup();
            Physic = new Physics(this, player, Content, terrain, space);
            player.phisics = Physic;
            #endregion

            Vector3 temp;
            Components.Add(terrain);
            for (int i = 0; i < badGuys.Length; i++)
            {
                temp = new Vector3(((float)rand.NextDouble() - 0.5f) * 512 * 8, 0, ((float)rand.NextDouble() - 0.5f) * 512 * 8);
                badGuys[i] = new Enemy(this, Content, graphics, UnitTypes.EnemyType.TankEnemy, space, temp);
                badGuys[i].tank.setPosition(temp);
                badGuys[i].Player = player;
                badGuys[i].State = Enemy.EnemyState.Wander;
                badGuys[i].WorldTrees = trees;
                badGuys[i].phisics = Physic;
                badGuys[i].healthManager = Physic.healthManager;
                //badGuys[i].DrawOrder = 102;
                Components.Add(badGuys[i]);
            }
            player.EnemyList = badGuys;


            //tank.DrawOrder = 100;
            player.DrawOrder = 101;

            // Register the particle system components.
            //Components.Add(tank);


            Components.Add(player);
            Components.Add(explosionParticles);
            Components.Add(explosionSmokeParticles);
            Components.Add(projectileTrailParticles);
            for (int i = 0; i < trees.Length; i++)
            {
                trees[i].DrawOrder = 102;
                Components.Add(trees[i]);
            }
            // Game Screen
            //Components.Add(new GameScreen(this, player));
            gameScreen = new GameScreen(this, player);
            Components.Add(gameScreen);
        }
Пример #3
0
        private void UpdateTarget()
        {
            aimEnemy = null;
            numEnemiesAlive = 0;

            // Shoot ray
            Ray ray = new Ray(tank.Position, tank.ForwardVector);

            // Distance from the ray start position to the terrain
            float? distance = terrain.Intersects(ray);

            // Test intersection with enemies
            foreach (Enemy enemy in enemyList)
            {
                if (!enemy.IsDead)
                {
                    numEnemiesAlive++;

                    float? enemyDistance = enemy.BoxIntersects(ray);

                    if (enemyDistance != null)
                    {

                        if (distance == null || enemyDistance <= distance)
                        {
                            distance = enemyDistance;
                            aimEnemy = enemy;
                            //System.Console.WriteLine(numEnemiesAlive);
                        }
                    }
                }
            }

            // Weapon target position
            //weaponTargetPosition = gameLevel.Player.Weapon.FirePosition +
            //gameLevel.Player.Weapon.TargetDirection * 300;
        }