Пример #1
0
        public HUDUnit(Ship _ship, int _width, int _height, int _depth)
        {
            if (!barGraphics.initialized)
            {
                barGraphics.rasterizerState = new RasterizerState();
                barGraphics.rasterizerState.FillMode = FillMode.WireFrame;
                barGraphics.rasterizerState.CullMode = CullMode.None;

                barGraphics.vertexDeclaration = new VertexDeclaration(new VertexElement[]
                    {
                        new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
                        new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0)
                    }
                );

                barGraphics.basicEffect = new BasicEffect(Space394Game.GameInstance.GraphicsDevice);
                barGraphics.basicEffect.VertexColorEnabled = true;

                barGraphics.initialized = true;
            }
            else { }

            ship = _ship;

            width = _width;
            height = _height;
            depth = _depth;

            shieldBarTex = ContentLoadManager.loadTexture("Textures/ShieldBar");
            healthBarTex = ContentLoadManager.loadTexture("Textures/HealthBar");
            barBackgroundTex = ContentLoadManager.loadTexture("Textures/BackBar");
            barMaxWidth = barBackgroundTex.Width;

            enemyMarkerTex = ContentLoadManager.loadTexture("Textures/enemy_marker");
            friendlyMarkerTex = ContentLoadManager.loadTexture("Textures/friendly_marker");
            objectiveMarkerTex = ContentLoadManager.loadTexture("Textures/objective_marker");

            alphaEffect = new AlphaTestEffect(Space394Game.GameInstance.GraphicsDevice);

            alphaEffect.AlphaFunction = CompareFunction.Greater;
            alphaEffect.ReferenceAlpha = 128;

            // Preallocate an array of four vertices.
            vertices = new VertexPositionColorTexture[4];

            double totalScale = 0.075;
            int hudScaleX = ((int)(20 * totalScale));
            int hudScaleY = ((int)(4 * totalScale));
            vertices[0].Position = new Vector3(hudScaleX, hudScaleY, 0);
            vertices[1].Position = new Vector3(-hudScaleX, hudScaleY, 0);
            vertices[2].Position = new Vector3(hudScaleX, -hudScaleY, 0);
            vertices[3].Position = new Vector3(-hudScaleX, -hudScaleY, 0);

            rotation = ship.Rotation * Quaternion.CreateFromYawPitchRoll(0, MathHelper.ToRadians(90f), 0);
            up = Vector3.Transform(Vector3.Up, rotation);

            quad = new TextureQuad(Vector3.Zero, Vector3.Backward, Vector3.Up, 1, 1);
        }
 public static Bomber createNewBomber(Vector3 position, Quaternion rotation, Ship.Team _team, SpawnShip _home)
 {
     Bomber rFighter = null;
     switch (_team)
     {
         case Ship.Team.Esxolus:
             rFighter = new EsxolusBomber(seed += seedIncrement, position, rotation, _home);
             break;
         case Ship.Team.Halk:
             rFighter = new HalkBomber(seed += seedIncrement, position, rotation, _home);
             break;
     }
     return ((Bomber)rFighter);
 }
 public static CapitalShip createNewCapitalShip(Vector3 position, Quaternion rotation, Ship.Team _team)
 {
     CapitalShip rBattleship = null;
     switch (_team)
     {
         case Ship.Team.Esxolus:
             rBattleship = new EsxolusCapitalShip(seed += seedIncrement, position, rotation);
             break;
         case Ship.Team.Halk:
             rBattleship = new HalkCapitalShip(seed += seedIncrement, position, rotation);
             break;
     }
     return ((CapitalShip)Space394Game.GameInstance.CurrentScene.addSceneObject(rBattleship));
 }
Пример #4
0
 public int getInterceptorsRemaining(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusInterceptorsRemaining;
     }
     else
     {
         return halkInterceptorsRemaining;
     }
 }
Пример #5
0
 public List<Fighter> getEnemyFighters(Ship.Team _team)
 {
     if (_team == Ship.Team.Esxolus)
     {
         return halkFighters;
     }
     else
     {
         return esxolusFighters;
     }
 }
Пример #6
0
 public int getBombersRemaining(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusBombersRemaining;
     }
     else
     {
         return halkBombersRemaining;
     }
 }
Пример #7
0
 public int getAssaultFightersRemaining(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusAssaultFightersRemaining;
     }
     else
     {
         return halkAssaultFightersRemaining;
     }
 }
Пример #8
0
 public int spawnPointIncrease(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusSpawnPointsRemaining++;
     }
     else
     {
         return halkSpawnPointsRemaining++;
     }
 }
Пример #9
0
 public Event getTopEvent(Ship.Team team)
 {
     Event rEvent = null;
     switch (team)
     {
         case Ship.Team.Esxolus:
             rEvent = esxolusEvents.Peek();
             break;
         case Ship.Team.Halk:
             rEvent = halkEvents.Peek();
             break;
     }
     return rEvent;
 }
Пример #10
0
 public HUDUnit(Ship _ship)
 {
     ship = _ship;
 }
 public AIPursuitState(AI _ai, Ship _target, int _fleeCounter)
     : this(_ai)
 {
     // recycleState(_target, fleeCounter, ai.getShip().getInterestTime());
 }
        public override void Update(float deltaTime)
        {
            if (aiShip.Health <= 0)
            {
                StateComplete = true;
                nextState = ((AIDyingState)ai.MyDyingState).recycleState();

                if (target != null)
                {
                    target.AttackerCount = -1;
                    target = null;
                    ai.aiShared.target = null;
                }
            }
            else
            {
                if (target != null)
                {

                    retreatTimer -= deltaTime;
                    if (retreatTimer <= 0)
                    {
                        StateComplete = true;
                        if (ai.aiShared.fleeCounter <= 3)
                        {
                            ai.aiShared.fleeCounter++;
                            if (target is Fighter)
                            {
                                nextState = ((AIPursuitState)ai.MyPursuitState).recycleState();

                            }
                            else // else BattleShip
                            {
                                // interestTimeCopy was taken in as a copy of the ships current time left
                                nextState = ((AIEngageBattleshipState)ai.MyEngageBattleshipState).recycleState();
                            }
                        }
                        // Give up on target
                        else
                        {
                            target.AttackerCount = -1;
                            nextState = ((AIWanderState)ai.MyWanderState).recycleState();
                            if (target is CapitalShip)
                            {
                                ((AIWanderState)ai.MyWanderState).EngageStateHalt = true;
                            }
                        }
                        retreatTimer = RETREAT_TIME;
                    }
                    else
                    {
                        fireTimer -= deltaTime;
                        specialTimer -= deltaTime;

                        if (specialTimer <= 0) //  && targetDistSq < secondaryRange)
                        {
                            aiShip.fireSecondary();
                            specialTimer = specialRate;
                        }
                        else if (fireTimer <= 0) // && targetDistSq < primaryRange)
                        {
                            aiShip.firePrimary();
                            fireTimer = fireRate;
                        }
                        else { }

                        aiShip.Rotation = aiShip.AdjustRotation(Vector3.Forward, newForward, Vector3.Up, deltaTime);
                        aiShip.updateVelocity();

                        float degree = (float)random.NextDouble() * DEGREE_MOD;

                        switch (random.Next() % 3)
                        {
                            case 0:
                                ai.Ship.yawShip(degree, deltaTime);
                                break;
                            case 1:
                                ai.Ship.pitchShip(degree, deltaTime);
                                break;
                            case 2:
                                ai.Ship.rollShip(degree, deltaTime);
                                break;
                        }
                    }
                }
            }
        }
        public AIState recycleState(float _timerMod = 2.5f)
        {
            if (ai.CurrentState.CurrentState != state.Retreat)
            {
                target = ai.aiShared.target;
                StateComplete = false;
                nextState = null;
                AI.AI_Overmind.inRetreat++;

                if (aiShip.CollisionBase != null)
                {
                    aiShip.CollisionBase.Active = true;
                }
                else { }

                RETREAT_TIME = _timerMod + (float)random.NextDouble();
                retreatTimer = RETREAT_TIME;

                fireRate = aiShip.FireRate + 1.5f * (1 + (float)random.NextDouble());
                fireTimer = fireRate;

                specialRate = aiShip.SpecialRate + 13.5f * (1 + (float)random.NextDouble());
                specialTimer = specialRate;
            }
            else { }

            // the new forward vector, so the avatar faces the target
            newForward = Vector3.Normalize(aiShip.Position - offsetDirection());

            return this;
        }
 public static EsxolusIMissile createNewEsxolusIMissile(Vector3 position, Quaternion rotation, Ship parent)
 {
     return ((EsxolusIMissile)ProjectileManager.spawnEsxolusIMissile(seed += seedIncrement, position, rotation, parent));
 }
Пример #15
0
 public int getSpawnPointsRemaining(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusSpawnPointsRemaining;
     }
     else
     {
         return halkSpawnPointsRemaining;
     }
 }
Пример #16
0
 public SpawnShip getSpawnShip(Ship.Team team, int index)
 {
     int i = 0;
     SpawnShip rShip = null;
     while (rShip == null || index != 0)
     {
         if (spawnShips[i].ShipTeam == team)
         {
             rShip = spawnShips[i];
             index--;
         }
         else { }
         i++;
         if (i == spawnShips.Count)
         {
             break;
         }
         else { }
     }
     return rShip;
 }
Пример #17
0
 public int assaultFightersIncrease(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusAssaultFightersRemaining++;
     }
     else
     {
         return halkAssaultFightersRemaining++;
     }
 }
Пример #18
0
 public int interceptorsIncrease(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusInterceptorsRemaining++;
     }
     else
     {
         return halkInterceptorsRemaining++;
     }
 }
Пример #19
0
 public int bombersIncrease(Ship.Team team)
 {
     if (team == Ship.Team.Esxolus)
     {
         return esxolusBombersRemaining++;
     }
     else
     {
         return halkBombersRemaining++;
     }
 }
Пример #20
0
 public void sharedRefresh(Ship _target, float _timer)
 {
     aiShared.target = _target;
     aiShared.fleeCounter = 0;
     aiShared.interestTimer = _timer;
 }
 public static Laser createNewLaser(Vector3 position, Quaternion rotation, Ship parent)
 {
     return ((Laser)ProjectileManager.spawnLaser(seed += seedIncrement, position, rotation, parent));
 }