Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!ModelController.inModelMode)
        {
            dragTimer = 0;
            dragging  = false;
            return;
        }

        bool clicked = Input.GetMouseButton(0);

        if (!dragging && clicked && Cursor.hovered && (Cursor.hovered.standingUnit == unit || Cursor.hovered.standingModel == model))
        {
            if (ModelController.unit != unit)
            {
                ModelController.unit = unit;
                CursorController.ShowMoveCells();
                Menu.Refresh();
            }
        }

        if (clicked)
        {
            dragTimer += Time.deltaTime;
            dragging   = dragging || dragTimer >= minDragTimer && Cursor.hovered && Cursor.hovered.standingModel == model;
            if (dragging && !selected)
            {
                DisplayModel(model);
            }
        }
        else
        {
            selected  = false;
            dragTimer = 0;
            dragging  = false;

            MoveModelTowardCursor(modelCursor);
        }

        if (dragging)
        {
            CursorController.Cancel();

            Cursor hoveredCursor = Cursor.hovered;

            if (hoveredCursor)
            {
                MoveModelTowardCursor(hoveredCursor);

                if (Cursor.hovered.standingModel == null)
                {
                    SetModelCursor(Cursor.hovered);
                }
                else if (Cursor.hovered.standingModel != model)
                {
                    SetModelCursor(lastGoodModelCursor);
                }
            }
        }
    }
Ejemplo n.º 2
0
 public static void PickAction(Unit unit, int actionIndex)
 {
     CursorController.Cancel();
     SetState(State.PickTarget);
     selectedActionIndex = actionIndex;
     CursorController.ShowActionCursors(unit, actionIndex);
 }
Ejemplo n.º 3
0
    public void Cancel()
    {
        if (operating || !active)
        {
            return;
        }

        controller.Cancel();
    }
Ejemplo n.º 4
0
    void Update()
    {
        if (canLaunch && !launched && Unit.current)
        {
            Launch();
        }

        if (InputController.InputCancel())
        {
            CursorController.Cancel();
        }

        if (refreshView)
        {
            RefreshPlayerView();
            refreshView = false;
        }

        if (playingTurn)
        {
            playingTurnTimer += Time.deltaTime;

            if (playingTurnTimer > 2)
            {
                NextTurnLoop(Player.OldestTurn());
                playingTurnTimer = 0;
            }
        }

        if (Unit.current)
        {
            nextTurnMenu.transform.Find("Panel").Find("PlayerInfo").GetComponent <Text>().text = "Currently Player " + (Unit.current.playerIndex + 1) + "'s turn";
            nextTurnMenu.transform.Find("Panel").Find("NextTurn").gameObject.SetActive(!playingTurn && Player.OldestTurn() != null && Player.OldestTurn().finished);
            nextTurnMenu.GetComponent <Canvas>().enabled = Unit.current.playerIndex != Player.player.playerIndex;
        }
        else
        {
            nextTurnMenu.GetComponent <Canvas>().enabled = false;
        }
    }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Awake()
    {
        // register movement key
        KeyInput.Default.MoveVertical.performed   += ctx => MoveButtonClicked(new Vector2Int(0, (int)ctx.ReadValue <float>()));
        KeyInput.Default.MoveHorizontal.performed += ctx => MoveButtonClicked(new Vector2Int((int)ctx.ReadValue <float>(), 0));
        KeyInput.Default.MoveVertical.canceled    += _ => MoveButtonReleased();
        KeyInput.Default.MoveHorizontal.canceled  += _ => MoveButtonReleased();
        if (!debugMode)
        {
            KeyInput.Default.Confirm.performed += _ => controller.Confirm();
        }
        else
        {
            KeyInput.Default.DebugConfirm.performed += _ => controller.Confirm();  //c for confirm
        }
        KeyInput.Default.Cancel.performed += _ => controller.Cancel();

        if (!controlOn)
        {
            KeyInput.Disable();
        }

        controller = GetComponent <CursorController>();
    }
Ejemplo n.º 6
0
 public static void FinishStanceChange()
 {
     CursorController.Cancel();
     CursorController.ShowMoveCells();
     Menu.Refresh();
 }