Ejemplo n.º 1
0
        public void RandomSetTreasure(GameTypes.PlayerType playerType)
        {
            var player = GetPlayer(playerType);
            int setNum = 0;
            var idToCellPositionDict = new Dictionary <long, CellPosition>();

            while (setNum < TREASURE_NUM)
            {
                var r = new System.Random();
                var x = r.Next(CellManager.CELL_MAX_NUM);
                r = new System.Random();
                var y      = r.Next(CellManager.CELL_MAX_NUM);
                var canSet = true;
                foreach (var cellPos in idToCellPositionDict.Values)
                {
                    if (cellPos.X == x && cellPos.Y == y)
                    {
                        canSet = false;
                        break;
                    }
                }
                if (!canSet)
                {
                    continue;
                }

                idToCellPositionDict.Add(LifeUniqueId.GetUniqueId(), new CellPosition(x, y));
                setNum++;
            }

            player.SetTreasures(idToCellPositionDict);
            Locator.CellManager.SetTreasures(playerType, idToCellPositionDict);
        }
Ejemplo n.º 2
0
 public void SetTreasures(GameTypes.PlayerType playerType, Dictionary <long, CellPosition> dict)
 {
     foreach (var pos in dict)
     {
         SetTreasure(playerType, pos.Key, pos.Value);
     }
 }
Ejemplo n.º 3
0
        public Block.MaterialType PlayerTypeToMaterialType(GameTypes.PlayerType playerType)
        {
            var materialType = playerType == GameTypes.PlayerType.SELF ?
                               Block.MaterialType.RED : Block.MaterialType.BLUE;

            return(materialType);
        }
Ejemplo n.º 4
0
 public PlayerModel(GameTypes.PlayerType playerType, List <BlockModel> blockModels)
 {
     PlayerType = playerType;
     foreach (var block in blockModels)
     {
         OwnBlockDict.Add(block.Id, block);
     }
 }
Ejemplo n.º 5
0
        public void SetTurn(GameTypes.PlayerType playerType)
        {
            var b = playerType == GameTypes.PlayerType.SELF;

            IsSelfTurn  = b;
            IsEnemyTurn = !b;
            Locator.OutGamePresenter.PlayerUIPresenter.UpdateEnableHandle(GameTypes.PlayerType.SELF, IsSelfTurn);
            Locator.OutGamePresenter.PlayerUIPresenter.UpdateEnableHandle(GameTypes.PlayerType.ENEMY, IsEnemyTurn);
            var p = Locator.PlayerManager.GetPlayer(GameTypes.PlayerType.SELF);
        }
Ejemplo n.º 6
0
        private void _Initialize(GameTypes.PlayerType playerType, Dictionary <long, CellPosition> lifes)
        {
            var playerModel = new PlayerModel(playerType, _GetInitialBlocks());

            _playerModelDict[playerType] = playerModel;
            var player = GetPlayer(playerType);

            Locator.CellManager.SetTreasures(playerType, lifes);
            player.SetTreasures(lifes);
        }
Ejemplo n.º 7
0
 public void FinishTurn(GameTypes.PlayerType playerType)
 {
     if (playerType == GameTypes.PlayerType.SELF)
     {
         SetTurn(GameTypes.PlayerType.ENEMY);
     }
     else if (playerType == GameTypes.PlayerType.ENEMY)
     {
         SetTurn(GameTypes.PlayerType.SELF);
     }
 }
Ejemplo n.º 8
0
 public void UpdateEnableHandle(GameTypes.PlayerType playerType, bool enable)
 {
     if (playerType == GameTypes.PlayerType.SELF)
     {
         _selfPlayer.UpdateHandleBoard(enable);
     }
     else
     {
         _enemyPlayer.UpdateHandleBoard(enable);
     }
 }
Ejemplo n.º 9
0
        public void PutBlock(GameTypes.PlayerType playerType, BlockModel blockModel)
        {
            var positions     = new List <Vector3>();
            var occupiedCells = blockModel.OccupyCells;

            foreach (var cell in occupiedCells)
            {
                positions.Add(new Vector3(cell.X, BLOCK_POS_Y, cell.Y));
            }
            var materialType = PlayerTypeToMaterialType(playerType);

            Block.Create(materialType, positions, _blockTransform);
        }
Ejemplo n.º 10
0
 public void PutTreasure(GameTypes.PlayerType playerType, long id)
 {
     if (playerType == GameTypes.PlayerType.SELF)
     {
         HasSelfTreasure = true;
         SelfTreasureId  = id;
     }
     if (playerType == GameTypes.PlayerType.ENEMY)
     {
         HasEnemyTreasure = true;
         EnemyTreasureId  = id;
     }
 }
Ejemplo n.º 11
0
        public static bool PutBlock(GameTypes.PlayerType playerType, long id, CellModel cellModel)
        {
            if (cellModel == null)
            {
                return(false);
            }
            var player = Locator.PlayerManager.GetPlayer(playerType);
            var block  = player.PickBlock(id);

            if (!block.CanPut(cellModel.Position))
            {
                return(false);
            }
            PutBlock(player, block, cellModel.Position);
            return(true);
        }
Ejemplo n.º 12
0
 public PlayerModel GetPlayer(GameTypes.PlayerType playerType)
 {
     return(_playerModelDict[playerType]);
 }
Ejemplo n.º 13
0
        public void SetTreasure(GameTypes.PlayerType playerType, long id, CellPosition pos)
        {
            var cellModel = GetCell(pos.X, pos.Y);

            cellModel.PutTreasure(playerType, id);
        }