Beispiel #1
0
        public bool DoTankControls(float pSeconds)
        {
            bool tankMoved = false;

            if (Tank.Health() > 0)
            {
                if (Controller.IsPressedWithCharge(Control.LEFT_TRACK_FORWARDS))
                {
                    tankMoved = true;
                    if (Controller.IsPressedWithCharge(Control.RIGHT_TRACK_FORWARDS))
                    {
                        Tank.BothTracksForward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.LEFT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else if (Controller.IsPressedWithCharge(Control.RIGHT_TRACK_BACKWARDS))
                    {
                        Tank.LeftTrackForward();
                        Tank.RightTrackBackward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.LEFT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else
                    {
                        Tank.LeftTrackForward();
                        Controller.DepleteCharge(Control.LEFT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                }
                else if (Controller.IsPressedWithCharge(Control.LEFT_TRACK_BACKWARDS))
                {
                    tankMoved = true;
                    if (Controller.IsPressedWithCharge(Control.RIGHT_TRACK_BACKWARDS))
                    {
                        Tank.BothTracksBackward();
                        Controller.DepleteCharge(Control.LEFT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.RIGHT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else if (Controller.IsPressedWithCharge(Control.RIGHT_TRACK_FORWARDS))
                    {
                        Tank.LeftTrackBackward();
                        Tank.RightTrackForward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.LEFT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else
                    {
                        Tank.LeftTrackBackward();
                        Controller.DepleteCharge(Control.LEFT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                }
                else if (Controller.IsPressedWithCharge(Control.RIGHT_TRACK_FORWARDS))
                {
                    tankMoved = true;
                    if (Controller.IsPressedWithCharge(Control.LEFT_TRACK_FORWARDS))
                    {
                        Tank.BothTracksForward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.LEFT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else if (Controller.IsPressedWithCharge(Control.LEFT_TRACK_BACKWARDS))
                    {
                        Tank.LeftTrackBackward();
                        Tank.RightTrackForward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.LEFT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else
                    {
                        Tank.RightTrackForward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                }
                else if (Controller.IsPressedWithCharge(Control.RIGHT_TRACK_BACKWARDS))
                {
                    tankMoved = true;
                    if (Controller.IsPressedWithCharge(Control.LEFT_TRACK_BACKWARDS))
                    {
                        Tank.BothTracksBackward();
                        Controller.DepleteCharge(Control.LEFT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.RIGHT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else if (Controller.IsPressedWithCharge(Control.LEFT_TRACK_FORWARDS))
                    {
                        Tank.LeftTrackForward();
                        Tank.RightTrackBackward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                        Controller.DepleteCharge(Control.LEFT_TRACK_FORWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                    else
                    {
                        Tank.RightTrackBackward();
                        Controller.DepleteCharge(Control.RIGHT_TRACK_BACKWARDS, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                    }
                }

                if (Controller.IsPressedWithCharge(Control.TURRET_LEFT))
                {
                    Tank.CannonLeft();
                    Controller.DepleteCharge(Control.TURRET_LEFT, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                }
                else if (Controller.IsPressedWithCharge(Control.TURRET_RIGHT))
                {
                    Tank.CannonRight();
                    Controller.DepleteCharge(Control.TURRET_RIGHT, DGS.Instance.GetFloat("TRACK_DEPLETION_RATE") * pSeconds);
                }

                if (Controller.IsPressedWithCharge(Control.FIRE))
                {
                    Tank.PrimingWeapon(pSeconds);
                }
                else
                {
                    if (Tank.FireIfPrimed())
                    {
                        SoundEffectInstance bulletShot = Tankontroller.Instance().GetSoundManager().GetSoundEffectInstance("Sounds/Tank_Gun");
                        bulletShot.Play();
                        Controller.DepleteCharge(Control.FIRE, DGS.Instance.GetFloat("BULLET_CHARGE_DEPLETION")); // BULLET CHARGE HERE
                        Tank.SetFired(DGS.Instance.GetInt("BLAST_DELAY"));
                    }
                }

                if (Controller.IsPressed(Control.RECHARGE))
                {
                    if (!Tank.ChargeDown)
                    {
                        Tank.ChargePressed();
                        Controller.AddCharge(Control.RECHARGE, DGS.Instance.GetFloat("CHARGE_AMOUNT"));
                    }
                }
                else
                {
                    Tank.ChargeReleased();
                }
            }
            if (Tank.Fired() > 0)
            {
                Tank.DecFired();
            }
            return(tankMoved);
        }