コード例 #1
0
    // Use this for initialization
    public override void Init()
    {
        CombatMoveEvent moveEvent = new CombatMoveEvent();
        moveEvent.Character = Character;

        m_GridManager = GameObject.FindObjectOfType<GridManager>();
        GridHex targetHex = m_GridManager.UniversalNPCTarget;
        GridHex currentHex = Character.transform.parent.gameObject.GetComponent<GridHex>();

        if (currentHex != targetHex && targetHex.AvailableSpace >= 2)
        {
            moveEvent.FinalTarget = Pathfinding.PathToHex(currentHex, targetHex)[1];
            OnQueueEvent(moveEvent);
        }

        /* // Random hex movement
        GridHex currentHex = Character.transform.parent.gameObject.GetComponent<GridHex>();
        List<GridHex> availableHexes = new List<GridHex>();
        for (int i = 0; i < 6; i++)
        {
            if (currentHex.AdjacentHexes[i] != null)
                availableHexes.Add(currentHex.AdjacentHexes[i]);
        }

        int targetHexIndex = Random.Range(0, availableHexes.Count - 1);
        moveEvent.FinalTarget = availableHexes[targetHexIndex];
        */
    }
コード例 #2
0
    public override void Process()
    {
        if (EventManager.SelectedHex != null)
        {
            Debug.Log("Selected HEX detected.");

            GridHex characterHex = Character.transform.parent.GetComponent<GridHex>();
            Debug.Log("Character Hex: " + characterHex);
            int distanceToHex;

            switch(Action)
            {
            case EventManager.UIAction.MOVE:
                distanceToHex = Pathfinding.PathToHex(characterHex, EventManager.SelectedHex, Character.Size).Count - 1;

                if (distanceToHex == 1)
                {
                    CombatMoveEvent moveEvent = new CombatMoveEvent();
                    moveEvent.Character = Character;
                    moveEvent.FinalTarget = EventManager.SelectedHex;
                    OnQueueEvent(moveEvent);
                }

                OnEventComplete();
                Debug.Log("PromptTargetEvent complete");
                break;
            case EventManager.UIAction.ATTACK:
                distanceToHex = Pathfinding.PathToHex(characterHex, EventManager.SelectedHex, 0).Count - 1;

                if (distanceToHex == 1)
                {
                    Debug.Log("CombatAttackEvent Triggered.");
                    CombatAttackEvent attackEvent = new CombatAttackEvent();
                    attackEvent.Character = Character;
                    attackEvent.Target = EventManager.SelectedHex;
                    OnQueueEvent(attackEvent);
                    Debug.Log("CombatAttackEvent Queued");
                }

                OnEventComplete();
                Debug.Log("PromptTargetEvent complete");
                break;
            }

            EventManager.SetSelectedHex(null);
            GetPanel("UI_PromptTarget").gameObject.SetActive(true);

            Debug.Log("EndProcess PromptTargetEvent()");
        }
    }