Esempio n. 1
0
    public GameDescriptor(Board board, Unit.OwnerEnum turn)
    {
        units      = new UnitInfo[BoardInfo.Row, BoardInfo.Col];
        grids      = new Board.GridState[BoardInfo.Row, BoardInfo.Col];
        playerInfo = new int[2][] { new int[(int)(Unit.TypeEnum.Void)], new int[(int)(Unit.TypeEnum.Void)] };

        for (int i = 0; i < BoardInfo.Row; i++)
        {
            for (int j = 0; j < BoardInfo.Col; j++)
            {
                units[i, j] = board.GetUnitInfo(new Position(i, j));
                if (units[i, j].type == Unit.TypeEnum.Bread)
                {
                    units[i, j].type = Unit.TypeEnum.Void;
                }
                grids[i, j] = board.GetGridState(new Position(i, j));
            }
        }

        for (Unit.TypeEnum type = Unit.TypeEnum.Bread; type < Unit.TypeEnum.Void; type++)
        {
            playerInfo[(int)Unit.OwnerEnum.Black][(int)type] = board.GetPlayerInfo(type, Unit.OwnerEnum.Black);
            playerInfo[(int)Unit.OwnerEnum.White][(int)type] = board.GetPlayerInfo(type, Unit.OwnerEnum.White);
        }

        restResource = board.RestBread;

        hasMove   = false;
        hasBuy    = false;
        this.turn = turn;
    }
Esempio n. 2
0
    public bool CanBuy(Unit.TypeEnum type, Unit.OwnerEnum owner)
    {
        if (hasBuy)
        {
            return(false);
        }
        if (!Unit.IsSoldier(type))
        {
            return(false);
        }
        if (playerInfo[(int)owner][(int)Unit.TypeEnum.Bread] < StorageInfo.CardCost[Storage.TypeToIndex(type)])
        {
            return(false);
        }
        if (GetInfo(BoardInfo.Base[(int)owner]).owner != Unit.OwnerEnum.None)
        {
            return(false);
        }
        if (type == Unit.TypeEnum.Boss && GetPlayerInfo(Unit.TypeEnum.Boss, turn) != 0)
        {
            return(false);
        }
        if (GetPlayerTotalCount(turn) - GetPlayerInfo(Unit.TypeEnum.Bread, turn) >= 5)
        {
            return(false);
        }

        return(true);
    }
Esempio n. 3
0
 private GameDescriptor(Unit.OwnerEnum turn)
 {
     this.turn  = turn;
     units      = new UnitInfo[BoardInfo.Row, BoardInfo.Col];
     grids      = new Board.GridState[BoardInfo.Row, BoardInfo.Col];
     playerInfo = new int[2][] { new int[(int)(Unit.TypeEnum.Void)], new int[(int)(Unit.TypeEnum.Void)] };
 }
Esempio n. 4
0
    public void BuyCardEffect(Unit card, Unit.OwnerEnum owner)
    {
        Vector3 position = Unit.PosToScreen(BoardInfo.Base[(int)owner]);

        iTween.MoveTo(card.gameObject, iTween.Hash("position", position, "time", 1f, "oncomplete", "OnAppearComplete", "oncompletetarget", card.gameObject));
        StartEffect(EffectType.MoveIn);
    }
Esempio n. 5
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();
    }
Esempio n. 6
0
    public GameDescriptor(Board board, Unit.OwnerEnum turn)
    {
        units = new UnitInfo[BoardInfo.Row, BoardInfo.Col];
        grids = new Board.GridState[BoardInfo.Row, BoardInfo.Col];
        playerInfo = new int[2][] { new int[(int)(Unit.TypeEnum.Void)], new int[(int)(Unit.TypeEnum.Void)]};

        for (int i = 0; i < BoardInfo.Row; i++)
            for (int j = 0; j < BoardInfo.Col; j++)
            {
                units[i, j] = board.GetUnitInfo(new Position(i, j));
                if (units[i, j].type == Unit.TypeEnum.Bread)
                    units[i, j].type = Unit.TypeEnum.Void;
                grids[i, j] = board.GetGridState(new Position(i, j));
            }

        for(Unit.TypeEnum type = Unit.TypeEnum.Bread; type < Unit.TypeEnum.Void; type++) {
           playerInfo[(int)Unit.OwnerEnum.Black][(int)type] = board.GetPlayerInfo(type,Unit.OwnerEnum.Black);
           playerInfo[(int)Unit.OwnerEnum.White][(int)type] = board.GetPlayerInfo(type,Unit.OwnerEnum.White);
        }

        restResource = board.RestBread;

        hasMove = false;
        hasBuy = false;
        this.turn = turn;
    }
Esempio n. 7
0
 private GameDescriptor(Unit.OwnerEnum turn)
 {
     this.turn = turn;
     units = new UnitInfo[BoardInfo.Row, BoardInfo.Col];
     grids = new Board.GridState[BoardInfo.Row, BoardInfo.Col];
     playerInfo = new int[2][] { new int[(int)(Unit.TypeEnum.Void)], new int[(int)(Unit.TypeEnum.Void)] };
 }
Esempio n. 8
0
    private static double EvalCard(GameDescriptor descriptor, Unit.OwnerEnum owner)
    {
        double value = 0;

        for (Unit.TypeEnum type = Unit.TypeEnum.Bread; type < Unit.TypeEnum.Void; type++)
        {
            int tmp = descriptor.GetPlayerInfo(type, owner);
            if (tmp <= 2)
            {
                value += CardEval[(int)type] * tmp;
            }
            else
            {
                value += CardEval[(int)type] * (tmp - 2) / 2 + CardEval[(int)type] * 2;
            }

            tmp = descriptor.GetPlayerInfo(type, Unit.Opposite(owner));
            if (tmp <= 2)
            {
                value -= CardEval[(int)type] * tmp;
            }
            else
            {
                value -= CardEval[(int)type] * (tmp - 2) / 2 + CardEval[(int)type] * 2;
            }
        }

        return(value);
    }
Esempio n. 9
0
 private void CollectBreadEffect(Unit bread, Unit.OwnerEnum owner)
 {
     bread.Owner = owner;
     // set
     bread.setSpriteId(Unit.GetSpriteIdByName("bread_static"));
     iTween.MoveTo(bread.gameObject, iTween.Hash("position", storage.GetCollectPoint(owner), "time", 1f, "oncomplete", "OnDisappearComplete", "oncompletetarget", bread.gameObject));
     StartEffect(EffectType.CollectBread);
 }
Esempio n. 10
0
    private static double EvalDanger(GameDescriptor descriptor, Unit.OwnerEnum owner)
    {
        double        value     = 0;
        List <double> equalList = new List <double>();

        for (int i = 0; i < BoardInfo.Row; i++)
        {
            for (int j = 0; j < BoardInfo.Col; j++)
            {
                UnitInfo src_info = descriptor.GetInfo(new Position(i, j));
                if (src_info.owner == owner)
                {
                    foreach (Position delta in Controller.MoveOffsetList)
                    {
                        Position tar = src_info.pos + delta;
                        if (tar.IsValid)
                        {
                            UnitInfo tar_info = descriptor.GetInfo(tar);
                            if (tar_info.owner == Unit.Opposite(src_info.owner))
                            {
                                if (src_info.type > tar_info.type)
                                {
                                    value += CardEval[(int)tar_info.type];
                                    if (src_info.type == Unit.TypeEnum.Bomb || tar_info.type == Unit.TypeEnum.Bomb)
                                    {
                                        value -= CardEval[(int)src_info.type];
                                    }
                                }
                                else if (src_info.type < tar_info.type)
                                {
                                    value -= CardEval[(int)src_info.type];
                                    if (src_info.type == Unit.TypeEnum.Bomb || tar_info.type == Unit.TypeEnum.Bomb)
                                    {
                                        value += CardEval[(int)src_info.type];
                                    }
                                }
                                else
                                {
                                    equalList.Add(CardEval[(int)(src_info.type)]);
                                }
                            }
                        }
                    }
                }
            }
        }
        if (equalList.Count > 0)
        {
            equalList.Sort();
            for (int i = 0; i < equalList.Count - 1; i++)
            {
                value -= equalList[i];
            }
            value += equalList[equalList.Count - 1];
        }

        return(value);
    }
Esempio n. 11
0
        private bool VerifyBoardFromProperties(Hashtable hashtable)
        {
            if (global::GameInfo.Instance.controller == null || !global::GameInfo.Instance.controller.IsStart)
            {
                return(true);
            }
            var board = global::GameInfo.Instance.board == null ? null : global::GameInfo.Instance.board.GenerateBoardSummary();

            if (board == null)
            {
                return(true);
            }

            Debug.Log(GetBoardDebugInfo(board));

            // Verify opponent resourceNum (not need for my own)
            var resourceKey = Consts.PropNames.GetPlayerResourceKey(Opponent.ID);

            if (hashtable.ContainsKey(resourceKey))
            {
                int resource = (int)hashtable[resourceKey];
                if (resource != global::GameInfo.Instance.storage.GetResourceNum(OpponentTurn))
                {
                    Debug.LogWarning(string.Format("[GameClient] resource unmatch, the local is {0}, remote is {1}.",
                                                   global::GameInfo.Instance.storage.GetResourceNum(OpponentTurn), resource));
                    return(false);
                }
            }

            // Verify board slots
            for (int i = 0; i < BoardInfo.Row; i++)
            {
                for (int j = 0; j < BoardInfo.Col; j++)
                {
                    var slotTypeKey  = Consts.PropNames.GetBoardSlotTypeKey(i, j);
                    var slotOwnerKey = Consts.PropNames.GetBoardSlotOwnerKey(i, j);
                    var slotBreadKey = Consts.PropNames.GetBoardSlotBreadKey(i, j);
                    if (hashtable.ContainsKey(slotTypeKey) && hashtable.ContainsKey(slotOwnerKey) && hashtable.ContainsKey(slotBreadKey))
                    {
                        Unit.TypeEnum  type     = (Unit.TypeEnum)hashtable[slotTypeKey];
                        Unit.OwnerEnum owner    = (Unit.OwnerEnum)hashtable[slotOwnerKey];
                        bool           hasBread = (bool)hashtable[slotBreadKey];
                        if (type != board[i, j].type || owner != board[i, j].owner || hasBread != board[i, j].hasBread)
                        {
                            Debug.LogWarning(string.Format("[GameClient] board unmatch at ({0}, {1}), the local is {2}, remote is {3}.",
                                                           i, j, board[i, j], new SlotInfo()
                            {
                                type = type, owner = owner, hasBread = hasBread
                            }));
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 12
0
    public int GetPlayerTotalCount(Unit.OwnerEnum owner)
    {
        int sum = 0;

        for (Unit.TypeEnum type = Unit.TypeEnum.Bread; type < Unit.TypeEnum.Void; type++)
        {
            sum += playerInfo[(int)owner][(int)type];
        }
        return(sum);
    }
Esempio n. 13
0
    /// <summary>
    /// Sum the total count of all kinds of unit of owner
    /// </summary>
    /// <param name="owner">the owner to query</param>
    /// <returns></returns>
    public int GetPlayerTotalCount(Unit.OwnerEnum owner)
    {
        int sum = 0;

        foreach (KeyValuePair <Unit.TypeEnum, int> single in playerInfo[(int)owner])
        {
            sum += single.Value;
        }
        return(sum);
    }
Esempio n. 14
0
 /// <summary>
 /// switch turn (black | white) to show speific shop info
 /// </summary>
 /// <param name="turn"></param>
 public void SwitchTurn(Unit.OwnerEnum turn, int turnNum)
 {
     m_hasbuy                       = false;
     m_turn                         = turn;
     PlayerBlack.IsMyTurn           = turn == Unit.OwnerEnum.Black;
     PlayerWhite.IsMyTurn           = turn != Unit.OwnerEnum.Black;
     NowPlayer.endTurn.Interactable = false;
     NowPlayer.cancel.Interactable  = false;
     status.SetTurn(turnNum);
 }
Esempio n. 15
0
 /// <summary>
 /// Create the shopping card list, to click & buy
 /// </summary>
 /// <param name="board">which board to create</param>
 /// <param name="owner">owner type</param>
 private void CreateCardList(GameObject board, Unit.OwnerEnum owner)
 {
     for (int i = 0; i < StorageInfo.CardTypeList.Length; i++)
     {
         Unit unit = CreateUnit(new UnitInfo(StorageInfo.CardTypeList[i], owner));
         unit.name                    = i.ToString();
         unit.transform.parent        = board.transform.Find("Unit");
         unit.transform.localPosition = StorageInfo.CardPosOffset[i];
     }
 }
Esempio n. 16
0
 private void CollectBreadEffect(Unit bread, Unit.OwnerEnum owner)
 {
     bread.Owner = owner;
     // set
     bread.setSprite(ArtManager.Instance.GetBattleCardGraphicsByName("bread"));
     iTween.MoveAdd(bread.gameObject, iTween.Hash("amount", new Vector3(0, BoardInfo.GridHeight, 0), "time", 0.5f, "easetype", iTween.EaseType.easeOutCubic, "oncomplete", (iTween.CallbackDelegate)(tween => {
         iTween.MoveTo(bread.gameObject, iTween.Hash("position", storage.GetCollectPoint(owner), "time", 1f, "oncomplete", "OnDisappearComplete", "oncompletetarget", bread.gameObject));
     })));
     StartEffect(EffectType.CollectBread);
 }
Esempio n. 17
0
 public int GetResourceNum(Unit.OwnerEnum owner)
 {
     if (owner == Unit.OwnerEnum.Black)
     {
         return(PlayerBlack.Resource);
     }
     else
     {
         return(PlayerWhite.Resource);
     }
 }
Esempio n. 18
0
 /// <summary>
 /// Get the position that the bread will fly into to show resource addition
 /// </summary>
 /// <param name="owner">to specific which board to fly into</param>
 /// <returns></returns>
 public Vector3 GetCollectPoint(Unit.OwnerEnum owner)
 {
     if (owner == Unit.OwnerEnum.Black)
     {
         return(board0.transform.position + StorageInfo.collectPointOffset);
     }
     else
     {
         return(board1.transform.position + StorageInfo.collectPointOffset);
     }
 }
Esempio n. 19
0
    private static double EvalSpecial(GameDescriptor descriptor, Unit.OwnerEnum owner)
    {
        double value = 0;

        if (descriptor.GetPlayerInfo(Unit.TypeEnum.Boss, Unit.Opposite(owner)) > 0)
        {
            value += descriptor.GetPlayerInfo(Unit.TypeEnum.Bomb, owner) > 0 ? 1 : 0;
        }
        if (descriptor.GetPlayerInfo(Unit.TypeEnum.Boss, owner) > 0)
        {
            value -= descriptor.GetPlayerInfo(Unit.TypeEnum.Bomb, Unit.Opposite(owner)) > 0 ? 1 : 0;
        }
        if (descriptor.RestResource > 0)
        {
            if (descriptor.GetPlayerInfo(Unit.TypeEnum.Scout, owner) == 0)
            {
                if (descriptor.GetPlayerInfo(Unit.TypeEnum.Bread, owner) == 0)
                {
                    value -= 4;
                }
                if (descriptor.RestResource >= 5)
                {
                    value -= 3;
                }
            }
            if (descriptor.GetPlayerInfo(Unit.TypeEnum.Scout, owner) >= 2 && descriptor.RestResource > 5)
            {
                value += 7;
            }
            if (descriptor.GetPlayerInfo(Unit.TypeEnum.Scout, Unit.Opposite(owner)) >= 2 && descriptor.RestResource > 5)
            {
                value -= 7;
            }

            if (descriptor.GetPlayerInfo(Unit.TypeEnum.Scout, Unit.Opposite(owner)) == 0)
            {
                if (descriptor.GetPlayerInfo(Unit.TypeEnum.Bread, Unit.Opposite(owner)) == 0)
                {
                    value += 4;
                }
                if (descriptor.RestResource >= 5)
                {
                    value += 3;
                }
            }
        }

        if (descriptor.RestResource == 0)
        {
            value -= descriptor.GetPlayerInfo(Unit.TypeEnum.Scout, owner) * 0.5;
            value += descriptor.GetPlayerInfo(Unit.TypeEnum.Scout, Unit.Opposite(owner)) * 0.5;
        }
        return(value);
    }
Esempio n. 20
0
 public bool NewTurn()
 {
     if (!hasMove)
     {
         return(false);
     }
     hasMove = false;
     hasBuy  = false;
     turn    = Unit.Opposite(turn);
     return(true);
 }
Esempio n. 21
0
 /// <summary>
 /// Get the count of specific type&owner card in this game
 /// </summary>
 /// <param name="type">the type to query</param>
 /// <param name="owner">the owner to query</param>
 /// <returns></returns>
 public int GetPlayerInfo(Unit.TypeEnum type, Unit.OwnerEnum owner)
 {
     if (playerInfo[(int)owner].ContainsKey(type))
     {
         return(playerInfo[(int)owner][type]);
     }
     else
     {
         return(0);
     }
 }
Esempio n. 22
0
    public bool Buy(Unit.TypeEnum type, Unit.OwnerEnum owner)
    {
        if (!CanBuy(type, owner))
        {
            return(false);
        }

        Put(BoardInfo.Base[(int)owner], new UnitInfo(type, owner));
        playerInfo[(int)owner][(int)Unit.TypeEnum.Bread] -= StorageInfo.CardCost[Storage.TypeToIndex(type)];
        hasBuy = true;

        return(true);
    }
Esempio n. 23
0
        public void Do(GameDescriptor descriptor)
        {
            restore_Turn = descriptor.Turn;

            if (buy != null && buy.status == BuyAction.Status.Before_Move)
            {
                buy.Do(descriptor);
            }
            move.Do(descriptor);
            if (buy != null && buy.status == BuyAction.Status.After_Move)
            {
                buy.Do(descriptor);
            }
        }
Esempio n. 24
0
    /// <summary>
    /// Do buy card action
    /// </summary>
    /// <param name="type"></param>
    /// <param name="owner"></param>
    /// <returns></returns>
    public bool BuyCard(Unit.TypeEnum type, Unit.OwnerEnum owner)
    {
        Unit      newCard = CreateUnit(new UnitInfo(BoardInfo.Base[(int)turn], type, owner));
        Transform card    = NowBoard.transform.Find("Unit").transform.Find(TypeToIndex(type).ToString());

        newCard.transform.position = card.transform.position;

        hasbuy = true;

        newCard.Owner = owner;
        GlobalInfo.Instance.board.ModifyPlayerInfo(Unit.TypeEnum.Bread, turn, -StorageInfo.CardCost[TypeToIndex(newCard.Type)]);
        GlobalInfo.Instance.controller.BuyCardEffect(newCard, owner);

        return(true);
    }
Esempio n. 25
0
 public Sprite GetFlagSprite(Unit.OwnerEnum owner)
 {
     if (owner == Unit.OwnerEnum.Black)
     {
         return(blackFlag);
     }
     else if (owner == Unit.OwnerEnum.White)
     {
         return(whiteFlag);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 26
0
 public static Unit.OwnerEnum Opposite(Unit.OwnerEnum owner)
 {
     if (owner == Unit.OwnerEnum.Black)
     {
         return(Unit.OwnerEnum.White);
     }
     else if (owner == Unit.OwnerEnum.White)
     {
         return(Unit.OwnerEnum.Black);
     }
     else
     {
         return(Unit.OwnerEnum.None);
     }
 }
Esempio n. 27
0
 /// <summary>
 /// switch turn (black | white) to show speific shop info
 /// </summary>
 /// <param name="turn"></param>
 public void SwitchTurn(Unit.OwnerEnum turn)
 {
     hasbuy    = false;
     this.turn = turn;
     if (turn == Unit.OwnerEnum.Black)
     {
         board0.transform.Find("Unit").gameObject.SetActive(true);
         board1.transform.Find("Unit").gameObject.SetActive(false);
     }
     else
     {
         board0.transform.Find("Unit").gameObject.SetActive(false);
         board1.transform.Find("Unit").gameObject.SetActive(true);
     }
 }
Esempio n. 28
0
 public static double EvaluateResult(Ruler.GameResult result, Unit.OwnerEnum owner)
 {
     if (result == Ruler.GameResult.Black_Win)
     {
         return(owner == Unit.OwnerEnum.Black ? MaxValue : -MaxValue);
     }
     else if (result == Ruler.GameResult.White_Win)
     {
         return(owner == Unit.OwnerEnum.White ? MaxValue : -MaxValue);
     }
     else if (result == Ruler.GameResult.Draw)
     {
         return(0);
     }
     return(0);
 }
Esempio n. 29
0
    /// <summary>
    /// Do buy card action
    /// </summary>
    /// <param name="type"></param>
    /// <param name="owner"></param>
    /// <returns></returns>
    public bool BuyCard(Unit.TypeEnum type, Unit.OwnerEnum owner)
    {
        Unit      newCard = GameInfo.Instance.board.InstantiateUnit(new UnitInfo(BoardInfo.Base[(int)m_turn], type, owner));
        Transform card    = NowPlayer.cards[TypeToIndex(type)].transform;

        newCard.transform.position = UI2WorldPosition(card.transform.position);

        m_hasbuy = true;

        newCard.Owner      = owner;
        newCard.CardActive = true;
        GameInfo.Instance.board.ModifyPlayerInfo(Unit.TypeEnum.Bread, m_turn, -StorageInfo.CardCost[TypeToIndex(newCard.Type)]);
        GameInfo.Instance.controller.BuyCardEffect(newCard, owner);

        return(true);
    }
Esempio n. 30
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();
 }
Esempio n. 31
0
 public void SwitchTurn(Unit.OwnerEnum owner)
 {
     foreach (var unit in boardUnit)
     {
         if (unit == null)
         {
             continue;
         }
         if (unit.Owner == owner)
         {
             unit.CardActive = true;
         }
         else
         {
             unit.CardActive = false;
         }
     }
 }
Esempio n. 32
0
    public void NewGame(Unit.OwnerEnum owner)
    {
        m_ownerType = owner;

        Resource        = 0;
        playerName.text =
            owner == Unit.OwnerEnum.Black
            ? GameInfo.Instance.blackPlayerName
            : GameInfo.Instance.whitePlayerName;

        flag.sprite = ArtManager.Instance.GetFlagSprite(owner);
        flag.SetNativeSize();

        for (int i = 0; i < cards.Length; i++)
        {
            var image = cards[i].GetComponent <Image>();
            image.sprite = ArtManager.Instance.GetStorageCardSprite(StorageInfo.CardTypeList[i], owner);
        }
    }
Esempio n. 33
0
 public void NextTurn()
 {
     if (state == MainState.Wait || state == MainState.AI_Running)
     {
         Ruler.GameResult result = Ruler.CheckGame(board);
         if (result == Ruler.GameResult.NotYet)
         {
             turn = Unit.Opposite(turn);
             state = MainState.Move;
             NewTurn();
         }
         else
         {
             state = MainState.Over;
             this.result = result;
             OnGameOver();
         }
     }
 }
Esempio n. 34
0
    public void SetMoveHint(Unit source)
    {
        ClearHints();
        this.owner = source.Owner;
        this.source = source;
        source.Sprite.SetColor(0.5f);
        source.Focus = true;

        foreach (Position offset in Controller.MoveOffsetList)
        {
            Position newPos = source.Pos+offset;
            if (newPos.IsValid && GlobalInfo.Instance.board.GetUnitOwner(newPos) != owner)
            {
                Unit unit = GlobalInfo.Instance.storage.CreateUnit(new UnitInfo(source.Pos + offset, Unit.TypeEnum.Tile));
                SetHintStyle(unit);
                units.Add(unit);
            }
        }
        type = HintType.Move;

        isShow = true;
    }
Esempio n. 35
0
 public bool NewTurn()
 {
     if (!hasMove)
         return false;
     hasMove = false;
     hasBuy = false;
     turn = Unit.Opposite(turn);
     return true;
 }
Esempio n. 36
0
    public void Do(GameDescriptor descriptor)
    {
        restore_Turn = descriptor.Turn;

        if (buy != null && buy.status == BuyAction.Status.Before_Move)
            buy.Do(descriptor);
        move.Do(descriptor);
        if (buy != null && buy.status == BuyAction.Status.After_Move)
            buy.Do(descriptor);
    }
Esempio n. 37
0
 public UnitInfo(Position pos, Unit.TypeEnum type, Unit.OwnerEnum owner = Unit.OwnerEnum.None)
 {
     this.pos = pos;
     this.type = type;
     this.owner = owner;
 }
Esempio n. 38
0
 public UnitInfo(Unit.TypeEnum type, Unit.OwnerEnum owner = Unit.OwnerEnum.None)
 {
     this.pos = new Position();
     this.type = type;
     this.owner = owner;
 }
Esempio n. 39
0
    private void NewGame(GameMode gameMode)
    {
        this.gameMode = gameMode;

        lastMove = null;
        moveState = MoveState.Idle;
        ClearEffect();
        hint.ClearHints();
        board.NewGame();
        storage.NewGame();
        state = MainState.Ready;
        turn = Unit.OwnerEnum.Black;
        resultSprite.gameObject.SetActive(false);
        turnOverButton.gameObject.SetActive(false);

        if (gameMode != GameMode.Normal)
            InitAI();
        logger.Text = "";
        logger.State = UILogger.StateEnum.Normal;
    }
Esempio n. 40
0
 /// <summary>
 /// switch turn (black | white) to show speific shop info
 /// </summary>
 /// <param name="turn"></param>
 public void SwitchTurn(Unit.OwnerEnum turn)
 {
     hasbuy = false;
     this.turn = turn;
     if (turn == Unit.OwnerEnum.Black)
     {
         board0.transform.Find("Unit").gameObject.SetActive(true);
         board1.transform.Find("Unit").gameObject.SetActive(false);
     }
     else
     {
         board0.transform.Find("Unit").gameObject.SetActive(false);
         board1.transform.Find("Unit").gameObject.SetActive(true);
     }
 }