Exemple #1
0
        /// <summary>
        /// plays a lower body animation according to action.
        /// </summary>
        /// <param name="action">lower action</param>
        /// <param name="startTime">start time of animation</param>
        public void PlayLowerAction(LowerAction action, float startTime)
        {
            AnimPlayMode playMode = AnimPlayMode.Repeat;
            float blendTime = 0.0f;

            switch (action)
            {
                case LowerAction.Idle:
                    {
                        blendTime = 0.5f;
                    }
                    break;
                case LowerAction.Run:
                    {
                        blendTime = 0.3f;
                    }
                    break;
                case LowerAction.Damage:
                    {
                        playMode = AnimPlayMode.Once;
                        blendTime = 0.2f;
                    }
                    break;
                case LowerAction.Walk:
                    {
                        blendTime = 0.3f;
                    }
                    break;
                case LowerAction.BackwardWalk:
                    {
                        blendTime = 0.3f;
                    }
                    break;
                case LowerAction.LeftTurn:
                case LowerAction.RightTurn:
                    {
                        blendTime = 0.5f;
                    }
                    break;
                case LowerAction.ForwardDead:
                case LowerAction.BackwardDead:
                case LowerAction.LeftDead:
                case LowerAction.RightDead:
                    {
                        playMode = AnimPlayMode.Once;
                        blendTime = 0.2f;
                    }
                    break;                
                case LowerAction.BoosterPrepare:
                case LowerAction.BoosterFinish:
                case LowerAction.BoosterActive:
                case LowerAction.BoosterBreak:
                case LowerAction.BoosterLeftTurn:
                case LowerAction.BoosterRightTurn:
                    {
                        playMode = AnimPlayMode.Once;
                        blendTime = 0.2f;
                    }
                    break;
                default:
                    throw new NotSupportedException("Not supported an animation");
            }

            //  Play the lower animation
            PlayAnimation(indexLowerAnimation[(int)action],
                          startTime, blendTime, 
                          this.defaultAnimationScaleFactor, 
                          playMode);

            this.currentLowerAction = action;
            this.prepareLowerAction = LowerAction.Unknown;
            this.isOverwriteLowerAction = false;
        }
Exemple #2
0
        /// <summary>
        /// processes the user’s input.
        /// According to the input key, a weapon gets fired or 
        /// the player robot get moved.
        /// </summary>
        public void HandleInput(GameTime gameTime)
        {
            if( this.prepareLowerAction == LowerAction.Unknown)
                this.isOverwriteLowerAction = false;

            if (this.prepareUpperAction == UpperAction.Unknown)
                this.isOverwriteUpperAction = false;

            bool enableControl = (EnableHandleInput &&
                (FrameworkCore.CurrentCamera.FirstCamera is FollowCamera));

            //////////////////////////  Use booster
            if (this.gameInput.IsStrokeKey(GameKey.Booster) &&
                !IsDead && !IsCriticalDamaged && !isDelayBooster && 
                !IsReloading && !IsWeaponChanging && enableControl)
            {
                if (isActiveBooster == false && IsReadyToUseBooster)
                    ActionBooster();            //  Booster on
                else if (isActiveBooster)
                    ActionBoosterFinish();      //  Booster cancel
            }

            ////////////////////////    Use weapon
            {
                //  Reload weapon
                if (this.gameInput.IsStrokeKey(GameKey.WeaponReload) &&
                    (!IsDead && !IsCriticalDamaged && !IsFiring && !isActiveBooster &&
                     !isDelayBooster && !IsWeaponChanging && enableControl))
                {
                    ActionReload(CurrentWeapon);
                }
                //  Change weapon
                else if (this.gameInput.IsStrokeKey(GameKey.WeaponChange) &&
                    (!IsDead && !IsCriticalDamaged && !IsFiring && !isActiveBooster &&
                    !isDelayBooster && !IsWeaponChanging && enableControl))
                {
                    if (possiblePickupWeapon == null)
                        ActionSwapWeapon();
                    else
                        pickupElapsedTime = 0.0f;
                }
                //  Pickup weapon using change key
                else if (this.gameInput.IsPressKey(GameKey.WeaponChange) &&
                    (!IsDead && !IsCriticalDamaged && !IsFiring && !isActiveBooster &&
                    !isDelayBooster && !IsWeaponChanging && enableControl))
                {
                    if (possiblePickupWeapon != null)
                    {
                        RobotGameGame.CurrentStage.DisplayPickupCoolTime(
                                                        (int)this.PlayerIndex, true);

                        pickupElapsedTime +=
                            (float)gameTime.ElapsedGameTime.TotalSeconds;

                        if (pickupElapsedTime > 1.0f)
                        {
                            //  Pick up a weapon in the world
                            ActionPickupWeapon(possiblePickupWeapon);

                            //  Swaps the new weapon
                            ActionSwapSubWeapon();

                            pickupElapsedTime = 0.0f;

                            RobotGameGame.CurrentStage.DisplayPickupCoolTime(
                                                        (int)this.PlayerIndex, false);
                        }
                    }
                    else
                    {
                        pickupElapsedTime = 0.0f;

                        RobotGameGame.CurrentStage.DisplayPickupCoolTime(
                                                        (int)this.PlayerIndex, false);
                    }
                }
                //  Change weapon
                else if (this.gameInput.IsReleaseKey(GameKey.WeaponChange) &&
                (!IsDead && !IsCriticalDamaged && !IsFiring && !isActiveBooster &&
                 !isDelayBooster && !IsWeaponChanging && enableControl))
                {
                    if (possiblePickupWeapon != null)
                    {
                        if (pickupElapsedTime < 0.35f && pickupElapsedTime > 0.0f)
                        {
                            ActionSwapWeapon();
                        }
                    }

                    pickupElapsedTime = 0.0f;
                }

                //  Fire weapon
                if (this.gameInput.IsPressKey(GameKey.WeaponFire) &&
                     (!IsDead && !IsCriticalDamaged && !isDelayBooster &&
                      !IsReloading && !IsWeaponChanging && enableControl))
                {
                    if (CurrentWeapon.IsPossibleToFire())
                    {
                        //  Fire action
                        ActionFire();

                        WeaponFire();
                    }

                    //  Empty the weapon?
                    if (CurrentWeapon.NeedToReload && !IsReloading && !IsWeaponChanging)
                    {
                        ActionNonFire();

                        this.tryEmptyWeeapon = true;

                        if (this.CurrentWeapon.WeaponType == WeaponType.PlayerMachineGun)
                            CurrentWeapon.StopFireSound();

                        //  Play a weapon empty sound
                        if (!GameSound.IsPlaying(soundFireEmpty))
                        {
                            soundFireEmpty = GameSound.Play3D(
                                SoundTrack.PlayerEmptyBullet,
                                RobotGameGame.SinglePlayer);

                            RobotGameGame.CurrentStage.DisplayControlHelper(
                                            (int)this.PlayerIndex, 0, "(RB) RELOAD");
                        }
                    }
                }
                else
                {
                    if (this.CurrentWeapon.WeaponType == WeaponType.PlayerMachineGun)
                        CurrentWeapon.StopFireSound();

                    this.tryEmptyWeeapon = false;
                }
            }

            ////////////////////////    Rotate the player
            {
                if (this.gameInput.IsPressTurn() &&
                     (!IsDead && !IsCriticalDamaged && !isDelayBooster && enableControl))
                {
                    float angle = 0.0f;

                    //  Turn angle
                    if (isActiveBooster)
                        angle = BoosterTurnAngle;
                    else
                        angle = TurnAngle;

                    //  Look at left
                    if (this.gameInput.IsPressKey(GameKey.TurnLeft))
                    {
                        Rotate(new Vector2(angle, 0.0f));

                        if (this.CurrentLowerAction == LowerAction.Idle ||
                            this.CurrentLowerAction == LowerAction.RightTurn)
                        {
                            this.prepareLowerAction = LowerAction.LeftTurn;
                        }
                    }
                    //  Look at right
                    else if (this.gameInput.IsPressKey(GameKey.TurnRight))
                    {
                        Rotate(new Vector2(-angle, 0.0f));

                        if (this.CurrentLowerAction == LowerAction.Idle ||
                            this.CurrentLowerAction == LowerAction.LeftTurn)
                        {
                            this.prepareLowerAction = LowerAction.RightTurn;
                        }
                    }
                }
                else if (!IsDead && !IsCriticalDamaged && 
                         !isActiveBooster && enableControl)
                {
                    if (CurrentLowerAction == LowerAction.LeftTurn ||
                        CurrentLowerAction == LowerAction.RightTurn)
                    {
                        this.prepareLowerAction = LowerAction.Idle;
                    }
                }
            }

            ////////////////////////    Movement the player
            {
                bool goingOn = false;
                Vector3 moveVelocity = Vector3.Zero;

                //  Player booster control
                if (this.isActiveBooster)
                {
                    if (this.isDelayBooster == false)
                    {
                        this.moveDirection = this.Direction;

                        //  Left moving
                        if (this.gameInput.IsPressKey(GameKey.MoveLeft))
                        {
                            moveVelocity.X = -this.specData.RunSpeed;
                            moveVelocity.Z = this.SpecData.BoosterSpeed;
                        }
                        //  Right moving
                        else if (this.gameInput.IsPressKey(GameKey.MoveRight))
                        {
                            moveVelocity.X = this.specData.RunSpeed;
                            moveVelocity.Z = this.SpecData.BoosterSpeed;
                        }
                        //  Forward booster
                        else
                        {
                            moveVelocity.Z = this.SpecData.BoosterSpeed;
                        }

                        goingOn = true;
                    }
                    else
                    {
                        goingOn = false;
                    }
                }
                //  Player movement control
                else
                {
                    if (this.gameInput.IsPressMovement() &&
                        (!IsDead && !IsCriticalDamaged && 
                        !isDelayBooster && enableControl))
                    {
                        float moveSpeed = 0.0f;

                        if (IsFiring || IsReloading || 
                            IsWeaponChanging || IsTryEmptyWeapon)
                            moveSpeed = WalkSpeed;
                        else
                            moveSpeed = RunSpeed;

                        //  Move forward
                        if (this.gameInput.IsPressKey(GameKey.MoveForward))
                        {
                            //  Move Left forward
                            if (this.gameInput.IsPressKey(GameKey.MoveLeft))
                            {
                                this.moveDirection = new Vector3(-1.0f, 0, 1.0f);

                                moveVelocity = this.moveDirection *
                                        (moveSpeed * (this.moveDirection.Length() / 2));
                            }
                            //  Move Right forward
                            else if (this.gameInput.IsPressKey(GameKey.MoveRight))
                            {
                                this.moveDirection = new Vector3(1.0f, 0, 1.0f);

                                moveVelocity = this.moveDirection *
                                        (moveSpeed * (this.moveDirection.Length() / 2));
                            }
                            //  Move forward
                            else
                            {
                                this.moveDirection = new Vector3(0, 0, 1.0f);

                                moveVelocity = this.moveDirection * moveSpeed;
                            }
                        }
                        //  Move Backward
                        else if (this.gameInput.IsPressKey(GameKey.MoveBackward))
                        {
                            //  Move Left backward
                            if (this.gameInput.IsPressKey(GameKey.MoveLeft))
                            {
                                this.moveDirection = new Vector3(-1.0f, 0, -1.0f);

                                moveVelocity = this.moveDirection *
                                    (WalkBackwardSpeed * 
                                    (this.moveDirection.Length() / 2));
                            }
                            //  Move Right backward
                            else if (this.gameInput.IsPressKey(GameKey.MoveRight))
                            {
                                this.moveDirection = new Vector3(1.0f, 0, -1.0f);

                                moveVelocity = this.moveDirection *
                                    (WalkBackwardSpeed * 
                                    (this.moveDirection.Length() / 2));
                            }
                            //  Move backward
                            else
                            {
                                this.moveDirection = new Vector3(0, 0, -1.0f);

                                moveVelocity = this.moveDirection * WalkBackwardSpeed;
                            }
                        }
                        else
                        {
                            //  Move to Left
                            if (this.gameInput.IsPressKey(GameKey.MoveLeft))
                            {
                                this.moveDirection = new Vector3(-1.0f, 0, 0);
                                moveVelocity = this.moveDirection * moveSpeed;
                            }
                            //  Move to Right
                            else if (this.gameInput.IsPressKey(GameKey.MoveRight))
                            {
                                this.moveDirection = new Vector3(1.0f, 0, 0);
                                moveVelocity = this.moveDirection * moveSpeed;
                            }
                            //  Move stop
                            else
                            {
                                moveVelocity = this.moveDirection = Vector3.Zero;
                            }
                        }

                        goingOn = true;

                        pickupElapsedTime = 0.0f;
                    }
                    else
                    {
                        this.moveDirection = Vector3.Zero;

                        goingOn = false;
                    }

                    if (!IsCriticalDamaged && !IsDead)
                        ActionMovement(gameTime, this.moveDirection);
                }

                if (goingOn)
                {
                    //  Display the pick up message
                    if (possiblePickupWeapon != null)
                    {
                        RobotGameGame.CurrentStage.DisplayControlHelper(
                                            (int)this.PlayerIndex, 1, "(LB) PICK UP");
                    }
                    else
                    {
                        RobotGameGame.CurrentStage.DisableControlHelper(
                                            (int)this.PlayerIndex, 1);
                    }

                    possiblePickupWeapon = null;

                    //  Collision detecting with all enemies and
                    //  world before our player moves 
                    CollisionResult result = MoveHitTest(gameTime, moveVelocity);
                    if (result != null)
                    {
                        if (result.detectedCollide.Owner is GameItemBox)
                        {
                            GameItemBox item =
                                        result.detectedCollide.Owner as GameItemBox;

                            ActionPickUpItem(item);

                            goingOn = true;
                        }
                        else if (result.detectedCollide.Owner is GameWeapon)
                        {
                            GameWeapon weapon =
                                        result.detectedCollide.Owner as GameWeapon;

                            goingOn = true;

                            possiblePickupWeapon = weapon;
                        }
                        else
                        {                            
                            MoveStop();

                            //  Blocked booster moving
                            if (this.isActiveBooster)
                                ActionBoosterBreak();

                            goingOn = false;
                        }
                    }
                    else
                    {
                        if (IsDead || IsCriticalDamaged)
                        {
                            goingOn = false;
                        }
                        else
                        {
                            goingOn = true;
                        }
                    }
                }

                if (goingOn)
                {
                    Move(moveVelocity);
                }
                else
                {
                    MoveStop();
                }
            }

            //  Calculate camera distance with player
            CheckCollisionCamera();
        }
Exemple #3
0
        /// <summary>
        /// determines an moving animation according to velocity.
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="moveDirection"></param>
        public void ActionMovement(GameTime gameTime, Vector3 moveDirection)
        {
            bool doMove = true;
                        
            //  Forward
            if (moveDirection.Z > 0.0f)
            {
                //  Move Left forward
                if (moveDirection.X < 0.0f)
                {
                    //  Player change root axis
                    this.rootRotationAngle = 35.0f;
                }
                //  Move Right forward
                else if (moveDirection.X > 0.0f)
                {
                    //  Player change root axis
                    this.rootRotationAngle = -35.0f;
                }
                //  Forward
                else
                {
                    this.rootRotationAngle = 0.0f;
                }

                if (IsFiring || IsReloading || IsWeaponChanging || IsTryEmptyWeapon)
                {
                    if (this.CurrentLowerAction != LowerAction.Walk)
                        this.prepareLowerAction = LowerAction.Walk;
                }
                else
                {
                    if (this.CurrentLowerAction != LowerAction.Run)
                        this.prepareLowerAction = LowerAction.Run;
                }

                if (this.CurrentUpperAction != UpperAction.Run &&
                    !IsFiring && !IsReloading && !IsWeaponChanging && 
                    !IsTryEmptyWeapon && !IsDead)
                {
                    this.prepareUpperAction = UpperAction.Run;
                }
            }
            //  Backward
            else if (moveDirection.Z < 0.0f)
            {
                //  Move Left backward
                if (moveDirection.X < 0.0f)
                {
                    //  Player change root axis
                    this.rootRotationAngle = -30.0f;
                }
                //  Move Right backward
                else if (moveDirection.X > 0.0f)
                {
                    //  Player change root axis
                    this.rootRotationAngle = 30.0f;
                }
                //  Backward
                else
                {
                    //  Player change root axis
                    this.rootRotationAngle = 0.0f;
                }

                if (this.CurrentLowerAction != LowerAction.BackwardWalk)
                    this.prepareLowerAction = LowerAction.BackwardWalk;

                if (this.CurrentUpperAction != UpperAction.Idle &&
                    !IsFiring && !IsReloading && !IsTryEmptyWeapon &&
                    !IsWeaponChanging && !IsDead)
                {
                    this.prepareUpperAction = UpperAction.Idle;
                }
            }
            else
            {
                //  Move to Left
                if (moveDirection.X < 0.0f)
                {
                    //  Player change root axis
                    this.rootRotationAngle = 65.0f;

                    if (IsFiring || IsReloading || IsWeaponChanging || IsTryEmptyWeapon)
                    {
                        if (this.CurrentLowerAction != LowerAction.Walk)
                            this.prepareLowerAction = LowerAction.Walk;
                    }
                    else
                    {
                        if (this.CurrentLowerAction != LowerAction.Run)
                            this.prepareLowerAction = LowerAction.Run;
                    }

                    if (this.CurrentUpperAction != UpperAction.Run &&
                        !IsFiring && !IsReloading && !IsTryEmptyWeapon && 
                        !IsWeaponChanging && !IsDead)
                    {
                        this.prepareUpperAction = UpperAction.Run;
                    }
                }
                //  Move to Right
                else if (moveDirection.X > 0.0f)
                {
                    //  Player change root axis
                    this.rootRotationAngle = -65.0f;

                    if (IsFiring || IsReloading || IsWeaponChanging || IsTryEmptyWeapon)
                    {
                        if (this.CurrentLowerAction != LowerAction.Walk)
                            this.prepareLowerAction = LowerAction.Walk;
                    }
                    else
                    {
                        if (this.CurrentLowerAction != LowerAction.Run)
                            this.prepareLowerAction = LowerAction.Run;
                    }

                    if (this.CurrentUpperAction != UpperAction.Run &&
                        !IsFiring && !IsReloading && !IsTryEmptyWeapon &&
                        !IsWeaponChanging && !IsDead)
                    {
                        this.prepareUpperAction = UpperAction.Run;
                    }
                }
                //  Move Stop
                else
                {
                    doMove = false;

                    if (this.CurrentLowerAction == LowerAction.Run ||
                        this.CurrentLowerAction == LowerAction.Walk ||
                        this.CurrentLowerAction == LowerAction.BackwardWalk)
                    {
                        this.prepareLowerAction = LowerAction.Idle;
                    }

                    if (this.CurrentUpperAction != UpperAction.Idle && 
                        !IsFiring && !IsReloading && !IsTryEmptyWeapon &&
                        !IsWeaponChanging && !IsDead)
                    {
                        this.prepareUpperAction = UpperAction.Idle;
                    }
                                        
                    //  Player change root axis
                    this.rootRotationAngle = 0.0f;

                    this.moveElapsedTime = 0.0f;
                }
            }

            if (doMove)
            {
                //  Play the moving sound
                if (this.CurrentLowerAction == LowerAction.Run)
                {
                    if (this.moveElapsedTime == 0.0f)
                    {
                        if (GameSound.IsPlaying(soundWalk))
                            GameSound.Stop(soundWalk);

                        if (GameSound.IsPlaying(soundRun))
                            GameSound.Stop(soundRun);

                        soundRun = GameSound.Play3D(SoundTrack.PlayerRun, 
                                                    RobotGameGame.SinglePlayer);
                    }

                    //  Calculate run animation playing time for run sound
                    if (this.runDurationTime > this.moveElapsedTime)
                    {
                        this.moveElapsedTime += 
                            (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                    else
                    {
                        this.moveElapsedTime = 0.0f;
                    }
                }
                else if (this.CurrentLowerAction == LowerAction.Walk)
                {
                    if (this.moveElapsedTime == 0.0f)
                    {
                        if (GameSound.IsPlaying(soundWalk))
                            GameSound.Stop(soundWalk);

                        if (GameSound.IsPlaying(soundRun))
                            GameSound.Stop(soundRun);

                        soundWalk = GameSound.Play3D(SoundTrack.PlayerWalk,
                                                    RobotGameGame.SinglePlayer);
                    }

                    //  Calculate walk animation playing time for run sound
                    if (this.walkDurationTime > this.moveElapsedTime)
                    {
                        this.moveElapsedTime +=
                            (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                    else
                    {
                        this.moveElapsedTime = 0.0f;
                    }
                }
                else if (this.CurrentLowerAction == LowerAction.BackwardWalk)
                {
                    if (this.moveElapsedTime == 0.0f)
                    {
                        if (GameSound.IsPlaying(soundWalk))
                            GameSound.Stop(soundWalk);

                        if (GameSound.IsPlaying(soundRun))
                            GameSound.Stop(soundRun);

                        soundWalk = GameSound.Play3D(SoundTrack.PlayerWalk, 
                                                    RobotGameGame.SinglePlayer);

                        this.moveElapsedTime = 0.0f;
                    }

                    //  Calculate walk animation playing time for run sound
                    if (this.walkDurationTime > this.moveElapsedTime)
                    {
                        this.moveElapsedTime +=
                            (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                    else
                    {
                        this.moveElapsedTime = 0.0f;
                    }
                }
            }
            else
            {
                // Stop the move sound
                if (GameSound.IsPlaying(soundRun))
                    GameSound.Stop(soundRun);

                if (GameSound.IsPlaying(soundWalk))
                    GameSound.Stop(soundWalk);

                this.moveElapsedTime = 0.0f;
            }
        }
Exemple #4
0
 /// <summary>
 /// plays a lower body animation according to action.
 /// </summary>
 /// <param name="action">lower action</param>
 public void PlayLowerAction(LowerAction action)
 {
     PlayLowerAction(action, 0.0f);
 }
Exemple #5
0
        /// <summary>
        /// an animation of getting ready before booster.
        /// </summary>
        protected void ActionBoosterPrepare()
        {
            this.isActiveBooster = true;
            this.isDelayBooster = true;
            this.actionElapsedTime = 0.0f;
            this.boosterWaveEffectTime = 0.0f;

            this.prepareLowerAction = LowerAction.BoosterPrepare;
            this.prepareUpperAction = UpperAction.BoosterPrepare;

            if (!GameSound.IsPlaying(soundBoosterPrepare))
            {
                soundBoosterPrepare = GameSound.Play3D(SoundTrack.PlayerPrepareBooster, 
                                                       RobotGameGame.SinglePlayer);
            }

            int count = 1;
            if (this.UnitType == UnitTypeId.Mark || this.UnitType == UnitTypeId.Yager)
                count = 2;

            //  Play the booster prepare particle on the backpack
            for (int i = 0; i < count; i++)
            {
                int index = -1;

                if( i == 0)
                    index = this.indexLeftBoosterDummy;
                else
                    index = this.indexRightBoosterDummy;

                particleBoosterPrepare[i] = GameParticle.PlayParticle(
                    ParticleType.BoosterPrepare, BoneTransforms[index],
                    Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f)));
            }
        }
Exemple #6
0
        /// <summary>
        /// an animation of booster in progress.
        /// </summary>
        protected void ActionBoosterActive()
        {
            this.isActiveBooster = true;
            this.isDelayBooster = false;

            this.prepareLowerAction = LowerAction.BoosterActive;
            this.prepareUpperAction = UpperAction.BoosterActive;

            if (!GameSound.IsPlaying(soundBooster))
                soundBooster = GameSound.Play3D(SoundTrack.PlayerBooster, 
                                                RobotGameGame.SinglePlayer);

            Matrix fixedAxis = Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f));

            int count = 1;
            if (this.UnitType == UnitTypeId.Mark || this.UnitType == UnitTypeId.Yager)
                count = 2;

            //  Play the booster flash particle on the backpack
            for (int i = 0; i < count; i++)
            {
                int index = -1;

                if (i == 0)
                    index = this.indexLeftBoosterDummy;
                else
                    index = this.indexRightBoosterDummy;

                particleBoosterOn[i] = GameParticle.PlayParticle(
                                          ParticleType.BoosterOn,
                                          BoneTransforms[index],
                                          fixedAxis);
            }

            //  Booster slide particle on the ground
            particleBoosterGround[0] = GameParticle.PlayParticle(
                                                ParticleType.BoosterGround,
                                                BoneTransforms[indexLeftFootDummy],
                                                fixedAxis);

            particleBoosterGround[1] = GameParticle.PlayParticle(
                                                ParticleType.BoosterGround,
                                                BoneTransforms[indexRightFootDummy],
                                                fixedAxis);

            //  vibrate a camera and controller
            if (FrameworkCore.CurrentCamera.FirstCamera is FollowCamera)
            {
                InputComponent input =
                        FrameworkCore.InputManager.GetInputComponent(this.PlayerIndex);

                input.SetGamePadVibration(0.3f, 0.5f, 0.5f);
            }
        }
Exemple #7
0
        /// <summary>
        /// an animation of booster getting interrupted.
        /// </summary>
        protected void ActionBoosterBreak()
        {
            this.isActiveBooster = true;
            this.isDelayBooster = true;
            this.actionElapsedTime = 0.0f;
            this.boosterWaveEffectTime = 0.0f;

            this.prepareLowerAction = LowerAction.BoosterBreak;
            this.prepareUpperAction = UpperAction.BoosterBreak;

            if (GameSound.IsPlaying(soundBoosterPrepare))
                GameSound.Stop(soundBoosterPrepare);

            if (GameSound.IsPlaying(soundBooster))
                GameSound.Stop(soundBooster);

            //  Stop the particle
            BoosterParticleStop();

            //  Vibrate a camera and controller
            if (FrameworkCore.CurrentCamera.FirstCamera is FollowCamera)
            {
                ViewCamera viewCamera = FrameworkCore.CurrentCamera;
                FollowCamera camera = null;

                switch (this.PlayerIndex)
                {
                    case PlayerIndex.One:
                        camera = viewCamera.GetCamera(0) as FollowCamera;
                        break;
                    case PlayerIndex.Two:
                        camera = viewCamera.GetCamera(1) as FollowCamera;
                        break;
                    case PlayerIndex.Three:
                        camera = viewCamera.GetCamera(2) as FollowCamera;
                        break;
                    case PlayerIndex.Four:
                        camera = viewCamera.GetCamera(3) as FollowCamera;
                        break;
                }

                camera.SetTremble(0.6f, 0.1f);

                InputComponent input =
                        FrameworkCore.InputManager.GetInputComponent(this.PlayerIndex);

                input.SetGamePadVibration(boosterBreakDurationTime / 2, 0.3f, 0.3f);
            }
        }
Exemple #8
0
        /// <summary>
        /// an animation at the end of booster.
        /// </summary>
        public void ActionBoosterFinish()
        {
            this.isActiveBooster = true;
            this.isDelayBooster = true;
            this.actionElapsedTime = 0.0f;
            this.boosterWaveEffectTime = 0.0f;

            this.prepareLowerAction = LowerAction.BoosterFinish;
            this.prepareUpperAction = UpperAction.BoosterFinish;

            //  Stop the booster sound
            if (GameSound.IsPlaying(soundBoosterPrepare))
                GameSound.Stop(soundBoosterPrepare);

            if (GameSound.IsPlaying(soundBooster))
                GameSound.Stop(soundBooster);

            //  Stop the booster particle
            BoosterParticleStop();

            //  Vibrate the camera and controller
            if (FrameworkCore.CurrentCamera.FirstCamera is FollowCamera)
            {
                InputComponent input =
                        FrameworkCore.InputManager.GetInputComponent(this.PlayerIndex);

                input.SetGamePadVibration(boosterFinishDurationTime / 2, 0.15f, 0.15f);
            }
        }
Exemple #9
0
        /// <summary>
        /// takes the destruction action.
        /// Plays different destroy animation according to the attack direction.
        /// </summary>
        /// <param name="attackerPosition"></param>
        public override void ActionDead(Vector3 attackerPosition)
        {
            Vector3 dir = Vector3.Normalize(attackerPosition - Position);

            float FrontDot = Vector3.Dot(Direction, dir);
            float RightDot = Vector3.Dot(Right, dir);

            if (FrontDot > 0.5f)
            {
                // Hit from front
                this.prepareLowerAction = LowerAction.BackwardDead;
                this.prepareUpperAction = UpperAction.BackwardDead;
            }
            else if (FrontDot < -0.5f)
            {
                // Hit from back
                this.prepareLowerAction = LowerAction.ForwardDead;
                this.prepareUpperAction = UpperAction.ForwardDead;
            }
            else if (RightDot >= 0.0f)
            {
                //  Hit from right
                this.prepareLowerAction = LowerAction.LeftDead;
                this.prepareUpperAction = UpperAction.LeftDead;
            }
            else if (RightDot < 0.0f)
            {
                //  Hit from left
                this.prepareLowerAction = LowerAction.RightDead;
                this.prepareUpperAction = UpperAction.RightDead;
            }

            //  Stop the sound
            if (GameSound.IsPlaying(soundRun))
                GameSound.Stop(soundRun);

            if (GameSound.IsPlaying(soundWalk))
                GameSound.Stop(soundWalk);

            CurrentWeapon.StopFireSound();

            //  Play a explosion particle
            GameSound.Play3D(SoundTrack.PlayerDestroy1, RobotGameGame.SinglePlayer);

            Matrix world = Matrix.CreateTranslation(Position);

            GameParticle.PlayParticle(ParticleType.DestroyHeavyMech1, 
                                      world, Matrix.Identity);

            //  vibrate the camera and the controller
            if (FrameworkCore.CurrentCamera.FirstCamera is FollowCamera)
            {
                ViewCamera viewCamera = FrameworkCore.CurrentCamera;
                FollowCamera camera = null;

                switch (this.PlayerIndex)
                {
                    case PlayerIndex.One:
                        camera = viewCamera.GetCamera(0) as FollowCamera;
                        break;
                    case PlayerIndex.Two:
                        camera = viewCamera.GetCamera(1) as FollowCamera;
                        break;
                    case PlayerIndex.Three:
                        camera = viewCamera.GetCamera(2) as FollowCamera;
                        break;
                    case PlayerIndex.Four:
                        camera = viewCamera.GetCamera(3) as FollowCamera;
                        break;
                }

                camera.SetTremble(1.0f, 0.2f);

                InputComponent input = 
                        FrameworkCore.InputManager.GetInputComponent(this.PlayerIndex);

                input.SetGamePadVibration(1.0f, 0.6f, 0.6f);
            }

            //  Remove the collision
            if (RobotGameGame.CurrentStage is VersusStageScreen)
                colLayerVersusTeam[(int)this.PlayerIndex].RemoveCollide(Collide);
            else
                colLayerFriendlyMech.RemoveCollide(Collide);

            //  Stop the booster particle and sound
            if (this.isActiveBooster)
            {
                if (GameSound.IsPlaying(soundBoosterPrepare))
                    GameSound.Stop(soundBoosterPrepare);

                if (GameSound.IsPlaying(soundBooster))
                    GameSound.Stop(soundBooster);

                BoosterParticleStop();
            }

            this.SourceBlend = Blend.SourceAlpha;
            this.DestinationBlend = Blend.InverseSourceAlpha;
            this.AlphaBlendEnable = true;
            this.ReferenceAlpha = 0;

            this.isActiveBooster = false;
            this.isDelayBooster = false;

            this.actionElapsedTime = 0.0f;

            RobotGameGame.CurrentStage.DisableAllControlHelper();
        }
Exemple #10
0
        /// <summary>
        /// attacked by enemy. takes the damage action.
        /// </summary>
        /// <param name="attacker"></param>
        public override void ActionDamage(GameUnit attacker)
        {
            switch (attacker.CurrentWeapon.WeaponType)
            {
                case WeaponType.PlayerHandgun:
                case WeaponType.PlayerMachineGun:
                case WeaponType.PlayerShotgun:
                case WeaponType.CameleerGun:
                case WeaponType.MaomingGun:
                    {
                        GameSound.Play3D(SoundTrack.HitGun, RobotGameGame.SinglePlayer);
                    }
                    break;
                case WeaponType.DuskmasCannon:
                case WeaponType.HammerCannon:
                case WeaponType.TigerCannon:
                    {
                        GameSound.Play3D(SoundTrack.HitCannon, 
                            RobotGameGame.SinglePlayer);
                    }
                    break;           
                case WeaponType.PhantomMelee:
                    {
                        GameSound.Play3D(SoundTrack.HitBossMelee, 
                            RobotGameGame.SinglePlayer);
                    }
                    break;
            }

            if (attacker.CurrentWeapon.SpecData.CriticalDamagedFire)
            {
                if (!isActiveBooster && !IsReloading && !IsWeaponChanging)
                {
                    this.prepareLowerAction = LowerAction.Damage;
                    this.prepareUpperAction = UpperAction.Damage;

                    this.isOverwriteLowerAction = true;
                    this.isOverwriteUpperAction = true;

                    if (GameSound.IsPlaying(soundRun))
                        GameSound.Stop(soundRun);

                    if (GameSound.IsPlaying(soundWalk))
                        GameSound.Stop(soundWalk);

                    CurrentWeapon.StopFireSound();
                }

                //  Trembling the camera
                if (FrameworkCore.CurrentCamera.FirstCamera is FollowCamera)
                {
                    InputComponent input = 
                        FrameworkCore.InputManager.GetInputComponent(this.PlayerIndex);

                    input.SetGamePadVibration(this.specData.CriticalDamagedTime / 2, 
                                              0.4f, 0.4f);
                }
           }
        }
Exemple #11
0
        /// <summary>
        /// takes an idle action.
        /// </summary>
        public override void ActionIdle()
        {
            this.prepareLowerAction = LowerAction.Idle;
            this.prepareUpperAction = UpperAction.Idle;

            CurrentWeapon.StopFireSound();

            if (GameSound.IsPlaying(soundRun))
                GameSound.Stop(soundRun);

            if (GameSound.IsPlaying(soundWalk))
                GameSound.Stop(soundWalk);

            MoveStop();
        }