Example #1
0
 public void StartEncounter()
 {
     currentEncounter = this;
     LockCameraAndPlayerMovement();
     enemyController.SetFightSequence(fightSequence);
     this.StartSafeCoroutine(GenerateEnemies());
 }
Example #2
0
 public static void SetEnemyEncounter(EnemyEncounter ee)
 {
     currentEncounter = ee;
     gm.restartPoint  = currentEncounter.restartPoint.position;
     prevHealth       = pc.GetHealth();
     prevEdge         = pc.GetEdge();
 }
Example #3
0
 public CombatTileForm(ref Player player)
 {
     InitializeComponent();
     this.player = player;
     encounter   = new EnemyEncounter(ref player);
     InitEncounter();
     encounter.fight.Update   += OnUpdateStatus;
     encounter.fight.Defeated += OnDefeated;
 }
Example #4
0
 public void SetFightSequenceReferences(EnemyController controller,
                                        EnemyEncounter encounter,
                                        FindFightPositions fightPositions)
 {
     enemyController               = controller;
     enemyEncounter                = encounter;
     findFightPositions            = fightPositions;
     simulataneousAttackingEnemies = 1;
 }
Example #5
0
 //Constructor function for this class
 public EnemyTileEncounterInfo(EnemyEncounter encounter_)
 {
     //Getting the object prefab for the encounter
     this.encounterPrefab = encounter_.encounterPrefab;
     //Getting the tile that this encounter is on
     CreateTileGrid.TileColRow encounterCoords = CreateTileGrid.globalReference.GetTileCoords(encounter_.GetComponent <Movement>().currentTile);
     this.encounterTileCol = encounterCoords.col;
     this.encounterTileRow = encounterCoords.row;
 }
Example #6
0
 public void SetFightSequenceReferences(EnemyController controller,
                                        EnemyEncounter encounter,
                                        FindFightPositions fightPositions)
 {
     enemyController = controller;
     enemyEncounter = encounter;
     findFightPositions = fightPositions;
     simulataneousAttackingEnemies = 1;
 }
    // Start is called before the first frame update
    public void BattleTransition(EnemyEncounter encounterr)
    {
        //enemy = encounterr.gameObject;
        //encounterr.on = true;
        if (encounterr.gameObject.tag == "boss")
        {
            boss = true;
        }
        else
        {
            boss = false;
        }
        if (encounterr.gameObject.tag == "secretBoss")
        {
            secretBoss = true;
        }
        else
        {
            secretBoss = false;
        }

        List <baseStats> party = currentParty;
        int ran = Random.Range(0, 3);

        if (ran == 0)
        {
            encounter = encounterr.encounter1;
        }
        else if (ran == 1)
        {
            encounter = encounterr.encounter2;
        }
        else if (ran == 2)
        {
            encounter = encounterr.encounter3;
        }

        encounterr.gameObject.GetComponent <EnemyEncounter>().enabled = false;
        foreach (baseStats person in currentParty)
        {
            if (person.gameObject.tag == "Overworld Player")
            {
                person.gameObject.GetComponent <playerMovement>().enabled          = false;
                person.gameObject.GetComponentInChildren <AudioListener>().enabled = false;
                person.gameObject.GetComponent <baseStats>().on = false;
            }
            else if (person.gameObject.tag == "party")
            {
                person.gameObject.GetComponent <SpriteRenderer>().enabled = false;
            }
            person.on = false;
        }
        battleMusic = encounterr.battleMusic;
        enemySpawner.instance.spawning = false;
        enemySpawner.instance.spawnLocations.Clear();
        StartCoroutine(TransitionB());
    }
Example #8
0
    //Function called externally to create instances of enemy encounter prefabs
    public void CreateEnemyEncounter(EnemyEncounter encounterToCreate_, TileInfo tileToSpawnOn_)
    {
        //Creating a new instance of the encounter object
        GameObject encounterObj = GameObject.Instantiate(encounterToCreate_.gameObject) as GameObject;

        //Setting the encounter's tile position
        encounterObj.GetComponent <Movement>().SetCurrentTile(tileToSpawnOn_);
        //Setting the encounter's original object prefab
        encounterObj.GetComponent <EnemyEncounter>().encounterPrefab = encounterToCreate_.gameObject;
        //Adding this encounter to our list of enemy tile encounters
        this.tileEnemyEncounters.Add(encounterObj.GetComponent <EnemyEncounter>());
    }
Example #9
0
    private IEnumerator Endbattle()
    {
        ability1.DisAllow();
        ability2.DisAllow();
        PlayerStats.CurrentHealth = AllyHp1;
        yield return(new WaitForSeconds(2));

        exp.gainedExp(500 + (CurrentFight * 100));
        //SceneManager.LoadScene ("Test",LoadSceneMode.Additive);
        EnemyEncounter.EndBattle();
        SceneManager.UnloadSceneAsync("BattleScene");
    }
    //Function called from CombatManager.InitiateCombat to load all player and enemy characters into combat
    public void InitializeCharactersForCombat(PartyGroup playerParty_, EnemyEncounter enemyParty_)
    {
        //Resetting the character lists
        this.playerCharacters = new List <Character>();
        this.enemyCharacters  = new List <Character>();

        //Filling both lists with the player and enemy characters
        foreach (Character pc in playerParty_.charactersInParty)
        {
            this.playerCharacters.Add(pc);
        }

        foreach (EncounterEnemy ec in enemyParty_.enemies)
        {
            GameObject newEnemy = GameObject.Instantiate(ec.enemyCreature.gameObject);
            this.enemyCharacters.Add(newEnemy.GetComponent <Character>());
        }

        //Spawning the character models, setting their locations, and assigning any starting combat buffs
        this.SetCharacterTilePositions(playerParty_.combatDistance, enemyParty_);
        this.CreateCharacterModels();
        this.FindStartingBuffs();
    }
    //Function called from InitializeCharactersForCombat to set each character's tile position
    private void SetCharacterTilePositions(GroupCombatDistance partyDistance_, EnemyEncounter encounter_)
    {
        //The number of columns the player party is shifted
        int playerColShift = 0;

        //The number of columns the front half of the enemy encounter is shifted
        int enemyColShift0 = 0;
        int enemyColShift1 = 1;
        int enemyColShift2 = 2;
        int enemyColShift3 = 3;

        //Determine if we use the default enemy position or the ambush position
        EnemyCombatPosition encounterPos = encounter_.defaultPosition;

        //Rolling to see if this encounter will ambush the player
        float ambushRoll = Random.Range(0f, 1f);

        //If the enemies are able to ambush players, their encounter position is set to the ambush position
        if (ambushRoll < encounter_.ambushChance)
        {
            encounterPos = encounter_.ambushPosition;
        }

        //Determining which kind of enemy encounter the player's will be facing
        switch (encounterPos)
        {
        //If the enemy is in melee range
        case EnemyCombatPosition.MeleeFront:
        {
            //Setting the player positions between col 0 - 6
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //0-2
                playerColShift = 0;
                break;

            case GroupCombatDistance.Medium:            //2-4
                playerColShift = 2;
                break;

            case GroupCombatDistance.Close:            //4-6
                playerColShift = 4;
                break;
            }

            //Setting the enemy positions between col 7-10
            enemyColShift0 += 7;
            enemyColShift1 += 7;
            enemyColShift2 += 7;
            enemyColShift3 += 7;
        }
        break;

        case EnemyCombatPosition.MeleeFlanking:
        {
            //Setting the player positions between col 6-8 regardless of their preferred distance
            playerColShift = 6;

            //Setting the enemy positions so that they're split between cols 4-5 and 9-10
            enemyColShift0 += 4;        //Col 5
            enemyColShift1 += 8;        //Col 9
            enemyColShift2 += 1;        //Col 4
            enemyColShift3 += 7;        //Col 10
        }
        break;

        case EnemyCombatPosition.MeleeBehind:
        {
            //Setting the player positions between col 7-13
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //7-9
                playerColShift = 7;
                break;

            case GroupCombatDistance.Medium:            //9-11
                playerColShift = 9;
                break;

            case GroupCombatDistance.Close:            //11-13
                playerColShift = 11;
                break;
            }

            //Setting the enemy positions between col 3-6 but in reverse order
            enemyColShift0 += 6;
            enemyColShift1 += 4;
            enemyColShift2 += 2;
            enemyColShift3 += 0;
        }
        break;

        //If the enemy is in middle range
        case EnemyCombatPosition.MiddleFront:
        {
            //Setting the player positions between col 0 - 6
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //0-2
                playerColShift = 0;
                break;

            case GroupCombatDistance.Medium:            //2-4
                playerColShift = 2;
                break;

            case GroupCombatDistance.Close:            //4-6
                playerColShift = 4;
                break;
            }

            //Setting the enemy positions between col 9-12
            enemyColShift0 += 9;
            enemyColShift1 += 9;
            enemyColShift2 += 9;
            enemyColShift3 += 9;
        }
        break;

        case EnemyCombatPosition.MiddleFlanking:
        {
            //Setting the player positions between col 5-8
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //5-7
                playerColShift = 5;
                break;

            case GroupCombatDistance.Medium:            //6-8
                playerColShift = 6;
                break;

            case GroupCombatDistance.Close:            //6-8
                playerColShift = 6;
                break;
            }

            //Setting the enemy positions split between cols 2-3 and cols 10-11
            enemyColShift0 += 3;        //Col 3
            enemyColShift1 += 9;        //Col 10
            enemyColShift2 += 0;        //Col 2
            enemyColShift3 += 8;        //Col 11
        }
        break;

        case EnemyCombatPosition.MiddleBehind:
        {
            //Setting the player positions between col 7-13
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //7-9
                playerColShift = 7;
                break;

            case GroupCombatDistance.Medium:            //9-11
                playerColShift = 9;
                break;

            case GroupCombatDistance.Close:            //11-13
                playerColShift = 11;
                break;
            }

            //Setting the enemy positions between col 1-4 but in reverse order
            enemyColShift0 += 4;
            enemyColShift1 += 2;
            enemyColShift2 += 0;
            enemyColShift3 += -2;
        }
        break;

        //If the enemy is in a far range
        case EnemyCombatPosition.RangedFront:
        {
            //Setting the player positions between col 0 - 6
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //0-2
                playerColShift = 0;
                break;

            case GroupCombatDistance.Medium:            //2-4
                playerColShift = 2;
                break;

            case GroupCombatDistance.Close:            //4-6
                playerColShift = 4;
                break;
            }

            //Setting the enemy positions between col 10-13
            enemyColShift0 += 10;
            enemyColShift1 += 10;
            enemyColShift2 += 10;
            enemyColShift3 += 10;
        }
        break;

        case EnemyCombatPosition.RangedFlanking:
        {
            //Setting the player positions between col 5-8
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //5-7
                playerColShift = 5;
                break;

            case GroupCombatDistance.Medium:            //6-8
                playerColShift = 6;
                break;

            case GroupCombatDistance.Close:            //6-8
                playerColShift = 6;
                break;
            }

            //Setting the enemy positions split between cols 0-1 and cols 12-13
            enemyColShift0 += 1;        //Col 1
            enemyColShift1 += 3;        //Col 12
            enemyColShift2 += -2;       //Col 0
            enemyColShift3 += 10;       //Col 13
        }
        break;

        case EnemyCombatPosition.RangedBehind:
        {
            //Setting the player positions between col 7-11
            switch (partyDistance_)
            {
            case GroupCombatDistance.Far:            //7-9
                playerColShift = 7;
                break;

            case GroupCombatDistance.Medium:            //9-11
                playerColShift = 9;
                break;

            case GroupCombatDistance.Close:            //11-13
                playerColShift = 11;
                break;
            }

            //Setting the enemy positions between col 0-3, so no change
        }
        break;
        }

        //After we've found the column shifts, we loop through and set the player positions
        foreach (Character playerChar in this.playerCharacters)
        {
            //Offsetting the player position column from the starting position
            playerChar.charCombatStats.gridPositionCol = playerChar.charCombatStats.startingPositionCol + playerColShift;
            playerChar.charCombatStats.gridPositionRow = playerChar.charCombatStats.startingPositionRow;
        }

        //Now we set the enemy positions based on the column shifts
        for (int e = 0; e < this.enemyCharacters.Count; e++)
        {
            //If this enemy's column position is random
            if (encounter_.enemies[e].randomCol)
            {
                this.enemyCharacters[e].charCombatStats.gridPositionCol = Random.Range(0, 3);
            }
            //If this enemy's column position isn't random
            else
            {
                this.enemyCharacters[e].charCombatStats.gridPositionCol = encounter_.enemies[e].specificCol;
            }

            //If this enemy's row position is random
            if (encounter_.enemies[e].randomRow)
            {
                this.enemyCharacters[e].charCombatStats.gridPositionRow = Random.Range(0, 4);
            }
            //If this enemy's row position isn't random
            else
            {
                this.enemyCharacters[e].charCombatStats.gridPositionRow = encounter_.enemies[e].specificRow;
            }

            //offsetting the enemy column position based on what their default position is
            switch (this.enemyCharacters[e].charCombatStats.gridPositionCol)
            {
            case 0:
                this.enemyCharacters[e].charCombatStats.gridPositionCol = enemyColShift0;
                break;

            case 1:
                this.enemyCharacters[e].charCombatStats.gridPositionCol = enemyColShift1;
                break;

            case 2:
                this.enemyCharacters[e].charCombatStats.gridPositionCol = enemyColShift2;
                break;

            case 3:
                this.enemyCharacters[e].charCombatStats.gridPositionCol = enemyColShift3;
                break;

            default:
                //This case SHOULDN'T happen, but if it does, we treat it like the character's col is 0
                this.enemyCharacters[e].charCombatStats.gridPositionCol = enemyColShift0;
                break;
            }

            //Looping through all of the enemies created so far
            for (int i = 0; i < this.enemyCharacters.Count - 1; ++i)
            {
                //If the enemy we've just added shares the same combat row and column as another enemy
                if (this.enemyCharacters[e].charCombatStats.gameObject != this.enemyCharacters[i].gameObject &&
                    this.enemyCharacters[e].charCombatStats.gridPositionCol == this.enemyCharacters[i].charCombatStats.gridPositionCol &&
                    this.enemyCharacters[e].charCombatStats.gridPositionRow == this.enemyCharacters[i].charCombatStats.gridPositionRow)
                {
                    //The column shift amount for each column loop
                    int cShift = 0;

                    //Looping through all of the combat positions characters can be in
                    for (int c = 0; c < 4; ++c)
                    {
                        //Setting the column shift for this loop
                        if (c == 0)
                        {
                            cShift = enemyColShift0;
                        }
                        else if (c == 1)
                        {
                            cShift = enemyColShift1;
                        }
                        else if (c == 2)
                        {
                            cShift = enemyColShift2;
                        }
                        else if (c == 3)
                        {
                            cShift = enemyColShift3;
                        }

                        for (int r = 0; r < 8; ++r)
                        {
                            //Bool to track if the current position is empty
                            bool emptyPos = true;

                            //Looping through each enemy in the combat
                            foreach (Character ec in this.enemyCharacters)
                            {
                                //Making sure the enemy isn't somehow null or the enemy we've just created
                                if (ec != null && ec.gameObject != this.enemyCharacters[e].charCombatStats.gameObject)
                                {
                                    //If the tile isn't empty, we break out of this foreach loop
                                    if (ec.charCombatStats.gridPositionCol == cShift &&
                                        ec.charCombatStats.gridPositionRow == r)
                                    {
                                        emptyPos = false;
                                        break;
                                    }
                                }
                            }

                            //If we make it through all of the enemies without finding an overlap
                            if (emptyPos)
                            {
                                //Setting this enemy's position col and row to the empty position
                                this.enemyCharacters[e].charCombatStats.gridPositionCol = cShift;
                                this.enemyCharacters[e].charCombatStats.gridPositionRow = r;

                                //Breaking the row loop, col loop, and loop for checking other enemy positions
                                c = 10;
                                i = this.enemyCharacters.Count + 1;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    //Function called externally from LandTile.cs to initiate combat
    public void InitiateCombat(LandType combatLandType_, PartyGroup charactersInCombat_, EnemyEncounter encounter_)
    {
        //Creating the event data that we'll pass to the TransitionFade through the EventManager
        EVTData transitionEvent = new EVTData();

        //Setting the transition to take 0.5 sec to fade out, stay on black for 1 sec, fade in for 0.5 sec, and call our initialize event to display the combat canvas
        transitionEvent.combatTransition = new CombatTransitionEVT(true, 0.5f, 1, 0.5f, this.combatInitializeEvent);
        //Invoking the transition event through the EventManager
        EventManager.TriggerEvent(CombatTransitionEVT.eventNum, transitionEvent);

        //Resetting all of the combat tiles to their default values
        this.tileHandler.ResetCombatTiles();

        //Setting the combat positions for the player characters and enemies based on their distances
        this.characterHandler.InitializeCharactersForCombat(charactersInCombat_, encounter_);

        //Resetting the combat UI and cameras
        this.initiativeHandler.ResetForCombatStart();
        this.uiHandler.ResetForCombatStart();
        this.cameraHandler.ResetForCombatStart();

        //Setting the state to start increasing initiatives after a brief wait
        this.SetWaitTime(3, CombatState.IncreaseInitiative);

        //Looping through and copying the loot table from the encounter
        this.lootTable = new List <EncounterLoot>();
        foreach (EncounterLoot drop in encounter_.lootTable)
        {
            EncounterLoot loot = new EncounterLoot();
            loot.lootItem        = drop.lootItem;
            loot.dropChance      = drop.dropChance;
            loot.stackSizeMinMax = drop.stackSizeMinMax;
            this.lootTable.Add(loot);
        }
    }
Example #13
0
    //Function called from Movement.SetCurrentTile to indicate that an object is occupying this tile
    public void AddObjectToThisTile(GameObject objectToAdd_, bool rollForEncounter_ = true)
    {
        //Making sure we aren't adding a character more than once
        if (!this.objectsOnThisTile.Contains(objectToAdd_))
        {
            //If an enemy encounter is added to this tile
            if (objectToAdd_.GetComponent <EnemyEncounter>())
            {
                //Looping through all of the objects on this tile to see if a player party is on it
                foreach (GameObject currentObj in this.objectsOnThisTile)
                {
                    //If the current object is a player party
                    if (currentObj.GetComponent <PartyGroup>())
                    {
                        //Initiating combat with the first group of characters found.
                        //NOTE: Even if multiple parties are on the same tile, they're still considered as separated, so only 1 group at a time
                        PartyGroup     playerGroupOnTile = currentObj.GetComponent <PartyGroup>();
                        EnemyEncounter newEncounter      = objectToAdd_.GetComponent <EnemyEncounter>();
                        CombatManager.globalReference.InitiateCombat(this.type, playerGroupOnTile, newEncounter);

                        //After combat is initiated, the enemy encounter is destroyed before it is added to this tile
                        CharacterManager.globalReference.tileEnemyEncounters.Remove(objectToAdd_.GetComponent <EnemyEncounter>());
                        GameObject.Destroy(objectToAdd_);
                        //Breaking out of the function before multiple combats start at once
                        return;
                    }
                }

                //If there weren't any party groups on this tile, the enemy encounter is added
                this.objectsOnThisTile.Add(objectToAdd_);
            }
            //If a Party Group is added to this tile
            else if (objectToAdd_.GetComponent <PartyGroup>())
            {
                //The player group is added
                this.objectsOnThisTile.Add(objectToAdd_);

                //Looping through all of the objects on this tile to see if an enemy encounter is on it
                foreach (GameObject currentObj in this.objectsOnThisTile)
                {
                    //If the current object is an enemy encounter
                    if (currentObj.GetComponent <EnemyEncounter>())
                    {
                        //Initiating combat with the first group of characters found.
                        //NOTE: Even if multiple parties are on the same tile, they're still considered as separated, so only 1 group at a time
                        PartyGroup     playerGroupOnTile = objectToAdd_.GetComponent <PartyGroup>();
                        EnemyEncounter newEncounter      = currentObj.GetComponent <EnemyEncounter>();
                        CombatManager.globalReference.InitiateCombat(this.type, playerGroupOnTile, newEncounter);

                        //After combat is initiated, the enemy encounter is destroyed and we break out of the loop before multiple combats start at once
                        this.objectsOnThisTile.Remove(currentObj);
                        GameObject.Destroy(currentObj);
                        return;
                    }
                }

                //If we made it this far, there wasn't an enemy encounter on the tile, so we need to check for an encounter
                if (rollForEncounter_)
                {
                    //Looping through all objects on this tile to look for locations
                    bool locationFound = false;
                    foreach (GameObject o in this.objectsOnThisTile)
                    {
                        //If this object is a location, we break out of this loop
                        if (o.GetComponent <MapLocation>())
                        {
                            locationFound = true;
                            break;
                        }
                    }

                    //If there isn't a location on this tile we can roll for encounters. If there is, no random encounter
                    if (!locationFound)
                    {
                        this.RollForRandomEncounter();
                    }
                }
            }
        }
    }
    //Coroutine called from LoadPlayerProgress to load in the progress over time
    IEnumerator LoadProgressCoroutine(string folderName_)
    {
        //If the folder directory doesn't exist
        if (!Directory.Exists(Application.persistentDataPath + folderName_))
        {
            //We throw an exception because the folder that's supposed to hold the TileGrid.txt file doesn't exist
            throw new System.ArgumentException("SaveLoadManager.LoadPlayerProgress, The folder directory given does not exist!");
        }
        //If the folder exists but the file doesn't
        else if (!File.Exists(Application.persistentDataPath + folderName_ + "/" + this.defaultProgressFileName))
        {
            //We throw an exception because the file that we're supposed to load doesn't exist
            throw new System.ArgumentException("SaveLoadManager.LoadPlayerProgress, The PlayerProgress.txt file for this save does not exist!");
        }

        //Sending out an event to turn on the loading bar
        EVTData loadEVTData = new EVTData();

        loadEVTData.loadData = new LoadDataEVT(true, 7);
        EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);
        loadEVTData.loadData.startingLoad = false;

        //Getting all of the string data from the TileGrid.txt file
        string fileData = File.ReadAllText(Application.persistentDataPath + folderName_ + "/" + this.defaultProgressFileName);

        //De-serializing the player progress from the text file
        PlayerProgress loadedProgress = JsonUtility.FromJson(fileData, typeof(PlayerProgress)) as PlayerProgress;

        //Setting the GameData.cs variables
        GameData.globalReference.currentDifficulty   = loadedProgress.difficulty;
        GameData.globalReference.allowNewUnlockables = loadedProgress.allowNewUnlockables;
        GameData.globalReference.saveFolder          = loadedProgress.folderName;
        Random.state = loadedProgress.randState;

        //Setting the CreateTileGrid.cs variables
        TileMapManager.globalReference.cols = loadedProgress.gridCols;
        TileMapManager.globalReference.rows = loadedProgress.gridRows;

        //Updating the loading bar
        EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);//1

        //Setting the HUDChallengeRampUpTimer.cs variables
        HUDChallengeRampUpTimer.globalReference.currentDifficulty = loadedProgress.currentDifficulty;
        HUDChallengeRampUpTimer.globalReference.currentTimer      = loadedProgress.currentDifficultyTimer;

        //Updating the loading bar
        EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);//2

        //Setting the LevelUpManager.cs variable
        LevelUpManager.globalReference.characterLevel = loadedProgress.characterLevel;

        //Updating the loading bar
        EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);//3

        //Setting the PartyGroup.cs static references
        if (loadedProgress.partyGroup1 != null)
        {
            //Creating a new PartyGroup instance
            GameObject newPartyObj = GameObject.Instantiate(TileMapManager.globalReference.partyGroupPrefab);
            PartyGroup partyGroup1 = newPartyObj.GetComponent <PartyGroup>();

            //Setting the party variables
            partyGroup1.combatDistance = loadedProgress.partyGroup1.combatDist;

            //Looping through all of the character save data for this party group
            partyGroup1.charactersInParty = new List <Character>();
            for (int c = 0; c < loadedProgress.partyGroup1.partyCharacters.Count; ++c)
            {
                //If the current character index isn't null, we make a new character instance
                if (loadedProgress.partyGroup1.partyCharacters[c] != null)
                {
                    //Creating a new character instance
                    GameObject newCharacterObj = GameObject.Instantiate(TileMapManager.globalReference.defaultCharacterRef.gameObject);
                    Character  newCharacter    = newCharacterObj.GetComponent <Character>();

                    //Adding the new character to our new party group
                    partyGroup1.AddCharacterToGroup(newCharacter);

                    //Passing the character save data to the character instance to set all of the component variables
                    newCharacter.LoadCharacterFromSave(loadedProgress.partyGroup1.partyCharacters[c]);
                }
                //If the current character index is null, we leave the gap in the list
                else
                {
                    partyGroup1.charactersInParty.Add(null);
                }
            }

            //Updating the loading bar
            EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);//4

            //Getting the tile grid location of the player group and getting the tile connections
            TileInfo partyLocation = TileMapManager.globalReference.tileGrid[loadedProgress.partyGroup1.tileCol][loadedProgress.partyGroup1.tileRow];
            partyLocation.connectedTiles = new List <TileInfo>()
            {
                null, null, null, null, null, null
            };
            for (int coord = 0; coord < partyLocation.connectedTileCoordinates.Count; ++coord)
            {
                int col = partyLocation.connectedTileCoordinates[coord].col;
                int row = partyLocation.connectedTileCoordinates[coord].row;
                partyLocation.connectedTiles[coord] = TileMapManager.globalReference.tileGrid[col][row];
            }
            partyGroup1.GetComponent <WASDOverworldMovement>().SetCurrentTile(partyLocation);

            //Setting the static party group reference
            PartyGroup.globalReference = partyGroup1;

            //Updating the loading bar
            EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);//5
        }

        //Setting the dead characters from CharacterManager.cs
        CharacterManager.globalReference.deadCharacters = loadedProgress.deadCharacters;

        //Setting the quest log for QuestTracker.cs
        QuestTracker.globalReference.LoadQuestLogData(loadedProgress.questLog);

        //Updating the loading bar
        EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);//6

        //Setting the enemy encounters on the tile grid for CharacterManager.cs
        for (int e = 0; e < loadedProgress.enemyTileEncounters.Count; ++e)
        {
            //Getting the encounter reference
            EnemyEncounter encounterPrefab = loadedProgress.enemyTileEncounters[e].encounterPrefab.GetComponent <EnemyEncounter>();
            //Getting the enemy's tile position
            TileInfo enemyTile = TileMapManager.globalReference.tileGrid[loadedProgress.enemyTileEncounters[e].encounterTileCol][loadedProgress.enemyTileEncounters[e].encounterTileRow];
            //Telling the character manager to instantiate the prefab
            CharacterManager.globalReference.CreateEnemyEncounter(encounterPrefab, enemyTile);
        }

        //Updating the loading bar
        EventManager.TriggerEvent(LoadDataEVT.eventNum, loadEVTData);//7

        yield return(null);
    }
Example #15
0
 public void StartEncounter()
 {
     currentEncounter = this;
     LockCameraAndPlayerMovement();
     enemyController.SetFightSequence(fightSequence);
     this.StartSafeCoroutine(GenerateEnemies());
 }
Example #16
0
 public static void ClearEnemyEncounter()
 {
     currentEncounter = null;
 }