コード例 #1
0
    public (int, int) GetDirection(Command.MoveCommand direction, int currentPosition, int currentPosCamera)
    {
        if (direction == Command.MoveCommand.Right)
        {
            currentPosition += 10;
            currentPosCamera = 90;
        }

        if (direction == Command.MoveCommand.Left)
        {
            currentPosition -= 10;
            currentPosCamera = -90;
        }

        if (direction == Command.MoveCommand.Up)
        {
            currentPosition += 1;
            currentPosCamera = 0;
        }

        if (direction == Command.MoveCommand.Down)
        {
            currentPosition -= 1;
            currentPosCamera = 180;
        }

        return(currentPosition, currentPosCamera);
    }
コード例 #2
0
 private void btnAddMoveCommand(Command.MoveCommand direction)
 {
     BoardManager.Instance.AddCommand(direction, (guid) =>
     {
         InstantiateCommands(guid, direction);
         LayoutRebuilder.ForceRebuildLayoutImmediate(PnlCommandsSelected.GetComponent <RectTransform>());
     });
 }
コード例 #3
0
    public IEnumerator Move(Command.MoveCommand command)
    {
        bool stopMove = false;

        (currentPosition, posCamera) = BoardManager.Instance.Board.GetDirection(command, currentPosition, posCamera);

        (float x, float y, float z) = BoardManager.Instance.Board.GetXYZPosition(currentPosition, () =>
        {
            BoardManager.Instance.SetGameOver();
            stopMove = true;
        });

        if (stopMove)
        {
            yield break;
        }

        Vector3 currentPos = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z);

        Vector3 currentRot    = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, 0);
        Vector3 newCurrentRot = new Vector3(transform.localEulerAngles.x, posCamera, 0);

        float t = 0f;

        if (currentRot.y != newCurrentRot.y)
        {
            while (t < 1f)
            {
                t += 1 * Time.deltaTime;
                transform.localEulerAngles = Vector3.Lerp(currentRot, newCurrentRot, Mathf.SmoothStep(0f, 1f, t));
                yield return(null);
            }
        }

        t = 0f;
        while (t < 1f)
        {
            t += speed * Time.deltaTime;
            transform.localPosition = Vector3.Lerp(currentPos, new Vector3(x, GetHeight(), z), Mathf.SmoothStep(0f, 1f, t));
            yield return(null);
        }
    }
コード例 #4
0
    public void AddCommand(Command.MoveCommand command, Action <Guid> callbackPos)
    {
        if (Utils.Enum <Command.MoveCommand> .IsDefined(command))
        {
            Guid guid = Guid.NewGuid();

            if (!looping)
            {
                Commands.AddCommand(guid, Pin.Move(command));
            }

            if (looping)
            {
                for (int i = 0; i < iteration; i++)
                {
                    guid = Guid.NewGuid();
                    loopCommands.Add(guid, Pin.Move(command));
                }
            }

            callbackPos(guid);
            return;
        }
    }
コード例 #5
0
    private void InstantiateCommands(Guid guid, Command.MoveCommand direction)
    {
        CommandsSelected command = Instantiate(CommandsSelectedPrefab, (looping) ? CurrentPnlLoop : PnlCommandsSelected);

        command.SetInfo(direction.ToString(), ColorsCommands[(int)direction], guid);
    }