Exemplo n.º 1
0
        /// <summary>
        /// Constructor for Team Information
        /// </summary>
        /// <param name="teamId">Instance of Team class, indicating the identifier for the TeamInformation instance (red/blue)</param>
        /// <param name="fullyAIControlled">Indicates whether the team is human controlled or not</param>
        /// <param name="ownedTurrets">Owned turrets at the start of the game</param>
        /// <param name="teamStartingCredits">Initial credits</param>
        /// <param name="teamPlayer">Team player object</param>
        /// <param name="ownedNodes">Team's patrol nodes</param>
        /// <param name="ownedSpawnPoints">Team's owned spawn points</param>
        /// <param name="maxFighters">Maximum number of fighters</param>
        /// <param name="maxDestroyers">Maximum number of destroyers</param>
        /// <param name="teamHomeBase">Team base instance</param>
        /// <param name="playerSpawnPt">Team's player's spawn point</param>
        public TeamInformation(Team teamId, bool fullyAIControlled, List<Turret> ownedTurrets,
            int teamStartingCredits, playerObject teamPlayer, List<Node> ownedNodes, List<SpawnPoint> ownedSpawnPoints,
            uint maxFighters, uint maxDestroyers, Base teamHomeBase, PlayerSpawnPoint playerSpawnPt)
        {
            this.teamId = teamId;
            this.fullyAIControlled = fullyAIControlled;
            this.ownedTurrets = ownedTurrets;
            this.teamCredits = teamStartingCredits;
            this.teamPlayer = teamPlayer;
            this.teamOwnedNodes = ownedNodes;
            this.teamSpawnPoints = ownedSpawnPoints;
            this.maxDestroyers = maxDestroyers;
            this.maxFighters = maxFighters;
            this.teamFighters = new List<Fighter>((int)maxFighters);
            this.teamDestroyers = new List<Destroyer>((int)maxDestroyers);
            this.teamBase = teamHomeBase;

            scrambleQueue = new PowerDataStructures.PriorityQueue<int, StaticObject>(true);
            fighterBattleList = new Dictionary<Fighter, StaticObject>();
            destroyerBattleList = new Dictionary<Destroyer, StaticObject>();
            turretBattleList = new Dictionary<Turret, StaticObject>();
            gunsCoolDown = new Dictionary<StaticObject, int>();
            spawnQueue = new List<DynamicObject>(ownedSpawnPoints.Count);
            playerTarget = null;
            playerObjective = null;
        }
Exemplo n.º 2
0
        protected void loadMap2(string mapName)
        {
            // clear all lists
            pathNodes.Clear();
            DynamicObjs.Clear();
            AllObjects.Clear();
            DynamicObjs.Clear();
            Fighters.Clear();
            Destroyers.Clear();
            Towers.Clear();
            Asteroids.Clear();
            Projectiles.Clear();
            spawnPoints.Clear();

            gameGrid = new BBN_Game.Grid.GridStructure(200, 4000);

            SkyBox = new BBN_Game.Graphics.Skybox.Skybox(game, "Skybox/Starfield", 2000, 1);

            Player1 = new BBN_Game.Objects.playerObject(game, BBN_Game.Objects.Team.Red, new Vector3(0,0,-10), Vector3.Zero, false);
            Player2 = new BBN_Game.Objects.playerObject(game, BBN_Game.Objects.Team.Blue, new Vector3(0, 0, +10), Vector3.Zero, false);
            addObject(Player1);
            addObject(Player2);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the system to use new instances of player objects
 /// </summary>
 /// <param name="playerIndex">Either Red or Blue</param>
 public static Objects.playerObject spawnPlayer(Objects.Team playerIndex, Game game)
 {
     switch (playerIndex)
     {
         case Objects.Team.Red:
             addObject(Player1 = new BBN_Game.Objects.playerObject(game, Objects.Team.Red, Team1SpawnPoint.Position, new Vector3(0, 0, -1), numPlayers.Equals(Players.single) ? false : true));
             return Player1;
         case Objects.Team.Blue:
             addObject(Player2 = new BBN_Game.Objects.playerObject(game, Objects.Team.Blue, Team2SpawnPoint.Position, new Vector3(0, 0, 1), numPlayers.Equals(Players.single) ? false : true));
             if (numPlayers.Equals(Players.single))
             {
                 Player2.setYawSpeed = Player2.getYawSpeed * YAW_PITCH_ROLL_SPEED_FACTOR_FOR_AI_PLAYER;
                 Player2.setpitchSpeed = Player2.getpitchSpeed * YAW_PITCH_ROLL_SPEED_FACTOR_FOR_AI_PLAYER;
                 Player2.setRollSpeed = Player2.getRollSpeed * YAW_PITCH_ROLL_SPEED_FACTOR_FOR_AI_PLAYER;
             }
             return Player2;
         default:
             throw new Exception("System only supports index 1 or 2");
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Sets up the viewport of the object
        /// </summary>
        /// <param name="cam">The camera MAtrices</param>
        /// <param name="screenViewport">The Screen viewport dimensions</param>
        /// <param name="player">The player for the current viewport</param>
        /// <returns></returns>
        private Boolean setVertexCoords(SpriteBatch b, Camera.CameraMatrices cam, Vector2 screenViewport, playerObject player)
        {
            Color col;
            if (this is Objects.Turret)
                col = ((Objects.Turret)this).Repairing ? Color.Aqua : this.Equals(player.Target) ? Color.Red : this.team.Equals(Team.neutral) ? Color.Yellow :
                        this.Team.Equals(player.team) ? Color.Green : Color.Orange;
            else
                col = this.Equals(player.Target) ? Color.Red : this.team.Equals(Team.neutral) ? Color.Yellow :
                        this.Team.Equals(player.team) ? Color.Green : Color.Orange;

            float radiusOfObject;
            radiusOfObject = greatestLength * 5f; // sets the greatest size of the object

            float distance = (Position - cam.Position).Length(); // distance the object is from the camera
            float radius = (greatestLength / 2); // a variable for checking distances away from camera
            //Check if the objectis further away from the camera than its actual size.
            if (distance > radius)
            {
                float angularSize = (float)Math.Tan(radius / distance); // calculate the size differance due to distance away
                radiusOfObject = angularSize * GraphicsDevice.Viewport.Height / MathHelper.ToRadians(cam.viewAngle); // change the size of the object in accordance to the viewing angle
            }

            // The view and projection matrices together
            Matrix viewProj = cam.View * cam.Projection;
            Vector4 screenPos = Vector4.Transform(Position, viewProj); // the position the screen is at according to the matrices

            float halfScreenY = screenViewport.Y / 2.0f; // half the size of the screen
            float halfScreenX = screenViewport.X / 2.0f; // half the size of the screen

            float screenY = ((screenPos.Y / screenPos.W) * halfScreenY) + halfScreenY; // the position of the object in 2d space y
            float screenX = ((screenPos.X / screenPos.W) * halfScreenX) + halfScreenX; // the position of the object in 2d space x

            // set positions for lines to draw
            setVertexPosition(screenX, screenY, radiusOfObject, col);

            // set the y back to the non depth version
            screenY = halfScreenY - ((screenPos.Y / screenPos.W) * halfScreenY);
            float distanceToPlayer = (cam.Position - Position).Length();

            drawData(b, distanceToPlayer, screenX, screenY, radiusOfObject, col, player); // draw the distances to the object

            // set the variable to the new position vectors
            targetBoxVB.SetData<VertexPositionColor>(targetBoxVertices);
            return true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draws the Target vox for the player
        /// </summary>
        /// <param name="cam">Camera MAtrices class</param>
        /// <param name="currentPlayerforViewport">The current player for the viewport</param>
        public void drawSuroundingBox(SpriteBatch b, Camera.CameraMatrices cam, playerObject currentPlayerforViewport)
        {
            //if its the current player dont draw it
            if (this is playerObject)
                if (((playerObject)this).getViewport.Equals(Game.GraphicsDevice.Viewport))
                    return;

            if (this is Objects.Bullet || this is Objects.Planets.Planet || this is Objects.Asteroid) // dont draw for bullets
                return;

            if ((cam.Position - Position).Length() > 800) // depth culling
                return;

            if (IsVisible(cam))
            {
                Vector2 screenViewport = new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

                if (setVertexCoords(b, cam, screenViewport, currentPlayerforViewport))
                    drawBox(screenViewport);
            }
        }