Exemplo n.º 1
0
    public bool OnCommand(InputManager.Command command, InputManager.Event eventType)
    {
        if (eventType != InputManager.Event.Up || halting)
        {
            return(true);
        }
        switch (command)
        {
        case InputManager.Command.Up:
        case InputManager.Command.Down:
        case InputManager.Command.Right:
        case InputManager.Command.Left:
        case InputManager.Command.UpLeft:
        case InputManager.Command.DownLeft:
        case InputManager.Command.DownRight:
        case InputManager.Command.UpRight:
            EightDir dir = EightDirExtensions.FromCommand(command);
            Global.Instance().Input.RemoveListener(this);
            unit.battler.StepOrAttack(dir, executeResult);
            break;

        case InputManager.Command.Wait:
            Global.Instance().Input.RemoveListener(this);
            executeResult.value = true;
            break;

        case InputManager.Command.Skill1:
        case InputManager.Command.Skill2:
        case InputManager.Command.Skill3:
        case InputManager.Command.Skill4:
        case InputManager.Command.Skill5:
        case InputManager.Command.Skill6:
            int skillNumber = Global.Instance().Input.CommandToNumber(command) - 1;
            if (skillNumber < pc.activeBook.spells.Count)
            {
                Skill skill = pc.activeBook.spells[skillNumber];
                if (unit.CanUse(skill))
                {
                    Global.Instance().Input.RemoveListener(this);
                    StartCoroutine(skill.PlaySkillRoutine(unit, executeResult));
                }
                else
                {
                    if (skill.costMP > 0)
                    {
                        narrator.Log(skill + " costs too much MP to cast.", true);
                    }
                    else
                    {
                        narrator.Log(skill + " is on cooldown.", true);
                    }
                }
            }
            break;

        case InputManager.Command.Examine:
        case InputManager.Command.Confirm:
            Global.Instance().Input.RemoveListener(this);
            StartCoroutine(ScanRoutine());
            rightDisplayEnabled = false;
            break;

        case InputManager.Command.Debug:
            StartCoroutine(spellEditor.ActivateRoutine(this, pc,
                                                       pc.GetComponent <MapEvent>().map.GetComponent <MapGenerator>().level));
            break;

        case InputManager.Command.Zoom:
            MapCamera cam = FindObjectOfType <MapCamera>();
            if (cam.target == pc.GetComponent <MapEvent3D>())
            {
                cam.target         = pc.battle.map.GetEventNamed("ZoomTarget").GetComponent <MapEvent3D>();
                cam.targetDistance = 100.0f;
            }
            else
            {
                cam.targetDistance = 25.0f;
                cam.target         = pc.GetComponent <MapEvent3D>();
            }
            break;
        }
        return(true);
    }