Пример #1
0
 public override void keyProcess(float elapsedTime)
 {
     if (mGameInputManager.getKeyCurrentDown(KeyCode.A))
     {
         CommandCharacterUseItem cmd = newCmd(out cmd);
         cmd.mItemIndex = mPlayer.getPlayerPack().getSelectedIndex();
         pushCommand(cmd, mPlayer);
     }
     //切换道具
     if (mGameInputManager.getKeyCurrentDown(KeyCode.B))
     {
         if (mPlayer.getPlayerPack().canChangeSelection())
         {
             pushCommand <CommandCharacterSelectItem>(mPlayer);
         }
     }
     // 仅测试用
     if (mGameInputManager.getKeyCurrentDown(KeyCode.Alpha1))
     {
         CommandCharacterGetItem cmd = newCmd(out cmd);
         cmd.mItemType = PLAYER_ITEM.PI_MISSILE;
         pushCommand(cmd, mPlayer);
     }
     if (mGameInputManager.getKeyCurrentDown(KeyCode.Alpha2))
     {
         CommandCharacterGetItem cmd = newCmd(out cmd);
         cmd.mItemType = PLAYER_ITEM.PI_SHIELD;
         pushCommand(cmd, mPlayer);
     }
     if (mGameInputManager.getKeyCurrentDown(KeyCode.Alpha3))
     {
         CommandCharacterGetItem cmd = newCmd(out cmd);
         cmd.mItemType = PLAYER_ITEM.PI_TURBO;
         pushCommand(cmd, mPlayer);
     }
     if (mGameInputManager.getKeyCurrentDown(KeyCode.Alpha4))
     {
         CommandCharacterGetItem cmd = newCmd(out cmd);
         cmd.mItemType = PLAYER_ITEM.PI_LAND_MINE;
         pushCommand(cmd, mPlayer);
     }
     // 上方向键增加速度
     if (mGameInputManager.getKeyCurrentDown(KeyCode.UpArrow))
     {
         CommandCharacterHardwareSpeed cmdPassValue = newCmd(out cmdPassValue, false);
         cmdPassValue.mSpeed = mPlayer.getCharacterData().mSpeed + 1.0f;
         pushCommand(cmdPassValue, mPlayer);
     }
     // 下方向键降低速度
     if (mGameInputManager.getKeyCurrentDown(KeyCode.DownArrow))
     {
         CommandCharacterHardwareSpeed cmdPassValue = newCmd(out cmdPassValue, false);
         cmdPassValue.mSpeed = mPlayer.getCharacterData().mSpeed - 1.0f;
         pushCommand(cmdPassValue, mPlayer);
     }
     if (mGameInputManager.getKeyCurrentDown(KeyCode.Space))
     {
         pushCommand <CommandCharacterJump>(mPlayer);
     }
 }
Пример #2
0
    // 道具箱子生效的效果
    public override void onEffective(Character player)
    {
        // 角色获得一个随机道具
        CommandCharacterGetItem cmd = newCmd(out cmd);

        cmd.mItemType = generateItemType();
        pushCommand(cmd, player);
        // 开始销毁道具箱子
        mItemManager.destroyItem(this);
    }