Example #1
0
        /// <summary>
        /// another dfs, kms
        /// </summary>
        /// <param name="start"></param>
        /// <param name="team"></param>
        /// <returns></returns>
        public BoardEntity NearestBoardEntity(Position start, Team?team, BoardEntity ignore = null, bool includeStealth = false)
        {
            Queue <Tile>   tiles        = new Queue <Tile>();
            HashSet <Tile> visitedTiles = new HashSet <Tile>();

            tiles.Enqueue(GetTile(start));
            while (tiles.Count > 0)
            {
                Tile        t         = tiles.Dequeue();
                List <Tile> neighbors = GetTilesNoDiag(t.Position);
                foreach (Tile newTile in neighbors)
                {
                    if (!visitedTiles.Contains(newTile))
                    {
                        if (newTile.BoardEntity != null && ((team == null || newTile.BoardEntity.Team == team) &&
                                                            newTile.BoardEntity != ignore) && !((CharacterBoardEntity)newTile.BoardEntity).IsStealthed())
                        {
                            return(newTile.BoardEntity);
                        }
                        visitedTiles.Add(newTile);
                        tiles.Enqueue(newTile);
                    }
                }
            }

            return(null);
        }
Example #2
0
    public bool ComparePosition(BoardEntity boardEntity)
    {
        var v1 = new Vector3(boardEntity.Position.X, boardEntity.Position.Y, boardEntity.Position.Z);
        var v2 = new Vector3(Position.X, Position.Y, Position.Z);

        return(v1.Equals(v2));
    }
Example #3
0
    public override async UniTask Activate(CardController card, PlayerEntity player, BoardEntity board)
    {
        GameManager.Instance.isChoicePrompting = true;

        //建物カード建築
        GameManager.Instance.isBuilding = true;
        Debug.Log("Activate_10_carpentry begin");


        //建築完了まで待つ
        //Slotcontrollerが確認
        await UniTask.WaitUntil(() => !GameManager.Instance.isBuilding);

        //コスト分カードを捨てる
        Debug.Log("手札を捨ててください");
        GameManager.Instance.isDiscarding = true;

        await player.hands.StartDiscard();

        //Trashcontrollerが確認
        await UniTask.WaitUntil(() => !GameManager.Instance.isDiscarding);


        Debug.Log("Activate_10_carpentry done");
        GameManager.Instance.isChoicePrompting = false;
    }
Example #4
0
        private void EvaluateStats(BoardEntity boardEntity, Stats previewStats = null, SkillReport skillReport = null)
        {
            foreach (StatType type in displayOrder)
            {
                string text = boardEntity.Stats.StatToString(type);
                if (previewStats != null)
                {
                    Color?col = GetStatChangeColor(boardEntity, previewStats, type);
                    if (col != null)
                    {
                        text += ColorText((Color)col, " -> " + previewStats.StatValueString(type));
                    }
                }
                if (skillReport != null)
                {
                    List <StatModifier> mods = new List <StatModifier>();
                    foreach (Buff buff in skillReport.Buffs)
                    {
                        mods.AddRange(buff.GetStatModifiers());
                    }
                    int value = skillReport.targetAfter.GetDefaultStat(type, mods).Value;
                    skillReport.targetAfter.modifiers = mods;

                    Color?col = GetStatChangeColor(boardEntity, skillReport.targetAfter, type);
                    if (col != null)
                    {
                        text += ColorText((Color)col, " -> " + skillReport.targetAfter.StatValueString(type));
                    }
                    skillReport.targetAfter.modifiers = new List <StatModifier>();
                }
                AddText(text, Stats.StatTypeToTooltip(type));
            }
            AddRangeText(boardEntity);
        }
Example #5
0
        public void UpdateProfile(BoardEntity boardEntity, Stats previewStats = null, SkillReport skillReport = null)
        {
            if (currentBoardEntity != null)
            {
                currentBoardEntity.updateStatHandler -= RefreshProfile;
            }
            currentBoardEntity = boardEntity;
            if (boardEntity == null)
            {
                gameObject.SetActive(false);
            }
            else
            {
                currentBoardEntity.updateStatHandler += RefreshProfile;
                gameObject.SetActive(true);
                processBoardEntity(boardEntity, previewStats, skillReport);
            }

            CharacterBoardEntity characterBoardEntity = Core.Instance.convert(boardEntity);

            if (characterBoardEntity != null && characterBoardEntity.Ka != null)
            {
                kaProfile.SetActive(true);
                kaProfile.GetComponent <Image>().sprite = characterBoardEntity.Ka.ProfilePic;
            }
            else
            {
                kaProfile.SetActive(false);
            }
        }
Example #6
0
 private void processBoardEntity(BoardEntity boardEntity, Stats previewStats = null, SkillReport skillreport = null)
 {
     if (previewStats != null)
     {
         apDisplay.DisplayAp(boardEntity, previewStats);
     }
     else
     {
         apDisplay.DisplayAp(boardEntity);
     }
     UpdateProfilePic(boardEntity.ProfileImage);
     foreach (GameObject g in texts)
     {
         Destroy(g);
     }
     foreach (GameObject g in passives)
     {
         Destroy(g);
     }
     AddTitle(boardEntity.Name);
     EvaluateStats(boardEntity, previewStats, skillreport);
     if (showPassives)
     {
         if (boardEntity is CharacterBoardEntity)
         {
             AddPassives(((CharacterBoardEntity)boardEntity).Passives);
         }
     }
 }
Example #7
0
 public static Board ToTable(this BoardEntity board)
 {
     return(new Board {
         BoardId = board.BoardId,
         Name = board.Name
     });
 }
Example #8
0
        public async void GivenCommandWhenTaskExistsThenMapDtoToEntity()
        {
            // Arrange
            var boardEntity = new BoardEntity {
                Slug = "board-name"
            };
            var boardColumnEntity = new BoardColumnEntity
            {
                Slug        = "board-column-name",
                BoardEntity = boardEntity
            };

            SetupCommandHandler(new List <BoardEntity> {
                boardEntity
            }, new List <BoardColumnEntity> {
                boardColumnEntity
            });

            var command = new UpdateBoardColumnCommand
            {
                BoardSlug       = "board-name",
                BoardColumnSlug = "board-column-name",
                BoardColumn     = new BoardColumn
                {
                    Slug = "board-column-name"
                }
            };

            // Act
            await handler.Handle(command, CancellationToken.None);

            // Assert
            mockMappingService.Verify(x => x.Map(It.IsAny <BoardColumn>(), It.IsAny <BoardColumnEntity>()), Times.Once);
        }
    public async UniTask <bool> Activate(CardController card, PlayerEntity player, BoardEntity board)
    {
        //manaが足りているかチェック
        //もしくはキャンセル処理を可能にする

        if (card.model.greenToActivate.Value > board.mana.model.greenMana.Value)
        {
            Debug.Log("ActivateCardEffect failed: not eonugh mana");
            return(false);
        }
        else if (card.model.blueToActivate.Value > board.mana.model.blueMana.Value)
        {
            Debug.Log("ActivateCardEffect failed: not eonugh mana");
            return(false);
        }
        else if (card.model.redToActivate.Value > board.mana.model.redMana.Value)
        {
            Debug.Log("ActivateCardEffect failed: not eonugh mana");
            return(false);
        }

        //コスト消費
        board.mana.model.greenMana.Value -= card.model.greenToActivate.Value;
        board.mana.model.blueMana.Value  -= card.model.blueToActivate.Value;
        board.mana.model.redMana.Value   -= card.model.redToActivate.Value;

        await this.activateCardEffect.Activate(card, player, board);

        return(true);
    }
 public void GlowBoardEntity(BoardEntity boardEntity)
 {
     if (boardEntity != null)
     {
         //boardEntity.GetComponentInChildren<GlowManager>().TurnOn(this, defaultBoardEntityHighlightColor);
     }
 }
Example #11
0
        private Point GetCenterPos(BoardEntity entity, bool top)
        {
            var    xOffset = entity.ActualWidth / 2;
            double yOffset;

            if (entity == PlayerBoardHeroEntity)
            {
                yOffset = -31;
            }
            else if (entity == OpponentBoardHeroEntity)
            {
                yOffset = -28;
            }
            else
            {
                yOffset = entity.ActualHeight / 2;
                if (!top)
                {
                    yOffset *= -1;
                }
            }
            var x = GetPosition(entity).X + xOffset;
            var y = GetPosition(entity).Y + yOffset;

            return(new Point(x, y));
        }
 public void UnGlowBoardEntity(BoardEntity boardEntity)
 {
     if (boardEntity != null)
     {
         //boardEntity.GetComponentInChildren<GlowManager>().TurnOff(this);
     }
 }
        public void setSelectedBoardEntity(BoardEntity boardEntity)
        {
            if (boardEntity == TurnManager.CurrentBoardEntity && (boardEntity == null || boardEntity.Team != Team.Enemy))
            {
                setHoverEntity(null);
                selectedBoardEntity = null;
                tileSelectionManager.CancelSelection();

                selectedBoardEntity = boardEntity;
                profile.UpdateProfile(boardEntity);

                buildMoveOptions();
                if (boardEntity == null)
                {
                    skillSelector.Hide();
                }
            }

            /*
             * else
             * {
             *  if (boardEntity == hoverBoardEntity)
             *  {
             *      setHoverEntity(null);
             *  }
             *  else
             *  {
             *      //setHoverEntity(boardEntity);
             *  }
             * }
             */
        }
        // this is the main one
        public void SelectTile(BoardEntity boardEntity, List <TileSelectOption> options, Action <TileSelectOption> callBack, bool isMovement = false,
                               Action hoverExit = null)
        {
            this.hoverExit = hoverExit;
            if (selectionCallBack == null)
            {
                this.isMovement   = isMovement;
                selectionCallBack = callBack;

                possibleTiles.Clear();
                options.ForEach(x => possibleTiles.Add(x.Selection, x));

                if (boardEntity != null)
                {
                    selectedEntity = boardEntity;
                    glow(selectedEntity.GetTile(), defaultHoverColor);
                }

                // highlight possible moves
                foreach (TileSelectOption opt in options)
                {
                    highlightMovableTile(opt.Selection.GetComponentInChildren <PathOnClick>());
                }

                //selectedTile = boardEntity.GetTile().PathOnClick;
            }
        }
Example #15
0
 void OnEntityEnterGoal(BoardEntity ent)
 {
     if (ent == player)
     {
         WonUIPopUp();
     }
 }
Example #16
0
        public async Task <IActionResult> PutAsync(string userId, [FromBody] Board board)
        {
            // Validate input and return 400 Bad Request if invalid
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            // Create the valid data entity
            var entity = new BoardEntity
            {
                PartitionKey = userId,
                RowKey       = board.Id,
                Name         = board.Name,
                OwnerId      = board.OwnerId
            };

            // Update the data
            var updatedEntity = await _boardRepository.InsertOrMergeAsync(entity);

            // Create the return contract
            var updatedBoard = new Board
            {
                Id      = updatedEntity.RowKey,
                Name    = updatedEntity.Name,
                OwnerId = updatedEntity.OwnerId
            };

            // Return 200 OK
            return(Ok(updatedBoard));
        }
        public async void GivenQueryWhenBoardExistsThenEachItemMapped()
        {
            // Arrange
            var boardEntity = new BoardEntity {
                Slug = "board-name"
            };

            SetupQueryHandler(new List <BoardEntity>
            {
                boardEntity
            },
                              new List <BoardColumnEntity>
            {
                new BoardColumnEntity
                {
                    BoardEntity = boardEntity
                }
            });

            var query = new SearchBoardColumnsQuery
            {
                BoardSlug = "board-name"
            };

            // Act
            await handler.HandleAsync(query);

            // Assert
            mockMappingService.Verify(x => x.Map <BoardColumn>(It.IsAny <BoardColumnEntity>()), Times.Once);
        }
 public void Hover(BoardEntity boardEntity)
 {
     if (getHoverEntity() == null)
     {
         profile.UpdateProfile(boardEntity);
     }
 }
Example #19
0
        public async Task <BoardEntity> Update(BoardEntity board)
        {
            var storedBoard = _boardRepository.GetById(board.Id);

            if (storedBoard != null)
            {
                try
                {
                    storedBoard.Name        = board.Name != null ? board.Name : storedBoard.Name;
                    storedBoard.Description = board.Description != null ? board.Description : storedBoard.Description;
                    storedBoard.UserGroups  = board.UserGroups.Count > 0 ? board.UserGroups : storedBoard.UserGroups;
                    storedBoard.Active      = board.Active;
                    storedBoard.UpdatedAt   = DateTime.Now;

                    var updateUser = await _boardRepository.Update(storedBoard);

                    return(updateUser);
                }
                catch (Exception error)
                {
                    throw error;
                }
            }

            throw new Exception("Board not exists! Choice another name!");
        }
Example #20
0
    public void OnClickPoint(int x, int y)
    {
        if (isEditingMap)
        {
            HexPoint p = currentBoard.GetPoint(x, y);

            if (p.state == HexPoint.State.WIREFRAME)
            {
                p.ForceChangeStateTo(HexPoint.State.NORMAL);
            }
            else
            {
                p.ForceChangeStateTo(HexPoint.State.WIREFRAME);
            }
        }
        else
        {
            BoardEntity ent = currentBoard.FindEntityAtPoint(currentBoard.GetPoint(x, y));
            if (ent != null)
            {
                currentBoard.RemoveEntity(ent);
            }
            else
            {
                ent = Instantiate(selectingEntity.gameObject).GetComponent <BoardEntity>();
                currentBoard.AddEntity(ent, x, y);
            }
        }
    }
        public async void GivenCommandWhenBoardColumnExisttsAndIsEmptyThenBoardColumnRemovedAndSaveChangesCalled()
        {
            // Arrange
            var boardEntity = new BoardEntity {
                Slug = "board-name"
            };
            var boardColumnEntity = new BoardColumnEntity {
                Id = 1, Slug = "board-column-name", BoardEntity = boardEntity
            };

            SetupHandler(new List <BoardEntity> {
                boardEntity
            }, new List <BoardColumnEntity>
            {
                boardColumnEntity
            }, new List <BoardTaskEntity>());

            var command = new DeleteBoardColumnCommand
            {
                BoardSlug       = "board-name",
                BoardColumnSlug = "board-column-name"
            };

            // Act
            await handler.HandleAsync(command);

            // Assert
            mockDataContext.Verify(x => x.SaveChangesAsync(), Times.Once());
            mockDataContext.Verify(x => x.Delete(boardColumnEntity), Times.Once());
        }
        public async void GivenCommandWhenBoardColumnHasTasksThenBoardColumnNotEmptyExceptionThrown()
        {
            // Arrange
            var boardEntity = new BoardEntity {
                Slug = "board-name"
            };
            var boardColumnEntity = new BoardColumnEntity {
                Id = 1, Slug = "board-column-name", BoardEntity = boardEntity
            };

            SetupHandler(new List <BoardEntity> {
                boardEntity
            }, new List <BoardColumnEntity>
            {
                boardColumnEntity
            }, new List <BoardTaskEntity>
            {
                new BoardTaskEntity {
                    BoardColumnEntity = boardColumnEntity
                }
            });

            var command = new DeleteBoardColumnCommand
            {
                BoardSlug       = "board-name",
                BoardColumnSlug = "board-column-name"
            };

            // Act & Assert
            await Assert.ThrowsAsync <BoardColumnNotEmptyException>(() => handler.HandleAsync(command));
        }
Example #23
0
        public async void GivenCommandWhenTaskExistsThenMappedBackToDto()
        {
            // Arrange
            var boardEntity = new BoardEntity {
                Slug = "board-name"
            };
            var boardColumnEntity = new BoardColumnEntity
            {
                Slug        = "board-column-name",
                BoardEntity = boardEntity
            };

            SetupCommandHandler(new List <BoardEntity> {
                boardEntity
            }, new List <BoardColumnEntity> {
                boardColumnEntity
            });

            var command = new UpdateBoardColumnCommand
            {
                BoardSlug       = "board-name",
                BoardColumnSlug = "board-column-name",
                BoardColumn     = new BoardColumn()
            };

            // Act
            await handler.HandleAsync(command);

            // Assert
            mockMappingService.Verify(x => x.Map <BoardColumn>(It.IsAny <BoardColumnEntity>()), Times.Once);
        }
Example #24
0
        public async void GivenCommandWhenTaskExistsThenAttachedSaveChangesCalled()
        {
            // Arrange
            var boardEntity = new BoardEntity {
                Slug = "board-name"
            };
            var boardColumnEntity = new BoardColumnEntity
            {
                Slug        = "board-column-name",
                BoardEntity = boardEntity
            };

            SetupCommandHandler(new List <BoardEntity> {
                boardEntity
            }, new List <BoardColumnEntity> {
                boardColumnEntity
            });

            var command = new UpdateBoardColumnCommand
            {
                BoardSlug       = "board-name",
                BoardColumnSlug = "board-column-name",
                BoardColumn     = new BoardColumn()
            };

            // Act
            await handler.HandleAsync(command);

            // Assert
            mockDataContext.Verify(x => x.SetModified(boardColumnEntity), Times.Once);
            mockDataContext.Verify(x => x.SaveChangesAsync(), Times.Once);
        }
Example #25
0
 public static Board ToTable(this BoardEntity board)
 {
     return(new Board {
         Id = board.Id.ToBoardId(),
         Name = board.Name
     });
 }
Example #26
0
    public List <BoardEntity> FindEntitiesInArea(Coord center, int radius)
    {
        List <BoardEntity> ret = new List <BoardEntity>();

        for (int i = center.y - radius; i <= center.y + radius; i++)
        {
            for (int j = center.x - radius; j <= center.x + radius; j++)
            {
                Coord c = new Coord(j, i);

                if (center.Distance(c) <= radius)
                {
                    Tile t = GetTile(c);
                    if (t != null)
                    {
                        BoardEntity e = t.entity;
                        if (e != null)
                        {
                            ret.Add(e);
                        }
                    }
                }
            }
        }

        return(ret);
    }
Example #27
0
    private void Awake()
    {
        canvasGroup = GetComponent <CanvasGroup>();
        canvas      = FindObjectOfType <Canvas>();

        board = GameObject.Find("BoardEntity").GetComponent <BoardEntity>();
    }
        public async void GivenQueryWhenBoardExistsThenBoardColumnCollectionReturned()
        {
            // Arrange
            var boardEntity = new BoardEntity {
                Slug = "board-name"
            };

            SetupQueryHandler(new List <BoardEntity>
            {
                boardEntity
            },
                              new List <BoardColumnEntity>
            {
                new BoardColumnEntity
                {
                    BoardEntity = boardEntity
                }
            });

            var query = new SearchBoardColumnsQuery
            {
                BoardSlug = "board-name"
            };

            // Act
            var boardColumnCollection = await handler.HandleAsync(query);

            // Assert
            Assert.NotNull(boardColumnCollection);
        }
Example #29
0
 public CharacterBoardEntity convert(BoardEntity boardEntity)
 {
     if (boardEntity is CharacterBoardEntity)
     {
         return((CharacterBoardEntity)boardEntity);
     }
     return(null);
 }
Example #30
0
 public void ExecuteEnterActions(BoardEntity boardEntity, Tile t, Action callback)
 {
     enterActionCounter  = 0;
     enterBoardEntity    = boardEntity;
     enterActionCallback = callback;
     leavingTile         = t;
     ExecuteEnterActionsHelper();
 }