示例#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);
                }
            }
        }
    }
示例#2
0
 public static void PickAction(Unit unit, int actionIndex)
 {
     CursorController.Cancel();
     SetState(State.PickTarget);
     selectedActionIndex = actionIndex;
     CursorController.ShowActionCursors(unit, actionIndex);
 }
示例#3
0
    public void Cancel()
    {
        if (operating || !active)
        {
            return;
        }

        controller.Cancel();
    }
示例#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;
        }
    }
示例#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>();
    }
示例#6
0
 public static void FinishStanceChange()
 {
     CursorController.Cancel();
     CursorController.ShowMoveCells();
     Menu.Refresh();
 }