Exemple #1
0
    void OnTouchEnd(int fingerId, Vector3 tapPosition, RaycastHit hitInfo)
    {
        if (myFingerId == fingerId)
        {
            myFingerId = InputManager.InactiveTouch;

            switch (mySquadState)
            {
            case Squad.SquadState.Ready:
                break;

            case Squad.SquadState.OnTapped:
                if (hitInfo.transform != null)
                {
                    if (hitInfo.transform == transform)
                    {
                        mySquadState = Squad.SquadState.Selected;
                        islandGrid.ResetPlayerNodeValues();
                        currentNode.PlayerVisited = 0;
                        islandGrid.SetPlayerNodeDistances(currentNode);

                        OnSquadSelected?.Invoke(this);
                        AnimateSquadSelected();
                    }
                }
                break;

            case Squad.SquadState.Selected:
                if (path.Count > 0)
                {
                    targetNode = PathfindingNode;
                    MoveToTarget(targetNode);

                    OnSquadDeselected?.Invoke(this);
                    AnimateSquadDeselected();
                }
                break;

            case Squad.SquadState.OnTappedSelected:
                if (hitInfo.transform != null)
                {
                    if (hitInfo.transform == transform)
                    {
                        mySquadState = Squad.SquadState.Ready;
                        path.Clear();
                        targetNode = null;

                        OnSquadDeselected?.Invoke(this);
                        AnimateSquadDeselected();
                    }
                }
                break;

            case Squad.SquadState.Moving:
            case Squad.SquadState.PendingUnitsReady:
                break;
            }
            AnimateSquadPath();
        }
    }
Exemple #2
0
    void Squad_OnSquadSelected(Squad squad)
    {
        if (squad != this)
        {
            switch (mySquadState)
            {
            case Squad.SquadState.Ready:
                break;

            case Squad.SquadState.OnTapped:
                mySquadState = SquadState.Ready;
                break;

            case Squad.SquadState.Selected:
            case Squad.SquadState.OnTappedSelected:
                if (path.Count > 0)
                {
                    targetNode = PathfindingNode;
                    MoveToTarget(targetNode);
                }
                else
                {
                    mySquadState = Squad.SquadState.Ready;
                }

                myFingerId = InputManager.InactiveTouch;
                OnSquadDeselected?.Invoke(this);
                AnimateSquadDeselected();
                break;

            case Squad.SquadState.Moving:
            case Squad.SquadState.PendingUnitsReady:
                break;
            }
        }
    }