Exemplo n.º 1
0
    public void GetNextStepTranslate()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            keyQueue.Enqueue(KeyCode.W);
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
            keyQueue.Enqueue(KeyCode.S);
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            keyQueue.Enqueue(KeyCode.A);
        }
        else if (Input.GetKeyDown(KeyCode.D))
        {
            keyQueue.Enqueue(KeyCode.D);
        }


        if (!islerping)
        {
            if (keyQueue.Count <= 0)
            {
                return;
            }

            KeyCode _nowKey = keyQueue.Dequeue();

            switch (_nowKey)
            {
            case KeyCode.W:
                nextPosition   = Vector3.forward;
                rotationAngles = Vector3.zero * 90f;
                break;

            case KeyCode.S:
                nextPosition   = Vector3.back;
                rotationAngles = Vector3.down * 180f;
                break;

            case KeyCode.A:
                nextPosition   = Vector3.left;
                rotationAngles = Vector3.down * 90f;
                break;

            case KeyCode.D:
                nextPosition   = Vector3.right;
                rotationAngles = Vector3.up * 90f;
                break;
            }

            playerInstance.GetComponent <Animator>().Play("Armature|jump", -1, 0);

            Vector3        _nextPos             = instance.destination + instance.nextPosition;
            bool           isConflictWithYogurt = (yogurtInstance.transform.position.x != -9999 && (yogurtInstance.transform.position - _nextPos).magnitude < 0.01f);
            DungeonMapData _data = DungeonManager.GetMapData((int)_nextPos.x, (int)_nextPos.z);

            if (_data.cubeData.canThrough && !isConflictWithYogurt)
            {
                if ((_data.itemData.canFuse) && (slimeMode != Item.ItemType.empty))
                {
                    Item.ItemType resultType = CheckFuse(slimeMode, _data.itemType);
                    if ((int)resultType > (int)Item.ItemType.poison)
                    {
                        // 吃到全部,不能合成
                    }
                    else
                    {
                        StepManager.InvokeStep();
                    }
                }
                else
                {
                    StepManager.InvokeStep();
                }

                if (_data.cubeType == E_DUNGEON_CUBE_TYPE.WATER)
                {
                    SlimeBehaviourManger.instance.GetNextStep(_data);

                    SlimeBehaviourManger.instance.WalkOnWater();
                }

                if (_data.cubeType == E_DUNGEON_CUBE_TYPE.TRAP)
                {
                    SlimeBehaviourManger.instance.GetNextStep(_data);

                    SlimeBehaviourManger.instance.WalkOnTrap();
                }
            }
            else if (_data.cubeType == E_DUNGEON_CUBE_TYPE.EARTH && slimeMode == Item.ItemType.acid)
            {
                SlimeBehaviourManger.instance.GetNextStep(_data);

                SlimeBehaviourManger.instance.AcidMeltWall();
                Rotate();
            }
            else
            {
                Rotate();
            }
        }
    }