Beispiel #1
0
    /// <summary>
    /// コマンド実行
    /// </summary>
    public override void ExecuteCommand(PlayerController.CommandData command)
    {
        PPPlayArea playArea = (Game as PPGame).PlayArea;

        switch ((PlayerController.CommandType)command.type)
        {
        case PlayerController.CommandType.PP_Swap:
            if (command.values != null)
            {
                Vector2i     grid   = new Vector2i(command.values[0] % PPGame.Config.PlayAreaWidth, command.values[0] / PPGame.Config.PlayAreaWidth);
                PPPanelBlock result = playArea.SwapPanel(playArea.GetBlock(grid), (PlayAreaBlock.Dir)command.values[1]);
                if (result != null)
                {
                    m_TouchedBlock = result;
                }
            }
            break;

        case PlayerController.CommandType.PP_Add:
            playArea.ElevateValue       = PPGame.Config.ManualElevateSpeed;
            playArea.MaxElevateWaitTime = PPGame.Config.ManualElevateInterval;
            playArea.SkipElevateWait();
            break;
        }

        // ダメージ
        DamageTable.DamageData damage = GetDamageData((PlayerController.DamageType)command.damageType, command.damageValue);
        if (damage != null)
        {
            foreach (var disturbData in damage.PPDisturb)
            {
                for (int i = 0; i < disturbData.count; i++)
                {
                    (Game as PPGame).PlayArea.CreateDisturbPanel(disturbData.width, disturbData.height);
                }
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// 更新
    /// </summary>
    public override void Play()
    {
        base.Play();

        PPPlayArea playArea = (Game as PPGame).PlayArea;

        if (Input.GetKeyDown(KeyCode.D))
        {
            (Game as PPGame).PlayArea.CreateDisturbPanel(6, 2);
        }

        // タッチした瞬間
        if (InputManager.IsTouchDown())
        {
            // タッチブロック保持
            m_TouchedBlock = playArea.GetBlock(Camera.main.ScreenToWorldPoint(InputManager.GetTouchPosition()));
        }

        // タッチ中
        if (InputManager.IsTouch())
        {
            // せり上げ
            if (InputManager.IsTouchDouble())
            {
                Elevate();
            }
            // 入れ替え
            else if (m_TouchedBlock != null)
            {
                Vector3 worldTouchPos = Camera.main.ScreenToWorldPoint(InputManager.GetTouchPosition());

                // 移動先グリッド
                Vector2i target = playArea.ConvertWorldToGrid(worldTouchPos);
                // 移動元グリッド
                Vector2i current = playArea.GetBlockGrid(m_TouchedBlock);

                if (target != current)
                {
                    Vector2i          dif = target - current;
                    PlayAreaBlock.Dir dir;
                    if (dif.x < 0)
                    {
                        dir = PlayAreaBlock.Dir.Left;
                    }
                    else if (dif.x > 0)
                    {
                        dir = PlayAreaBlock.Dir.Right;
                    }
                    else if (dif.y > 0)
                    {
                        dir = PlayAreaBlock.Dir.Down;
                    }
                    else
                    {
                        dir = PlayAreaBlock.Dir.Up;
                    }

                    // 交換
                    PPPanelBlock targetBlock = playArea.GetBlock(target);
                    Vector3      distance    = targetBlock != null ? targetBlock.Position - worldTouchPos : Vector3.zero;
                    if (targetBlock == null ||
                        ((dir == PlayAreaBlock.Dir.Left || dir == PlayAreaBlock.Dir.Right) && Mathf.Abs(distance.x) < PPGame.Config.PanelSwapStartDistance) ||
                        ((dir == PlayAreaBlock.Dir.Up || dir == PlayAreaBlock.Dir.Down) && Mathf.Abs(distance.y) < PPGame.Config.PanelSwapStartDistance))
                    {
                        SwapPanel(m_TouchedBlock, dir);
                    }
                }
            }
        }
    }