コード例 #1
0
    public void SavingBattleTeams(SaveBattleTeams battleTeams)
    {
        string pathParameters = Application.dataPath + "/BattleTeams.json";

        File.WriteAllText(pathParameters, JsonUtility.ToJson(battleTeams));
        Debug.Log(JsonUtility.ToJson(battleTeams));
    }
コード例 #2
0
    private void LoadingBattleTeams()
    {
        //#if UNITY_EDITOR
        string pathParameters = Application.dataPath + "/BattleTeams.json";

        if (File.Exists(pathParameters))
        {
            string json = File.ReadAllText(pathParameters);
            _battleTeams = JsonUtility.FromJson <SaveBattleTeams>(json);
        }
        else
        {
            _battleTeams = _defaultTeams;
        }
        //#endif
    }
コード例 #3
0
    public SaveBattleSystem()
    {
        _defaultTeams = new SaveBattleTeams(
            new SaveFightTeam(
                new List <SaveFightCharacter>
        {
            new SaveFightCharacter("000001", 1, 1, 0, 0),
            new SaveFightCharacter("000002", 1, 1, 1, 1),
            new SaveFightCharacter("000003", 1, 1, 2, 2),
        }
                ),
            new SaveFightTeam(
                new List <SaveFightCharacter>
        {
            new SaveFightCharacter("000001", 1, 1, 0, 0),
            new SaveFightCharacter("000002", 1, 1, 1, 1),
            new SaveFightCharacter("000003", 1, 1, 2, 2),
        }
                ));

        LoadingBattleTeams();
    }
コード例 #4
0
    public void ChangeFightLevel(int level)
    {
        SaveBattleSystem saveBattleSystem = new SaveBattleSystem();
        SaveBattleTeams  battleTeams;

        switch (level)
        {
        case 1:
            battleTeams = new SaveBattleTeams(
                new SaveFightTeam(
                    new List <SaveFightCharacter>
            {
                new SaveFightCharacter("000001", 1, 1, 0, 0),
                new SaveFightCharacter("000002", 1, 1, 1, 1),
                new SaveFightCharacter("000003", 1, 1, 2, 2),
            }
                    ),
                new SaveFightTeam(
                    new List <SaveFightCharacter>
            {
                new SaveFightCharacter("000001", 1, 1, 0, 0),
                new SaveFightCharacter("000002", 1, 1, 1, 1),
                new SaveFightCharacter("000003", 1, 1, 2, 2),
            }
                    ));
            saveBattleSystem.SavingBattleTeams(battleTeams);
            SceneManager.LoadScene("BattLe");
            break;

        case 2:
            battleTeams = new SaveBattleTeams(
                new SaveFightTeam(
                    new List <SaveFightCharacter>
            {
                new SaveFightCharacter("000001", 1, 1, 0, 0),
                new SaveFightCharacter("000002", 1, 1, 1, 1),
                new SaveFightCharacter("000003", 1, 1, 2, 2),
                new SaveFightCharacter("000001", 1, 2, 0, 3),
                new SaveFightCharacter("000002", 1, 2, 1, 4),
                new SaveFightCharacter("000003", 1, 2, 2, 5),
            }
                    ),
                new SaveFightTeam(
                    new List <SaveFightCharacter>
            {
                new SaveFightCharacter("000001", 1, 1, 0, 0),
                new SaveFightCharacter("000002", 1, 1, 1, 1),
                new SaveFightCharacter("000003", 1, 1, 2, 2),
                new SaveFightCharacter("000001", 1, 0, 0, 3),
                new SaveFightCharacter("000002", 1, 0, 1, 4),
                new SaveFightCharacter("000003", 1, 0, 2, 5),
            }
                    ));
            saveBattleSystem.SavingBattleTeams(battleTeams);
            SceneManager.LoadScene("BattLe");
            break;

        case 3:
            battleTeams = new SaveBattleTeams(
                new SaveFightTeam(
                    new List <SaveFightCharacter>
            {
                new SaveFightCharacter("000001", 1, 1, 0, 4),
                new SaveFightCharacter("000003", 1, 1, 1, 0),
                new SaveFightCharacter("000003", 1, 1, 2, 1),
                new SaveFightCharacter("000001", 1, 2, 0, 5),
                new SaveFightCharacter("000003", 1, 2, 1, 2),
                new SaveFightCharacter("000003", 1, 2, 2, 3),
                new SaveFightCharacter("000001", 1, 0, 2, 6),
                new SaveFightCharacter("000001", 1, 3, 2, 7),
            }
                    ),
                new SaveFightTeam(
                    new List <SaveFightCharacter>
            {
                new SaveFightCharacter("000001", 1, 0, 0, 0),
                new SaveFightCharacter("000002", 1, 0, 1, 1),
                new SaveFightCharacter("000002", 1, 0, 2, 2),
                new SaveFightCharacter("000001", 1, 1, 0, 3),
                new SaveFightCharacter("000002", 1, 1, 1, 4),
                new SaveFightCharacter("000002", 1, 1, 2, 5),
                new SaveFightCharacter("000001", 1, 2, 0, 6),
                new SaveFightCharacter("000002", 1, 2, 1, 7),
                new SaveFightCharacter("000002", 1, 2, 2, 8),
                new SaveFightCharacter("000001", 1, 3, 0, 9),
                new SaveFightCharacter("000002", 1, 3, 1, 10),
                new SaveFightCharacter("000002", 1, 3, 2, 11),
            }
                    ));
            saveBattleSystem.SavingBattleTeams(battleTeams);
            SceneManager.LoadScene("BattLe");
            break;
        }
    }
コード例 #5
0
    private void Start()
    {
        _battleTeams    = (new SaveBattleSystem()).BattleTeams;
        _characterViews = new Dictionary <BattleCharacter, FightCharacterView>();
        List <BattleCharacterPlacement>   teamA      = new List <BattleCharacterPlacement>();
        List <BattleCharacterPlacement>   teamB      = new List <BattleCharacterPlacement>();
        List <BattleCharacter>            queue      = new List <BattleCharacter>();
        Dictionary <BattleCharacter, int> queueTeamA = new Dictionary <BattleCharacter, int>();
        Dictionary <BattleCharacter, int> queueTeamB = new Dictionary <BattleCharacter, int>();

        foreach (var member in _battleTeams.FightTeamA.Characters)
        {
            DatabaseCharacter databaseCharacter = _database.GetDatabaseCharacter(member.Id);
            BattleCharacter   character         = new BattleCharacter(databaseCharacter.BattleCharacter, databaseCharacter.Characteristics, null);
            PlacementPosition position          = new PlacementPosition(member.LinePosition, member.ColumnPosition);

            teamA.Add(new BattleCharacterPlacement(character, position));
            queueTeamA.Add(character, member.PlaceInQueue);
        }

        foreach (var member in _battleTeams.FightTeamB.Characters)
        {
            DatabaseCharacter databaseCharacter = _database.GetDatabaseCharacter(member.Id);
            BattleCharacter   character         = new BattleCharacter(databaseCharacter.BattleCharacter, databaseCharacter.Characteristics, null);
            PlacementPosition position          = new PlacementPosition(member.LinePosition, member.ColumnPosition);

            teamB.Add(new BattleCharacterPlacement(character, position));
            queueTeamB.Add(character, member.PlaceInQueue);
        }

        _battlePlacement = new BattlePlacement(teamA, teamB);

        foreach (var member in _battlePlacement.Search.AllTeam())
        {
            member.SetBattlePlacement(_battlePlacement);
        }

        foreach (var member in teamA)
        {
            FightSpawnPoint    spawnPoint     = _teamASpownPoints[member.Position.Line].points[member.Position.Column];
            FightCharacterView fightCharacter = Instantiate(_prefabCharacter, spawnPoint.transform);
            _characterViews.Add(member.Character, fightCharacter);
        }

        foreach (var member in teamB)
        {
            FightSpawnPoint    spawnPoint     = _teamBSpownPoints[member.Position.Line].points[member.Position.Column];
            FightCharacterView fightCharacter = Instantiate(_prefabCharacter, spawnPoint.transform);
            _characterViews.Add(member.Character, fightCharacter);
        }

        for (int i = 0; queueTeamA.Count > 0 || queueTeamB.Count > 0; i++)
        {
            if (i % 2 == 0)
            {
                if (queueTeamA.Count > 0)
                {
                    BattleCharacter battleCharacter = null;
                    int             j = int.MaxValue;

                    foreach (var key in queueTeamA.Keys)
                    {
                        if (queueTeamA[key] < j)
                        {
                            battleCharacter = key;
                            j = queueTeamA[key];
                        }
                    }

                    if (battleCharacter != null)
                    {
                        queue.Add(battleCharacter);
                        queueTeamA.Remove(battleCharacter);
                    }
                }
            }
            else
            {
                if (queueTeamB.Count > 0)
                {
                    BattleCharacter battleCharacter = null;
                    int             j = int.MaxValue;

                    foreach (var key in queueTeamB.Keys)
                    {
                        if (queueTeamB[key] < j)
                        {
                            battleCharacter = key;
                            j = queueTeamB[key];
                        }
                    }

                    if (battleCharacter != null)
                    {
                        queue.Add(battleCharacter);
                        queueTeamB.Remove(battleCharacter);
                    }
                }
            }
        }

        _timer          = 0;
        _fightControler = GetComponent <FightControler>();

        _allAction = _fightControler.Fight(_battlePlacement, queue);

        for (_countAction = 0; _countAction < _allAction.Count; _countAction++)
        {
            if (_allAction[_countAction].Act == CharacterActionEvent.Action.System)
            {
                if (_allAction[_countAction].ActSystem.SystemEnum == CharacterActionEvent.ActionSystem.StartFight)
                {
                    return;
                }
            }

            ActionHandler(_allAction[_countAction]);
        }
    }