コード例 #1
0
    public void FinishDrag(Vector2Int coord)
    {
        if (selectedCell == null)
        {
            return;
        }

        var newCoord = currentCell.Coord;

        this[newCoord].SetHighlight(false);
        if (this[newCoord].CellCharacter == null)
        {
            // move
            this[newCoord].SetInfo(selectedCell.CellCharacter);
            selectedCell.Init();
        }
        else if (newCoord != selectedCell.Coord && newCoord != selectedCell.Coord)
        {
            // change
            var changeCell = this[newCoord].CellCharacter;

            this[newCoord].SetInfo(selectedCell.CellCharacter);
            selectedCell.SetInfo(changeCell);
        }

        selectedCell = null;
        currentCell  = null;
    }
コード例 #2
0
 public void EnterCell(Vector2Int coord)
 {
     currentCell = this[coord];
     if (selectedCell != null)
     {
         // highlight
         this[coord].SetHighlight(true);
     }
 }
コード例 #3
0
    public void BeginDrag(Vector2Int coord)
    {
        if (this[coord].CellCharacter == null)
        {
            return;
        }

        selectedCell = this[coord];
        currentCell  = this[coord];

        this[coord].SetHighlight(true);
    }
コード例 #4
0
    public void InitBoard(Level level)
    {
        foreach (var enemyDeckCell in enemyDeckCells)
        {
            enemyDeckCell.Init();
        }
        // 플레이어 저장 데이터에 현재 전투 중인 몬스터 정보가 없으면 새로 저장, 덱 셀에 입력
        if (!GameData.Instance.playerInfo.monsters.Any())
        {
            for (int i = 0; i < level.monstersPos.Length; ++i)
            {
                var       characterInfo = GameData.Instance.CharacterInfos[level.monsters[i]];
                Character character     = new Character(characterInfo);
                GameData.Instance.playerInfo.monsters.Add(character);
                enemyDeckCells[level.monstersPos[i]].SetInfo(character);
            }
        }
        else
        {
            // TODO: current hp가 반영된, character 정보로 셋팅하도록 수정
            // 덱 셀에 입력
            for (int i = 0; i < level.monstersPos.Length; ++i)
            {
                Character character = GameData.Instance.playerInfo.monsters[i];
                enemyDeckCells[level.monstersPos[i]].SetInfo(character);
            }
        }

        foreach (var heroDeckCell in heroDeckCells)
        {
            heroDeckCell.Init();
        }

        currentCell  = null;
        selectedCell = null;

        // 저장
        GameData.Instance.SavePlayerData();
    }