Ejemplo n.º 1
0
        /// <summary>
        /// Update an overheat bar to its current overheat value
        /// </summary>
        /// <param name="player"></param>
        private void UpdateOverheatBar(PlayerTank player)
        {
            if (player.Weapon.OverheatAmount > player.Weapon.OverheatTime)
            {
                player.Weapon.IsOverheating = true;
            }

            if (player.Weapon.IsOverheating)
            {
                if (player.Weapon.OverheatAmount <= 0)
                {
                    player.Weapon.IsOverheating = false;
                }
            }

            if (player.Weapon.OverheatAmount > 0 && player.TimeSinceFiring > player.Weapon.OverheatRecoveryStartTime)
            {
                player.Weapon.OverheatAmount -= (float)((player.Weapon.OverheatTime / player.Weapon.OverheatRecoverySpeed) *
                                                        ServiceManager.Game.DeltaTime);
            }

            this.Bars[1].Value = (int)MathHelper.Clamp((player.Weapon.OverheatAmount / player.Weapon.OverheatTime) * 100,
                                                       0f,
                                                       100f);
        }
Ejemplo n.º 2
0
 private void Start()
 {
     _playerTank                   = FindObjectOfType <PlayerTank>();
     _healthText                   = GetComponent <Text>();
     _healthText.text              = _playerTank.Health.ToString();
     _playerTank.OnDamageRecieved += UpdateHealth;
 }
Ejemplo n.º 3
0
        public override void DoAction()
        {
            PlayerTank tank = Game.Players[id];

            tank.Angle             = (float)angle;
            tank.DirectionRotation = direction;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initialize any components required by this state.
        /// </summary>
        public override void Initialize()
        {
            ServiceManager.Game.FormManager.ClearWindow();
            Options options = ServiceManager.Game.Options;

            RendererAssetPool.DrawShadows = GraphicOptions.ShadowMaps;
            mouseCursor = new MouseCursor(options.KeySettings.Pointer);
            mouseCursor.EnableCustomCursor();
            renderer    = ServiceManager.Game.Renderer;
            fps         = new FrameCounter();
            Chat        = new ChatArea();
            Projectiles = new ProjectileManager();
            Tiles       = new TexturedTileGroupManager();
            Utilities   = new UtilityManager();
            cd          = new Countdown();
            Lazers      = new LazerBeamManager(this);
            Scene.Add(Lazers, 0);
            Players            = new PlayerManager();
            currentGameMode    = ServiceManager.Theater.GetCurrentGameMode();
            Flags              = new FlagManager();
            Bases              = new BaseManager();
            EnvironmentEffects = new EnvironmentEffectManager();
            buffbar            = new BuffBar();
            Scores             = new ScoreBoard(currentGameMode, Players);
            input              = new ChatInput(new Vector2(5, ServiceManager.Game.GraphicsDevice.Viewport.Height), 300);//300 is a magic number...Create a chat width variable.
            input.Visible      = false;
            hud              = HUD.GetHudForPlayer(Players.GetLocalPlayer());
            localPlayer      = Players.GetLocalPlayer();
            Scene.MainEntity = localPlayer;
            sky              = ServiceManager.Resources.GetTexture2D("textures\\misc\\background\\sky");
            tips             = new GameTips(new GameContext(CurrentGameMode, localPlayer));
            helpOverlay      = new HelpOverlay();
        }
Ejemplo n.º 5
0
        public override void DoAction()
        {
            PlayerTank          owner   = null;
            EnvironmentProperty envprop = Game.EnvironmentEffects.GetEffect(environmentEffectId);

            if (envprop != null)
            {
                owner = envprop.Owner;
            }

            if (this.isDestroyed)
            {
                if (owner != null)
                {
                    string message = owner.Name + " destroyed the " +
                                     Game.Bases.GetBase(baseId).BaseColor.ToString().ToLower() + " base!";
                    Game.Chat.AddMessage(message, Color.Chartreuse);
                }

                Game.Bases.DestroyBase(baseId);
            }
            else
            {
                Game.Bases.DamageBase(baseId, damage);
            }
        }
Ejemplo n.º 6
0
        public override void DoAction()
        {
            PlayerTank tank = Game.Players[id];

            tank.SetPosition(point);
            tank.DirectionMovement   = direction;
            tank.PreviouslyCollidied = false;
        }
Ejemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        player     = GameObject.FindGameObjectWithTag("Player");
        playertank = player.GetComponent <PlayerTank>();

        placeTime = Time.time;
        // explosion = GetComponent<ParticleSystem>();
        // explosion.playOnAwake = false;
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Detects if tank is intersecting a impassible tile
        /// </summary>
        /// <param name="tankObject">Clients Tank</param>
        /// <returns>Collision</returns>
        private bool DetectCollision(PlayerTank tankObject)
        {
            // The 3 below this comment is an offset to make sure we only check for collisions with tiles
            // adjacent to us.  Checks are done to a range of 3 tiles.
            int numTilesX = (viewportRect.X / Constants.TILE_SIZE) + 3;
            int numTilesY = (viewportRect.Y / Constants.TILE_SIZE) + 3;

            int minimumX = (int)(tankObject.Position.X / Constants.TILE_SIZE) - numTilesX;
            int minimumY = (int)(-tankObject.Position.Y / Constants.TILE_SIZE) - numTilesY;
            int maximumX = (int)(tankObject.Position.X / Constants.TILE_SIZE) + numTilesX;
            int maximumY = (int)(-tankObject.Position.Y / Constants.TILE_SIZE) + numTilesY;

            for (int y = minimumY; y < map.Height && y <= maximumY; y++)
            {
                if (y < 0)
                {
                    continue;
                }

                for (int x = minimumX; x < map.Width && x <= maximumX; x++)
                {
                    if (x < 0)
                    {
                        continue;
                    }

                    Options.KeyBindings keys = ServiceManager.Game.Options.KeySettings;

                    DrawableTile tile = visibleTiles[y * map.Width + x];
                    if (tankObject.Name == PlayerManager.LocalPlayerName)
                    {
                        if (!tile.Passable && (
                                (Keyboard.GetState().IsKeyDown(keys.Forward) &&
                                 tankObject.FrontSphere.Intersects(tile.BoundingBox)) ||
                                (Keyboard.GetState().IsKeyDown(keys.Backward) &&
                                 tankObject.BackSphere.Intersects(tile.BoundingBox))))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (!tile.Passable &&
                            ((tankObject.FrontSphere.Intersects(tile.BoundingBox) &&
                              tankObject.DirectionMovement == VTankObject.Direction.FORWARD) ||
                             (tankObject.BackSphere.Intersects(tile.BoundingBox) &&
                              tankObject.DirectionMovement == VTankObject.Direction.REVERSE)))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        player     = GameObject.FindGameObjectWithTag("Player");
        playertank = player.GetComponent <PlayerTank>();


        Projectile.constraints = RigidbodyConstraints.FreezeAll;

        placeTime = Time.time;
    }
Ejemplo n.º 10
0
 public void RemovePlayer()
 {
     // Makes sure you can't remove if there is only 1 player
     if (Gamemode.Instance.Players.Count != 1)
     {
         PlayerOptions.SetActive(false);
         Gamemode.Instance.RemovePlayer(playerTank);
         this.playerTank = null;
     }
 }
Ejemplo n.º 11
0
 public Minimap(PlayerManager playerList, PlayerTank _localPlayer)
     : base()
 {
     IsDisposed       = false;
     Enabled          = true;
     players          = playerList;
     localPlayer      = _localPlayer;
     mapObjectTexture = ServiceManager.Resources.GetTexture2D("textures\\misc\\MiniMap\\PlayerIndicator");
     area             = new Rectangle(ServiceManager.Game.Width - miniMapWidth - 15, 15, miniMapWidth, miniMapHeight);
 }
Ejemplo n.º 12
0
        public override void DoAction()
        {
            PlayerTank newTank = PlayerManager.CreateTankObject(tank);

            newTank.SetPosition(tank.position);
            Game.Players[newTank.ID] = newTank;
            Game.NeedsSync           = true;
            Game.Scores.AddPlayer(tank.attributes.name, tank.team);
            Game.Chat.AddMessage(tank.attributes.name + " has joined the game.", Color.Yellow);
        }
Ejemplo n.º 13
0
 public Minimap(PlayerManager playerList, PlayerTank _localPlayer)
     : base()
 {
     IsDisposed = false;
     Enabled = true;
     players = playerList;
     localPlayer = _localPlayer;
     mapObjectTexture = ServiceManager.Resources.GetTexture2D("textures\\misc\\MiniMap\\PlayerIndicator");
     area = new Rectangle(ServiceManager.Game.Width - miniMapWidth - 15, 15, miniMapWidth, miniMapHeight);
 }
Ejemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        // Add initial force.
        rigidbody.AddForce (0, 800, 0);

        // This connects the missile to the normal ship when fired.
        playerTank = GameObject.Find ("Player Tank").GetComponent < PlayerTank > ();

        soundManager = Camera.main.GetComponent<Sounds>();
    }
Ejemplo n.º 15
0
        public override void DoAction()
        {
            PlayerTank player = Game.Players.GetLocalPlayer();

            Console.Error.WriteLine();
            Console.Error.WriteLine("Tank's position has been reset.");
            Console.Error.WriteLine("Old position: ({0}, {1})", player.Position.X, player.Position.Y);
            Console.Error.WriteLine("New position: ({0}, {1})", position.x, position.y);
            Console.Error.WriteLine();

            player.SetPosition(position);
        }
Ejemplo n.º 16
0
        public void Return_False_IfDirection_IsNotDown()
        {
            //arrange
            var direction     = Direction.Up;
            var collisionStub = new Mock <ICollision>();
            var playerTank    = new PlayerTank(3, 3, direction, mapMock.Object, enviromentFactoryStub.Object, collisionStub.Object);

            //act
            var result = playerTank.MoveDown();

            //assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Ensures all references are released.
        /// </summary>
        public void Dispose()
        {
            players          = null;
            flags            = null;
            bases            = null;
            utilities        = null;
            localPlayer      = null;
            renderTarget     = null;
            texture          = null;
            mapObjectTexture = null;

            IsDisposed = true;
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Update a cooldown bar to its current status
 /// </summary>
 /// <param name="player">The player</param>
 private void UpdateCooldownBar(PlayerTank player)
 {
     if (player.GetRateOfFire() > 0)
     {
         this.Bars[1].Value = (int)MathHelper.Clamp((1f - (player.Remaining /
                                                           (player.Weapon.Cooldown * (player.Weapon.Cooldown * player.GetRateOfFire())))) * 100f, 0f, 100f);
     }
     else
     {
         this.Bars[1].Value = (int)MathHelper.Clamp((1f - (player.Remaining /
                                                           player.Weapon.Cooldown)) * 100f, 0f, 100f);
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Update the secondary bar of the player.  Checks what type of bar we're
 /// dealing with and uses the appropriate method.
 /// </summary>
 /// <param name="player">The player</param>
 public void UpdateSecondaryBar(PlayerTank player)
 {
     if (this.HasChargeBar)
     {
         this.UpdateChargeBar(player);
     }
     else if (this.HasOverHeatBar)
     {
         this.UpdateOverheatBar(player);
     }
     else
     {
         this.UpdateCooldownBar(player);
     }
 }
Ejemplo n.º 20
0
        public void Return_False_IfCollision_IsDetected()
        {
            //arrange
            var row           = 3;
            var col           = 3;
            var direction     = Direction.Right;
            var collisionMock = new Mock <ICollision>();
            var playerTank    = new PlayerTank(row, col, direction, mapMock.Object, enviromentFactoryStub.Object, collisionMock.Object);

            collisionMock.Setup(c => c.DetectCollision(mapMock.Object, row, col + 1)).Returns(true);

            //act
            var result = playerTank.MoveRight();

            //assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 21
0
        public void Return_True_IfCollision_IsNotDetected()
        {
            //arrange
            var row           = 3;
            var col           = 3;
            var direction     = Direction.Down;
            var collisionMock = new Mock <ICollision>();
            var playerTank    = new PlayerTank(row, col, direction, mapMock.Object, enviromentFactoryStub.Object, collisionMock.Object);

            collisionMock.Setup(c => c.DetectCollision(mapMock.Object, row + 1, col)).Returns(false);

            //act
            var result = playerTank.MoveDown();

            //assert
            Assert.IsTrue(result);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Update a charge bar to the current charge status
        /// </summary>
        /// <param name="player"></param>
        private void UpdateChargeBar(PlayerTank player)
        {
            if (player.IsCharging)
            {
                float rateOfFire = player.GetRateOfFire();
                float chargeAmount;
                long  delta = Clock.GetTimeMilliseconds() - player.TimeChargingBegan;
                long  timeCharging;
                if (rateOfFire > 0f)
                {
                    timeCharging = delta + (long)(delta * rateOfFire);
                }
                else
                {
                    timeCharging = delta;
                }

                if (Clock.GetTimeMilliseconds() - player.TimeChargingBegan >= player.Weapon.MaxChargeTime * 1000)
                {
                    chargeAmount = 100f;
                }
                else
                {
                    if (timeCharging == 0)
                    {
                        this.Bars[1].StartPulsing(255, 255, 255);
                        this.Bars[1].PulseIncrement = 15;
                        timeCharging = 1;
                    }

                    chargeAmount = (timeCharging / (player.Weapon.MaxChargeTime * 1000)) * 100f;
                }

                this.Bars[1].Value = (int)MathHelper.Clamp(chargeAmount, 0f, 100f);
            }
            else
            {
                this.Bars[1].Value = (int)MathHelper.Clamp(0f, 0f, 100f);
                if (this.Bars[1].IsPulsing)
                {
                    this.Bars[1].StopPulsing();
                    this.Bars[1].PulseIncrement = 7;
                }
            }
        }
Ejemplo n.º 23
0
        public GameScene(Game _game) : base(_game)
        {
            //Set Player Pos
            player          = new PlayerTank(this);
            player.Position = new Vector2(Program.GameWidth / 4, Program.GameHeight / 2);

            //Create Boss
            spindleBoss = new Spindle(this);

            //Setup Tile Grid
            int w = (int)Math.Ceiling((double)(Program.GameWidth / 16));
            int h = (int)Math.Ceiling((double)(Program.GameHeight / 16)) + 1;

            int[,] tempGrid = new int[w, h];

            for (int xx = 0; xx < tempGrid.GetLength(0); xx++)
            {
                for (int yy = 0; yy < tempGrid.GetLength(1); yy++)
                {
                    tempGrid[xx, yy] = 0;
                    //HoriWalls
                    if (xx == 0 || xx == tempGrid.GetLength(0) - 1)
                    {
                        tempGrid[xx, yy] = 1;
                    }

                    //VertWalls
                    if (yy == 0 || yy == tempGrid.GetLength(1) - 1)
                    {
                        tempGrid[xx, yy] = 1;
                    }
                }
            }

            tileGrid = new TileGrid(tempGrid, 16, 16);

            //Create Dialouge Box, but don't show it
            dialougeBox         = new DialougeBox();
            dialougeBox.Visible = false;
        }
Ejemplo n.º 24
0
        public void Return_Correct_Value_When_Direction_IsLeft()
        {
            //arrange
            var row       = 2;
            var col       = 3;
            var direction = Direction.Left;

            var envFactoryStub = new Mock <IEnvironmentFactory>();
            var collisionStub  = new Mock <ICollision>();

            var expectedShell = new Mock <IShell>();

            envFactoryStub.Setup(f => f.CreateShell(row, col - 1, mapMock.Object, direction, envFactoryStub.Object, collisionStub.Object)).Returns(expectedShell.Object);

            var playerTank = new PlayerTank(row, col, direction, mapMock.Object, envFactoryStub.Object, collisionStub.Object);

            //act
            var actualShell = playerTank.Shoot();

            //assert
            Assert.AreSame(expectedShell.Object, actualShell);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Returns a default HUD for the VTank Client. Two scaled bars: one left, one right.
        /// Detects whether the player is using a weapon that requires a charge bar or a
        /// overheat bar instead of the default cooldown bar.
        /// </summary>
        public static HUD GetHudForPlayer(PlayerTank player)
        {
            HUD _hud = new HUD(2);

            _hud.Bars[0].BarColor = new Color(0.1f, 1.0f, 0.2f); //Green Health Bar
            _hud.Bars[0].Opacity  = 0.1f;
            _hud.Bars[1].Opacity  = 0.1f;

            _hud.Bars[0].Scale = .5f;
            _hud.Bars[1].Scale = .5f;

            _hud.Bars[0].Origin = new Vector2(0, 0);

            _hud.Bars[0].TextEnabled = false;
            _hud.Bars[1].TextEnabled = false;

            _hud.Bars[1].Orientation = HUD_Bar.HUDOrientation.RIGHT;
            _hud.HasChargeBar        = false;
            _hud.HasOverHeatBar      = false;

            if (player.Weapon.CanCharge)
            {
                _hud.Bars[1].BarColor = new Color(0.0f, 0.0f, 1.0f); //Blue cooldown bar
                _hud.HasChargeBar     = true;
            }
            else if (player.Weapon.UsesOverHeat)
            {
                _hud.Bars[1].BarColor = new Color(1.0f, 0.0f, 0.0f); //Red cooldown bar
                _hud.HasOverHeatBar   = true;
            }
            else
            {
                _hud.Bars[1].BarColor = new Color(1.0f, 1.0f, 0.0f); //Yellow cooldown bar
                _hud.Bars[1].Opacity  = 0.1f;
            }

            return(_hud);
        }
Ejemplo n.º 26
0
    private void Update()
    {
        var tank = Physics2D.OverlapBox(transform.position, collisionSize, 0, tankMask);

        if (!tank)
        {
            return;
        }

        PlayerTank playerTank = tank.GetComponent <PlayerTank>();
        EnemyTank  enemyTank  = tank.GetComponent <EnemyTank>();

        HandleAnyTankPickup(playerTank, enemyTank);
        if (Type == PickUpType.Tank)
        {
            AudioManager.s_Instance.PlayFxClip(AudioManager.AudioClipType.LiveTaken);
        }
        else
        {
            AudioManager.s_Instance.PlayFxClip(AudioManager.AudioClipType.BonusTaken);
        }
        Destroy(gameObject);
    }
Ejemplo n.º 27
0
    public virtual void OnTriggerEnter2D(Collider2D coll)
    {
        EnamyTank  _enemy  = coll.transform.GetComponent <EnamyTank>();
        PlayerTank _player = coll.transform.GetComponent <PlayerTank>();

        if (coll.transform.CompareTag("Wall"))
        {
            Destroy(BulletObj);
        }
        if (coll.transform.CompareTag("Enemy"))
        {
            if (_isEnemy == 1)
            {
                _enemy.HpTank -= Damage;
            }
            Destroy(BulletObj);
        }
        if (coll.transform.CompareTag("Player"))
        {
            _player.HpTank -= Damage;
            Destroy(BulletObj);
        }
    }
Ejemplo n.º 28
0
        /// <summary>
        /// Returns a default HUD for the VTank Client. Two scaled bars: one left, one right.
        /// Detects whether the player is using a weapon that requires a charge bar or a
        /// overheat bar instead of the default cooldown bar.
        /// </summary>
        public static HUD GetHudForPlayer(PlayerTank player)
        {
            HUD _hud = new HUD(2);
            _hud.Bars[0].BarColor = new Color(0.1f, 1.0f, 0.2f); //Green Health Bar
            _hud.Bars[0].Opacity = 0.1f;
            _hud.Bars[1].Opacity = 0.1f;

            _hud.Bars[0].Scale = .5f;
            _hud.Bars[1].Scale = .5f;

            _hud.Bars[0].Origin = new Vector2(0, 0);

            _hud.Bars[0].TextEnabled = false;
            _hud.Bars[1].TextEnabled = false;

            _hud.Bars[1].Orientation = HUD_Bar.HUDOrientation.RIGHT;
            _hud.HasChargeBar = false;
            _hud.HasOverHeatBar = false;

            if (player.Weapon.CanCharge)
            {
                _hud.Bars[1].BarColor = new Color(0.0f, 0.0f, 1.0f); //Blue cooldown bar
                _hud.HasChargeBar = true;
            }
            else if (player.Weapon.UsesOverHeat)
            {
                _hud.Bars[1].BarColor = new Color(1.0f, 0.0f, 0.0f); //Red cooldown bar
                _hud.HasOverHeatBar = true;
            }
            else
            {
                _hud.Bars[1].BarColor = new Color(1.0f, 1.0f, 0.0f); //Yellow cooldown bar
                _hud.Bars[1].Opacity = 0.1f;
            }

            return _hud;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Updates the HUD based on the values of the player
 /// </summary>
 /// <param name="player"></param>
 private void UpdateHUDValues(PlayerTank player)
 {
     hud.UpdateHealth(player);
     hud.UpdateSecondaryBar(player);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Update the health on the player's health bar
 /// </summary>
 /// <param name="player">The player</param>
 public void UpdateHealth(PlayerTank player)
 {
     this.Bars[0].Value = (int)MathHelper.Clamp((player.Health * 100 / Constants.MAX_PLAYER_HEALTH), 0f, 100f);
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Update the secondary bar of the player.  Checks what type of bar we're
 /// dealing with and uses the appropriate method.
 /// </summary>
 /// <param name="player">The player</param>
 public void UpdateSecondaryBar(PlayerTank player)
 {
     if (this.HasChargeBar)
     {
         this.UpdateChargeBar(player);
     }
     else if (this.HasOverHeatBar)
     {
         this.UpdateOverheatBar(player);
     }
     else
     {
         this.UpdateCooldownBar(player);
     }
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Update a charge bar to the current charge status
        /// </summary>
        /// <param name="player"></param>
        private void UpdateChargeBar(PlayerTank player)
        {
            if (player.IsCharging)
            {
                float rateOfFire = player.GetRateOfFire();
                float chargeAmount;
                long delta = Clock.GetTimeMilliseconds() - player.TimeChargingBegan;
                long timeCharging;
                if (rateOfFire > 0f)
                {
                    timeCharging = delta + (long)(delta * rateOfFire);
                }
                else
                {
                    timeCharging = delta;
                }

                if (Clock.GetTimeMilliseconds() - player.TimeChargingBegan >= player.Weapon.MaxChargeTime * 1000)
                    chargeAmount = 100f;
                else
                {
                    if (timeCharging == 0)
                    {
                        this.Bars[1].StartPulsing(255, 255, 255);
                        this.Bars[1].PulseIncrement = 15;
                        timeCharging = 1;
                    }

                    chargeAmount = (timeCharging / (player.Weapon.MaxChargeTime * 1000)) * 100f;
                }

                this.Bars[1].Value = (int)MathHelper.Clamp(chargeAmount, 0f, 100f);
            }
            else
            {
                this.Bars[1].Value = (int)MathHelper.Clamp(0f, 0f, 100f);
                if (this.Bars[1].IsPulsing)
                {
                    this.Bars[1].StopPulsing();
                    this.Bars[1].PulseIncrement = 7;
                }
            }
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Update a cooldown bar to its current status
 /// </summary>
 /// <param name="player">The player</param>
 private void UpdateCooldownBar(PlayerTank player)
 {
     if (player.GetRateOfFire() > 0)
         this.Bars[1].Value = (int)MathHelper.Clamp((1f - (player.Remaining /
             (player.Weapon.Cooldown * (player.Weapon.Cooldown * player.GetRateOfFire())))) * 100f, 0f, 100f);
     else
         this.Bars[1].Value = (int)MathHelper.Clamp((1f - (player.Remaining /
             player.Weapon.Cooldown)) * 100f, 0f, 100f);
 }
Ejemplo n.º 34
0
        void LoadObjects()
        {
            tankModel = LoadedResources.ModelList[level_load_list["PlayerTankModel"]].Model_rez;
            tankTextures = LoadedResources.ModelList[level_load_list["PlayerTankModel"]].Textures_rez;
            missileModel = LoadedResources.ModelList[level_load_list["PlayerRocketModel"]].Model_rez;
            missileTextures = LoadedResources.ModelList[level_load_list["PlayerRocketModel"]].Textures_rez;
            cornerModel = LoadedResources.ModelList["Model\\sphere"].Model_rez;

            playerTank = new PlayerTank(this, tankModel, tankTextures, myLevel.playerSpawn.Position);
            playerTank.Load();
            playerTank.scale = PLAYER_SCALE;
            playerTank.alive = true;

            //playerTank.position = TANK_POSITION;
            playerTank.position = myLevel.playerSpawn.Position;

            playerTank2 = new PlayerTank(this, tankModel, tankTextures, myLevel.playerSpawn.Position);
            playerTank2.Load();
            playerTank2.scale = PLAYER_SCALE;
            playerTank2.alive = true;

            playerTank2.position = TANK_POSITION;
            playerTank2.position = new Vector3 (playerTank2.position.X - 20, playerTank2.position.Y,
                playerTank2.position.Z);

            playerTanks = new PlayerTank[numTanks];

            for (int i = 0; i < numTanks; ++i)
            {
                playerTanks[i] = new PlayerTank(this, tankModel, tankTextures, myLevel.playerSpawn.Position);
                playerTanks[i].Load();
                playerTanks[i].scale = PLAYER_SCALE;
                playerTanks[i].alive = true;

                playerTanks[i].position = TANK_POSITION;
                playerTanks[i].position = new Vector3(
                    playerTank2.position.X + 20 * (1 + i),
                    playerTank2.position.Y,
                    playerTank2.position.Z); ;
            }

            enemyTanks = new List<EnemyTank>();
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Initialize the scoreboard.
        /// </summary>
        public void InitScoreBoard()
        {
            if (ServiceManager.Theater == null)
            {
                return;
            }

            Statistics[] stats = ServiceManager.Theater.GetScoreboard();
            GameSession.ScoreboardTotals totals = new GameSession.ScoreboardTotals();

            if (mode == GameMode.CAPTURETHEFLAG)
            {
                totals = ServiceManager.Theater.GetTeamStats();
            }

            if (team1 != null)
            {
                team1.Clear();
            }
            if (team2 != null)
            {
                team2.Clear();
            }

            foreach (Statistics stat in stats)
            {
                PlayerTank tank = players.GetPlayerByName(stat.tankName);

                if (tank != null)
                {
                    if (tank.Team == GameSession.Alliance.RED && !team1.ContainsKey(stat.tankName))
                    {
                        team1.Add(stat.tankName, new Score(Color.Red, stat));
                        team1stats.kills      += stat.kills;
                        team1stats.assists    += stat.assists;
                        team1stats.deaths     += stat.deaths;
                        team1stats.objectives += stat.objectivesCaptured;
                        team1stats.roundWins  += stat.objectivesCompleted;
                    }
                    else if (tank.Team == GameSession.Alliance.BLUE && !team2.ContainsKey(stat.tankName))
                    {
                        team2.Add(stat.tankName, new Score(customBlue, stat));
                        team2stats.kills      += stat.kills;
                        team2stats.assists    += stat.assists;
                        team2stats.deaths     += stat.deaths;
                        team2stats.objectives += stat.objectivesCaptured;
                        team2stats.roundWins  += stat.objectivesCompleted;
                    }
                    else if (tank.Team == GameSession.Alliance.NONE && !team1.ContainsKey(stat.tankName))
                    {
                        team1.Add(stat.tankName, new Score(neutralTeamColor, stat));
                    }
                }
            }

            if (totals != null)
            {
                team1stats.kills      = totals.killsBlue;
                team1stats.objectives = totals.capturesBlue;
                team2stats.kills      = totals.killsRed;
                team2stats.objectives = totals.capturesRed;
            }
        }
Ejemplo n.º 36
0
 public void RemovePlayer(PlayerTank player)
 {
     Players.Remove(player);
     Destroy(player.gameObject);
     PlayerCountChanged(this, EventArgs.Empty);
 }
Ejemplo n.º 37
0
 public void NewPlayer(PlayerTank player)
 {
     //player.transform.position = PlayerStartLocation.position;
     Players.Add(player);
     PlayerCountChanged?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 38
0
 public TankPhase(PlayerTank tank)
 {
     this.tank = tank;
 }
Ejemplo n.º 39
0
        /// <summary>
        /// Ensures all references are released.
        /// </summary>
        public void Dispose()
        {
            players = null;
            flags = null;
            bases = null;
            utilities = null;
            localPlayer = null;
            renderTarget = null;
            texture = null;
            mapObjectTexture = null;

            IsDisposed = true;
        }
Ejemplo n.º 40
0
 /// <summary>
 /// Constructor for the GameContext
 /// </summary>
 /// <param name="currentMode">The current game mode being played</param>
 /// <param name="currentWeapon">The current weapon being used</param>
 public GameContext(GameMode currentMode, PlayerTank currentPlayer)
 {
     this.currentMode = currentMode;
     this.currentWeapon = currentPlayer.Weapon;
     this.currentPlayer = currentPlayer;
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Update an overheat bar to its current overheat value
        /// </summary>
        /// <param name="player"></param>
        private void UpdateOverheatBar(PlayerTank player)
        {
            if (player.Weapon.OverheatAmount > player.Weapon.OverheatTime)
                player.Weapon.IsOverheating = true;

            if (player.Weapon.IsOverheating)
            {
                if (player.Weapon.OverheatAmount <= 0)
                {
                    player.Weapon.IsOverheating = false;
                }
            }

            if (player.Weapon.OverheatAmount > 0 && player.TimeSinceFiring > player.Weapon.OverheatRecoveryStartTime)
            {
                player.Weapon.OverheatAmount -= (float)((player.Weapon.OverheatTime / player.Weapon.OverheatRecoverySpeed) *
                        ServiceManager.Game.DeltaTime);
            }

            this.Bars[1].Value = (int)MathHelper.Clamp((player.Weapon.OverheatAmount / player.Weapon.OverheatTime) * 100,
                0f,
                100f);
        }