Пример #1
0
    float _GetDirectionAngle(LastMoveInfo lastMove)
    {
        float angle;

        if (lastMove.from.R == lastMove.to.R)
        {
            if (lastMove.from.C + 1 == lastMove.to.C)
            {
                angle = 0f;
            }
            else
            {
                angle = 180f;
            }
        }
        else if (lastMove.from.R + 1 == lastMove.to.R)
        {
            angle = 90f;
        }
        else
        {
            angle = -90f;
        }
        if (GameInfo.Instance.ShouldUpsidedown)
        {
            angle += 180;
        }
        return(angle);
    }
Пример #2
0
    private void NewGame(GameMode gameMode)
    {
        this.gameMode = gameMode;
        GameInfo.Instance.NewGame();

        lastMove = null;
        lastMoveHint.UnFocus();
        moveState = MoveState.Idle;
        ClearEffect();
        hint.ClearHints();

        if (gameMode == GameMode.Agent)
        {
            InitAgent();
        }

        board.NewGame();
        storage.NewGame();
        switchModeUI.NewGame();
        state   = MainState.Ready;
        turn    = Unit.OwnerEnum.Black;
        turnNum = 0;
        if (resultUI != null)
        {
            resultUI.gameObject.SetActive(false);
        }
        storage.IsEndTurnValid = false;
        storage.IsCancelValid  = false;

        _actionLogs.Clear();
        _actionsCurrentTurn.Clear();

        statusUI.ShowAction();
    }
Пример #3
0
    private void MoveEffect(Unit src, Position pos)
    {
        var originPos = src.Pos;

        board.Pick(src.Pos);
        src.Pos = pos;
        Vector2 targetPos = Unit.PosToScreen(pos);

        iTween.MoveTo(src.gameObject, iTween.Hash("position", new Vector3(targetPos.x, targetPos.y, 0), "time", 0.2f, "oncomplete", "OnMoveComplete", "oncompletetarget", src.gameObject));
        StartEffect(EffectType.Move);

        if (lastMove != null)
        {
            lastMoveHint.UnFocus();
        }
        lastMove = new LastMoveInfo(originPos, pos);
    }
Пример #4
0
 public void RollbackGame()
 {
     if (effectNum != 0 && !(state == MainState.Move || state == MainState.Wait))
     {
         return;
     }
     hint.ClearHints();
     board.RollbackGame(cache);
     storage.RollbackGame(cache);
     lastMove = cache.lastMove;
     lastMoveHint.Focus(lastMove);
     turn      = cache.descriptor.Turn;
     turnNum   = cache.turnNum;
     state     = MainState.Move;
     moveState = MoveState.Idle;
     _actionsCurrentTurn.Clear();
 }
Пример #5
0
    public void Focus(LastMoveInfo lastMove)
    {
        if (lastMove == null)
        {
            UnFocus();
            return;
        }
        transform.position = Unit.PosToScreen(lastMove.from);
        gameObject.SetActive(true);

        directionHint.transform.rotation = Quaternion.Euler(new Vector3(0, 0, _GetDirectionAngle(lastMove)));
        var offset = _GetTweenOffset(lastMove);

        directionHint.transform.localPosition = -offset * .5f;
        iTween.MoveTo(directionHint.gameObject,
                      iTween.Hash(
                          "position", offset * .5f,
                          "time", tweenTime,
                          "looptype", iTween.LoopType.pingPong,
                          "easetype", iTween.EaseType.easeOutCubic,
                          "islocal", true));
    }
Пример #6
0
 public GameCache(Board board, Unit.OwnerEnum turn, int turnNum, LastMoveInfo lastMove)
 {
     descriptor    = new GameDescriptor(board, turn);
     this.turnNum  = turnNum;
     this.lastMove = lastMove;
 }
Пример #7
0
    Vector3 _GetTweenOffset(LastMoveInfo lastMove)
    {
        var offset = lastMove.GetOffset() * tweenDistance;

        return(offset);
    }