コード例 #1
0
ファイル: GameLevel.cs プロジェクト: nusisschad/XNAGameStudio
        /// <summary>
        /// creates a weapon for level.
        /// reads an weapon information file(.spec) and configures the weapon class.
        /// The read weapon class is stored in the list.
        /// </summary>
        /// <param name="info">weapon information for level</param>
        /// <param name="sceneParent">3D scene parent node</param>
        /// <returns>weapon class for the game</returns>
        protected GameWeapon CreateWeapon(WeaponInLevel info, NodeBase sceneParent)
        {
            GameWeaponSpec spec = new GameWeaponSpec();

            spec = (GameWeaponSpec)GameDataSpecManager.Load(info.SpecFilePath,
                                                            spec.GetType());

            GameWeapon weapon = new GameWeapon(spec);

            //  creates a collision data.
            Vector3 centerPos = Vector3.Transform(new Vector3(0f, spec.ModelRadius, 0f),
                                                  Matrix.Invert(weapon.RootAxis));

            CollideSphere collide = new CollideSphere(centerPos, spec.ModelRadius);

            weapon.SetCollide(collide);

            weapon.SetDroppedModelActiveFog(true);
            weapon.SetDroppedModelActiveLighting(false);

            //  drop to world.
            weapon.Drop(info.Position, sceneParent, null);

            //  adds a weapon to the list.
            weaponList.Add(weapon);

            return(weapon);
        }
コード例 #2
0
        /// <summary>
        /// takes the reload action.
        /// </summary>
        /// <param name="weapon">current weapon</param>
        /// <returns></returns>
        public override bool ActionReload(GameWeapon weapon)
        {
            //  If weapon reloaded, action reload
            if (CurrentWeapon.IsPossibleToReload())
            {
                CurrentWeapon.Reload(this.UnitType);

                engageAction = Action.Reload;

                return(true);
            }

            return(false);
        }
コード例 #3
0
ファイル: GameUnit.cs プロジェクト: nusisschad/XNAGameStudio
        /// <summary>
        /// creates a weapon by spec file.
        /// </summary>
        /// <param name="specFileName">weapon information file (.spec)</param>
        public void CreateWeapon(string specFileName)
        {
            GameWeaponSpec spec = new GameWeaponSpec();

            spec =
                (GameWeaponSpec)GameDataSpecManager.Load(specFileName, spec.GetType());

            GameWeapon createWeapon = new GameWeapon(spec);

            createWeapon.AttachOwner(this);

            weaponList.Add(createWeapon);

            SelectWeapon(0);
        }
コード例 #4
0
ファイル: GameUnit.cs プロジェクト: nusisschad/XNAGameStudio
        /// <summary>
        /// changes a weapon.
        /// </summary>
        /// <param name="slot">weapon slot number</param>
        public void SelectWeapon(int slot)
        {
            this.refCurrentWeapon  = weaponList[slot];
            this.currentWeaponSlot = slot;

            for (int i = 0; i < this.weaponList.Count; i++)
            {
                if (i == slot)
                {
                    weaponList[i].Visible = true;
                    weaponList[i].Enabled = true;
                }
                else
                {
                    weaponList[i].Visible = false;
                    weaponList[i].Enabled = false;
                }
            }
        }
コード例 #5
0
ファイル: EnemyBoss.cs プロジェクト: GodLesZ/svn-dump
        /// <summary>
        /// takes the reload action.
        /// </summary>
        /// <param name="weapon">current weapon</param>
        /// <returns></returns>
        public override bool ActionReload(GameWeapon weapon)
        {
            //  If weapon reloaded, action reload
            if (CurrentWeapon.IsPossibleToReload())
            {
                CurrentWeapon.Reload(this.UnitType);

                engageAction = Action.Reload;

                return true;
            }

            return false;
        }
コード例 #6
0
ファイル: GameLevel.cs プロジェクト: nusisschad/XNAGameStudio
        /// <summary>
        /// load all of the data for stage level, player, enemies, items, weapons, etc.
        /// </summary>
        /// <returns></returns>
        public void LoadLevel(string levelFile)
        {
            this.levelInfo = (GameLevelInfo)HelperFile.LoadData(levelFile,
                                                                levelInfo.GetType());

            RobotGameGame.CurrentGameLevel = this;

            //  Initialize level
            Initialize();

            //  Global fog
            if (levelInfo.FogEnable)
            {
                FrameworkCore.Viewer.BasicFog         = new RenderFog();
                FrameworkCore.Viewer.BasicFog.enabled = true;
                FrameworkCore.Viewer.BasicFog.start   = levelInfo.FogStart;
                FrameworkCore.Viewer.BasicFog.end     = levelInfo.FogEnd;

                FrameworkCore.Viewer.BasicFog.color = new Color(
                    (byte)levelInfo.FogColor.X,
                    (byte)levelInfo.FogColor.Y,
                    (byte)levelInfo.FogColor.Z);
            }
            else
            {
                FrameworkCore.Viewer.BasicFog         = new RenderFog();
                FrameworkCore.Viewer.BasicFog.enabled = false;
            }

            //  Global lighting
            if (levelInfo.LightingEnable)
            {
                FrameworkCore.Viewer.BasicLighting         = new RenderLighting();
                FrameworkCore.Viewer.BasicLighting.enabled = true;

                FrameworkCore.Viewer.BasicLighting.ambientColor = new Color(
                    (byte)levelInfo.LightingAmbientColor.X,
                    (byte)levelInfo.LightingAmbientColor.Y,
                    (byte)levelInfo.LightingAmbientColor.Z);

                FrameworkCore.Viewer.BasicLighting.diffuseColor = new Color(
                    (byte)levelInfo.LightingDiffuseColor.X,
                    (byte)levelInfo.LightingDiffuseColor.Y,
                    (byte)levelInfo.LightingDiffuseColor.Z);

                FrameworkCore.Viewer.BasicLighting.specularColor = new Color(
                    (byte)levelInfo.LightingSpecularColor.X,
                    (byte)levelInfo.LightingSpecularColor.Y,
                    (byte)levelInfo.LightingSpecularColor.Z);

                FrameworkCore.Viewer.BasicLighting.direction =
                    levelInfo.LightingDirection;
            }
            else
            {
                FrameworkCore.Viewer.BasicLighting         = new RenderLighting();
                FrameworkCore.Viewer.BasicLighting.enabled = false;
            }

            //  Create world
            if (this.levelInfo.WorldInLevel != null)
            {
                CreateWorld(ref this.levelInfo.WorldInLevel);
            }

            //  Create particles
            CreateParticle(this.levelInfo.ParticleListFile);

            //  Create player
            if (this.levelInfo.PlayerInLevel != null)
            {
                GamePlayer player = CreatePlayer(ref this.levelInfo.PlayerInLevel,
                                                 this.SceneMechRoot);

                RobotGameGame.SinglePlayer = player;
                FrameworkCore.GameEventManager.TargetScene = player;
            }

            //  Create all enemies in the level
            if (levelInfo.EnemyInLevelList != null)
            {
                for (int i = 0; i < levelInfo.EnemyInLevelList.Count; i++)
                {
                    EnemyInLevel enemy = levelInfo.EnemyInLevelList[i];

                    CreateSpawnEnemy(ref enemy, this.SceneMechRoot);
                }
            }

            //  Create all items in the level
            if (levelInfo.ItemInLevelList != null)
            {
                for (int i = 0; i < levelInfo.ItemInLevelList.Count; i++)
                {
                    ItemInLevel item = levelInfo.ItemInLevelList[i];

                    CreateItemBox(ref item, this.SceneWorldRoot);
                }
            }

            //  Create all weapons in the level
            if (levelInfo.WeaponInLevelList != null)
            {
                for (int i = 0; i < levelInfo.WeaponInLevelList.Count; i++)
                {
                    CreateWeapon(levelInfo.WeaponInLevelList[i], SceneWorldRoot);
                }
            }

            //  Entry collision of the units to layer in the level
            switch (Info.GamePlayType)
            {
            case GamePlayTypeId.StageClear:
            {
                GamePlayer player = SinglePlayer;

                //  Entry collision of the player to layer in the level
                CollisionLayerFriendlyMech.AddCollide(player.Collide);
                CollisionLayerAllMech.AddCollide(player.Collide);

                //  Entry collsion of each enemy to layer in the level
                for (int i = 0; i < EnemyCountInLevel; i++)
                {
                    GameEnemy enemy = GetEnemyInLevel(i);

                    CollisionLayerEnemyMech.AddCollide(enemy.Collide);
                    CollisionLayerAllMech.AddCollide(enemy.Collide);
                }
            }
            break;

            case GamePlayTypeId.Versus:
            {
            }
            break;
            }

            //  Entry collsion of items to layer in the level
            for (int i = 0; i < ItemCountInLevel; i++)
            {
                GameItemBox item = GetItemInLevel(i);

                CollisionLayerItems.AddCollide(item.Collide);
            }

            //  Entry collsion of weapons to layer in the level
            for (int i = 0; i < WeaponCountInLevel; i++)
            {
                GameWeapon weapon = GetWeaponInLevel(i);

                CollisionLayerItems.AddCollide(weapon.Collide);
            }
        }
コード例 #7
0
ファイル: GamePlayer.cs プロジェクト: GodLesZ/svn-dump
        /// <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();
        }
コード例 #8
0
ファイル: GamePlayer.cs プロジェクト: GodLesZ/svn-dump
        /// <summary>
        /// acquires a sub weapon, which has been dropped on the world.
        /// If there is a sub weapon already, besides the default weapon, 
        /// the current sub weapon is dropped onto the world and acquires 
        /// the specified pickup weapon.
        /// </summary>
        /// <param name="pickupWeapon">pickup weapon</param>
        public void ActionPickupWeapon(GameWeapon pickupWeapon)
        {
            bool isSame = false;
            string message = "GOT";

            //  You've sub weapon
            if (WeaponCount > 1)
            {
                GameWeapon youveWeapon = GetWeapon(1);

                //  You've a same sub-weapon
                if (youveWeapon.WeaponType == pickupWeapon.WeaponType)
                {
                    youveWeapon.RemainAmmo += pickupWeapon.RemainAmmo;
                    pickupWeapon.Discard();
                    isSame = true;
                    possiblePickupWeapon = null;
                    RobotGameGame.CurrentStage.DisableControlHelper(
                        (int)this.PlayerIndex, 1);
                }
                //  If difference, your sub weapon must be drop to world
                else
                {
                    weaponList[1].Drop(new Vector3(Position.X, 0.5f, Position.Z), 
                        RobotGameGame.CurrentGameLevel.SceneWorldRoot,
                        RobotGameGame.CurrentGameLevel.CollisionLayerItems);
                    possiblePickupWeapon = weaponList[1];
                    weaponList.RemoveAt(1);
                }
            }
            else
            {
                RobotGameGame.CurrentStage.DisableControlHelper(
                    (int)this.PlayerIndex, 1);

                possiblePickupWeapon = null;
            }

            //  Add new weapon
            if (isSame == false)
            {
                weaponList.Add(pickupWeapon);
                pickupWeapon.Pickup(this);

                //  Play swap action
                if (this.CurrentWeaponSlot != 0)
                {
                    // Swap the new weapon
                    SelectWeapon(1);

                    //  Update selected weapon image in the Hud
                    RobotGameGame.CurrentStage.SetCurrentWeaponHud(
                        (int)this.PlayerIndex, CurrentWeapon.WeaponType);

                    this.prepareUpperAction = UpperAction.WeaponChange;

                    if (CurrentWeapon.NeedToReload)
                    {
                        RobotGameGame.CurrentStage.DisplayControlHelper(
                                        (int)this.PlayerIndex, 0, "(RB) RELOAD");
                    }
                    else
                    {
                        RobotGameGame.CurrentStage.DisableControlHelper(
                                        (int)this.PlayerIndex, 0);
                    }
                }
            }

            //  Play the pick up sound
            GameSound.Play3D(SoundTrack.PickupWeapon, RobotGameGame.SinglePlayer);
            
            switch(pickupWeapon.WeaponType)
            {
                case WeaponType.PlayerShotgun:
                    {
                        message += " SHOTGUN";
                    }
                    break;
                case WeaponType.PlayerHandgun:
                    {
                        message += " HANDGUN";
                    }
                    break;
            }

            //  Display the pick up message to screen
            RobotGameGame.CurrentStage.DisplayPickup((int)this.PlayerIndex, message,
                3.0f);
        }
コード例 #9
0
ファイル: GamePlayer.cs プロジェクト: GodLesZ/svn-dump
        /// <summary>
        /// takes the reload action.
        /// </summary>
        /// <param name="weapon">current weapon</param>
        /// <returns></returns>
        public override bool ActionReload(GameWeapon weapon)
        {
            //  If weapon reloaded, action reload
            if (CurrentWeapon.IsPossibleToReload())
            {
                CurrentWeapon.Reload(this.UnitType);

                switch (this.CurrentWeapon.WeaponType)
                {
                    case WeaponType.PlayerMachineGun:
                        {
                            this.prepareUpperAction = UpperAction.ReloadMachineGun;
                        }
                        break;
                    case WeaponType.PlayerShotgun:
                        {
                            this.prepareUpperAction = UpperAction.ReloadShotgun;
                        }
                        break;
                    case WeaponType.PlayerHandgun:
                        {
                            this.prepareUpperAction = UpperAction.ReloadHandgun;
                        }
                        break;
                }

                RobotGameGame.CurrentStage.DisableControlHelper(
                    (int)this.PlayerIndex, 0);
 
                return true;
            }

            return false;
        }
コード例 #10
0
ファイル: GameUnit.cs プロジェクト: GodLesZ/svn-dump
 public virtual bool ActionReload(GameWeapon weapon) { return false; }
コード例 #11
0
ファイル: GameUnit.cs プロジェクト: GodLesZ/svn-dump
        /// <summary>
        /// changes a weapon.
        /// </summary>
        /// <param name="slot">weapon slot number</param>
        public void SelectWeapon(int slot)
        {
            this.refCurrentWeapon = weaponList[slot];
            this.currentWeaponSlot = slot;

            for (int i = 0; i < this.weaponList.Count; i++)
            {
                if (i == slot)
                {
                    weaponList[i].Visible = true;
                    weaponList[i].Enabled = true;
                }
                else
                {
                    weaponList[i].Visible = false;
                    weaponList[i].Enabled = false;
                }
            }
        }
コード例 #12
0
ファイル: GameUnit.cs プロジェクト: GodLesZ/svn-dump
        /// <summary>
        /// creates a weapon by spec file.
        /// </summary>
        /// <param name="specFileName">weapon information file (.spec)</param>
        public void CreateWeapon(string specFileName)
        {
            GameWeaponSpec spec = new GameWeaponSpec();
            spec = 
                (GameWeaponSpec)GameDataSpecManager.Load(specFileName, spec.GetType());

            GameWeapon createWeapon = new GameWeapon(spec);
            createWeapon.AttachOwner(this);

            weaponList.Add(createWeapon);

            SelectWeapon(0);
        }
コード例 #13
0
ファイル: GameUnit.cs プロジェクト: nusisschad/XNAGameStudio
 public virtual bool ActionReload(GameWeapon weapon)
 {
     return(false);
 }