//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);
        }
    }
Beispiel #2
0
    //Constructor function for this class
    public PartySaveData(PartyGroup groupToSave_)
    {
        this.combatDist = groupToSave_.combatDistance;

        CreateTileGrid.TileColRow tileLocation = CreateTileGrid.globalReference.GetTileCoords(groupToSave_.GetComponent <WASDOverworldMovement>().currentTile);
        this.tileCol = tileLocation.col;
        this.tileRow = tileLocation.row;

        //Looping through all of the characters in the given party and getting their save data
        this.partyCharacters = new List <global::CharacterSaveData>();
        for (int c = 0; c < groupToSave_.charactersInParty.Count; ++c)
        {
            //If the current character isn't null, we save it's data
            if (groupToSave_.charactersInParty[c] != null)
            {
                CharacterSaveData charData = new CharacterSaveData(groupToSave_.charactersInParty[c]);
                this.partyCharacters.Add(charData);
            }
            //If the current character slot is null, we add the empty slot
            else
            {
                this.partyCharacters.Add(null);
            }
        }
    }
Beispiel #3
0
 //Function called every frame
 private void Update()
 {
     //If the selected party group is null, we set the reference to group 1 automatically
     if (this.selectedGroup == null)
     {
         this.selectedGroup = PartyGroup.group1;
     }
 }
        protected virtual async Task MovePartyAsync(ITile newTile)
        {
            if (!newTile.LayoutManager.WholeTileEmpty)
            {
                throw new InvalidOperationException();
            }

            await Task.WhenAll(PartyGroup.Select(ch => ch.MoveToAsync(ch.Location.GetNew(newTile))));
        }
    //Constructor function for this class
    public PartySaveData(PartyGroup groupToSave_)
    {
        this.combatDist = groupToSave_.combatDistance;

        TileColRow tileLocation = TileMapManager.globalReference.GetTileCoords(groupToSave_.GetComponent <WASDOverworldMovement>().currentTile);

        this.tileCol = tileLocation.col;
        this.tileRow = tileLocation.row;

        //Looping through all of the characters in the given party and getting their save data
        this.partyCharacters = new List <global::CharacterSaveData>();
        for (int c = 0; c < groupToSave_.charactersInParty.Count; ++c)
        {
            //If the current character isn't null, we save it's data
            if (groupToSave_.charactersInParty[c] != null)
            {
                CharacterSaveData charData = new CharacterSaveData(groupToSave_.charactersInParty[c]);
                this.partyCharacters.Add(charData);
            }
            //If the current character slot is null, we add the empty slot
            else
            {
                this.partyCharacters.Add(null);
            }
        }

        //Looping through all of the party inventory items to save their object references
        this.inventorySlots = new List <string>();
        this.stackedItems   = new List <string>();
        for (int i = 0; i < groupToSave_.inventory.itemSlots.Count; ++i)
        {
            //Making sure the current inventory object isn't null
            if (groupToSave_.inventory.itemSlots[i] != null)
            {
                //Reference to the item's IDTag component
                IDTag itemTag = groupToSave_.inventory.itemSlots[i].GetComponent <IDTag>();

                //Saving the IDTag info
                this.inventorySlots.Add(JsonUtility.ToJson(new PrefabIDTagData(itemTag)));

                //If the current item is a stack
                if (groupToSave_.inventory.itemSlots[i].currentStackSize > 1)
                {
                    //Creating a new InventoryItemStackData class to store the item stack
                    InventoryItemStackData stack = new InventoryItemStackData(i, itemTag, groupToSave_.inventory.itemSlots[i].currentStackSize);
                    //Adding a serialized version of the stack data to our list of stacked items
                    this.stackedItems.Add(JsonUtility.ToJson(stack));
                }
            }
            //If the current item is null, we set a null slot to keep the empty space
            else
            {
                this.inventorySlots.Add("");
            }
        }
    }
    //Function called externally from UI buttons to roll for tracking skills
    public void TrackingSkillCheck()
    {
        //Telling the time panel how many hours will pass while tracking
        TimePanelUI.globalReference.AdvanceTime(this.hoursPassed);

        //Getting the reference to the tracking block of the tile that the player party is currently on
        List <EncounterBlock> trackingEncounters = PartyGroup.group1.GetComponent <WASDOverworldMovement>().currentTile.getTrackingEncounters();

        //Int to hold the highest skill roll
        int highestRoll = 0;

        //Looping through each player character in the party
        for (int pc = 0; pc < PartyGroup.group1.charactersInParty.Count; ++pc)
        {
            //Making sure the current character slot isn't null
            if (PartyGroup.group1.charactersInParty[pc] != null)
            {
                //Rolling to see what the current character's skill check is
                int skillCheck = PartyGroup.group1.charactersInParty[pc].charSkills.GetSkillLevelValueWithMod(SkillList.Survivalist);
                skillCheck += Random.Range(1, 100);

                //If the current skill check is higher than the current highest, this check becomes the new highest
                if (skillCheck > highestRoll)
                {
                    highestRoll = skillCheck;
                }
            }
        }

        //Looping through this tile's tracking encounter blocks to see what the highest success is
        int currentHighestIndex = -1;

        for (int t = 0; t < trackingEncounters.Count; ++t)
        {
            //If the current encounter's skill check is less than or equal to the best roll
            if (trackingEncounters[t].skillCheck <= highestRoll)
            {
                //If the current encounter's skill is higher than the current highest encounter's, it becomes the new highest
                if (currentHighestIndex < 0 || trackingEncounters[t].skillCheck > trackingEncounters[currentHighestIndex].skillCheck)
                {
                    currentHighestIndex = t;
                }
            }
        }

        //If the current highest index is greater than -1, the player has succeeded and we start an encounter
        if (currentHighestIndex > -1)
        {
            //Getting the variables for the player party and tile to begin combat
            LandType   tileType    = PartyGroup.group1.GetComponent <WASDOverworldMovement>().currentTile.type;
            PartyGroup playerParty = PartyGroup.group1;
            //Telling the combat manager to start the fight
            CombatManager.globalReference.InitiateCombat(tileType, playerParty, trackingEncounters[currentHighestIndex].encounterEnemies);
        }
    }
        public override void Update(GameTime time)
        {
            if (!Enabled)
            {
                return;
            }

            base.Update(time);

            if (PartyGroup.Any() && PartyGroup.All(ch => !ch.Moving && ch.MapDirection != MapDirection))
            {
                RotateParty(partyGroup.First().MapDirection, MapDirection);
            }

            foreach (var champoin in PartyGroup)
            {
                champoin.Update(time);
            }

            if (IsActive && Mouse.GetState().LeftButton == ButtonState.Pressed && prevMouse.LeftButton == ButtonState.Released ||
                Keyboard.GetState().IsKeyDown(Keys.Enter) && prevKeyboard.IsKeyUp(Keys.Enter))
            {
                var tiles = new[] { Location.Tile }.Concat(Location.Tile.Neighbors
                                                           .Select(x => x.Item1))
                .ToArray();

                var matrix       = Matrix.Identity;
                var anyTriggered = false;
                foreach (var tile in tiles)
                {
                    if (tile.Renderer.Interact(this, ref matrix, null))
                    {
                        anyTriggered = true;
                        break;
                    }
                }

                if (!anyTriggered && Hand != null && Leader != null)
                {
                    ThrowItem();
                }
            }

            prevMouse    = Mouse.GetState();
            prevKeyboard = Keyboard.GetState();
        }
    //Function called when this object is created
    private void Awake()
    {
        //Initializing the character in party dictionary
        this.charactersInParty = new List <Character>();

        //Setting the static reference for this group
        if (PartyGroup.globalReference != null && PartyGroup.globalReference != this)
        {
            Destroy(this);
            return;
        }
        else
        {
            PartyGroup.globalReference = this;
            this.inventory             = this.GetComponent <Inventory>();
        }
    }
Beispiel #9
0
    //Function called from AddObjectToThisTile to see if we should start a random encounter
    public void RollForRandomEncounter()
    {
        //If we have no random encounters, this function does nothing
        if (this.randomEncounterList.Count < 1)
        {
            return;
        }

        //Rolling to see if we meet the encounter chance
        float encounterRoll = Random.Range(0.0f, 1f);

        if (encounterRoll < this.randomEncounterChance)
        {
            //Rolling to see which encounter is spawned
            float whichEncounter = Random.Range(0.0f, 1f);

            //Looping through each encounter
            for (int e = 0; e < this.randomEncounterList.Count; ++e)
            {
                //If we find one that has a greater spawn chance than our roll
                if (this.randomEncounterList[e].encounterChance >= whichEncounter)
                {
                    //Looping through and finding the object on this tile that has the player party
                    PartyGroup playerParty = PartyGroup.group1;

                    //If we couldn't find the player party object for some reason, we stop the combat from happening
                    if (playerParty == null)
                    {
                        return;
                    }

                    //Making sure there's not an encounter before the game even begins
                    if (TimePanelUI.globalReference == null || TimePanelUI.globalReference.daysTaken < 1)
                    {
                        return;
                    }

                    //We tell the combat manager to initiate combat with this encounter
                    CombatManager.globalReference.InitiateCombat(this.type, playerParty, this.randomEncounterList[e].encounterEnemies);
                    //Now we exit out of this function so we don't try to keep spawning more encounters
                    return;
                }
            }
        }
    }
Beispiel #10
0
    //Function called when this object is created
    private void Awake()
    {
        //Initializing the character in party dictionary
        this.charactersInParty = new List <Character>();

        //Setting the static reference for this group
        if (PartyGroup.group1 != null && PartyGroup.group1 != this)
        {
            Destroy(this);
            return;
        }
        else
        {
            PartyGroup.group1 = this;
        }

        //If the character manager has already been initialized, we set this party group as the selected group
        if (CharacterManager.globalReference != null)
        {
            CharacterManager.globalReference.selectedGroup = this;
        }
    }
    void Awake()
    {
        _battleRaging = false;

        _party1 = PlayerPanel.GetComponent <PartyGroup>();
        //_party1SuccessSprite = PlayerPanel.GetComponentInChildren<SuccessSprite>(true);
        //_party1FailSprite = PlayerPanel.GetComponentInChildren<FailSprite>(true);

        _party2 = BossPanel.GetComponent <PartyGroup>();
        //_party2SuccessSprite = BossPanel.GetComponentInChildren<SuccessSprite>(true);
        //_party2FailSprite = BossPanel.GetComponentInChildren<FailSprite>(true);

        _timerPanel = TimerPanel.GetComponent <TimerPanel>();

        _resolutionPanel = GetComponentInChildren <ResolutionPanel>(true);
        _theBigButton    = GetComponentInChildren <TheBigButton>(true);
        _buttonNamePanel = GetComponentInChildren <ButtonNamePanel>(true);
        _getReadyPanel   = GetComponentInChildren <AttackGetReadyPanel>(true);
        _cannon          = GetComponentInChildren <ProjectileCannon>(true);

        _audioSource = GetComponent <AudioSource>();
    }
    //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();
    }
 //Public function called from the Character List UI in the Gameplay scene to set a new character to interpolate to
 public void ChangeGroupToFollow()
 {
     this.groupToFollow = PartyGroup.globalReference;
 }
 //Public function called from the Character List UI in the Gameplay scene to set a new character to interpolate to
 public void ChangeGroupToFollow()
 {
     this.groupToFollow = CharacterManager.globalReference.selectedGroup;
 }
Beispiel #15
0
 protected override bool CanMoveToTile(ITile tile) => PartyGroup.All(ch => !ch.Moving) && base.CanMoveToTile(tile) && tile.LayoutManager.WholeTileEmpty;
Beispiel #16
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();
                    }
                }
            }
        }
    }
    private float ApplyDamage(float currentHealth, float startHealth, float minimumDamage, float maximumDamage, float critPercent, PartyGroup partyAttack, PartyGroup partyDefend, bool bSelfDamage)
    {
        //Get a random damage value from within the specific player attack range
        float damage = Mathf.FloorToInt(UnityEngine.Random.Range(
                                            minimumDamage,
                                            maximumDamage
                                            ));

        //Determine if it's a crit.
        bool bCrit = false;

        //Can't crit yourself. That's just mean.
        if (!bSelfDamage)
        {
            bCrit = UnityEngine.Random.Range(0.0f, 1.0f) < critPercent;
            if (bCrit)
            {
                damage *= 2.0f;
            }
        }

        float newHealth = currentHealth;

        if (damage >= currentHealth)
        {
            damage    = currentHealth;
            newHealth = 0;
        }
        else
        {
            newHealth -= damage;
        }

        _attackStats = new AttackStats()
        {
            currentHealth = currentHealth,
            damage        = damage,
            newHealth     = newHealth,
            startHealth   = startHealth,
            bCrit         = bCrit,
            bSelfDamage   = bSelfDamage,
            partyAttack   = partyAttack,
            partyDefend   = partyDefend
        };

        if (!bSelfDamage)
        {
            //Do a big fancy attack animation
            partyAttack.MakeAttack(_attackStats, PressButtonNotification);

            /*partyAttack.MakeAttack(bCrit, () =>
             * {
             *  partyDefend.TakeDamage(
             *      damage,
             *      newHealth,
             *      startHealth,
             *      bCrit,
             *      bSelfDamage
             *      );
             * }, PressButtonNotification);*/
        }
        else
        {
            //Damage thyself without a big attack animationa
            partyDefend.TakeDamage(
                damage,
                newHealth,
                startHealth,
                bCrit,
                bSelfDamage
                );
        }

        return(newHealth);
    }
    //Function called from the character manager when this character is added to the player party
    public void SetCombatPosition()
    {
        //Getting the PartyGroup that this character is in
        PartyGroup ourGroup = null;

        if (PartyGroup.group1 != null && PartyGroup.group1.charactersInParty.Contains(this.GetComponent <Character>()))
        {
            ourGroup = PartyGroup.group1;
        }
        //If no party group contains this character, nothing happens
        else
        {
            return;
        }

        //Looping through each character in the player party to see if any of the combat positions overlap
        bool isOverlapping = false;

        foreach (Character partyChar in ourGroup.charactersInParty)
        {
            //Making sure the character we're checking isn't an empty slot or this character
            if (partyChar != null && partyChar.charCombatStats != this)
            {
                //If the current party character has the same row and column positions as us
                if (partyChar.charCombatStats.startingPositionCol == this.startingPositionCol && partyChar.charCombatStats.startingPositionRow == this.startingPositionRow)
                {
                    //Marking that there's overlapping positions and breaking this loop
                    isOverlapping = true;
                    break;
                }
            }
        }

        //If we make it through the first loop and there's no overlapping, we're done
        if (!isOverlapping)
        {
            return;
        }

        //Looping throuch each of the combat positions characters can be in
        for (int c = 0; c < 3; ++c)
        {
            for (int r = 0; r < 8; ++r)
            {
                //Bool that tracks if the current position is empty
                bool emptyPos = true;

                //Looping through each character in the player party
                foreach (Character currentChar in ourGroup.charactersInParty)
                {
                    //Making sure the character we're checking isn't an empty slot in the party and also isn't this character
                    if (currentChar != null && currentChar.charCombatStats != this)
                    {
                        //If the current character is in the same position as this character, we break out of this loop and go to the next tile
                        if (currentChar.charCombatStats.startingPositionRow == r && currentChar.charCombatStats.startingPositionCol == c)
                        {
                            //Marking this tile as not empty and breaking the loop
                            emptyPos = false;
                            break;
                        }
                    }
                }

                //If we make it through all of the characters without finding someone else in this character's position
                if (emptyPos)
                {
                    //We set this character to the current row and column, then end this function
                    this.startingPositionCol = c;
                    this.startingPositionRow = r;
                    return;
                }
            }
        }
    }
    //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);
    }
Beispiel #20
0
        internal void AddGroupMember(string v)
        {
            var grp = new PartyGroup(v);

            GroupMembers.Add(grp as PartyGroup);
        }
Beispiel #21
0
        protected override void Init()
        {
            Size = new Vector2 {
                X = 843, Y = 630
            };
            base.Init();

            var actions = new Action[]
            {
                () => Data.TryAdd(SectionName.Header, Header.Create()),
                () => Data.TryAdd(SectionName.Footer, Footer.Create()),
                () => Data.TryAdd(SectionName.Clock, Clock.Create()),
                () => Data.TryAdd(SectionName.PartyGroup, PartyGroup.Create(Party.Create(), NonParty.Create())),
                () => {
                    var keys = new[] {
                        Strings.Name.SideMenu.Junction,
                        Strings.Name.SideMenu.Item,
                        Strings.Name.SideMenu.Magic,
                        Strings.Name.SideMenu.GF,
                        Strings.Name.SideMenu.Status,
                        Strings.Name.SideMenu.Ability,
                        Strings.Name.SideMenu.Switch,
                        Strings.Name.SideMenu.Card,
                        Strings.Name.SideMenu.Config,
                        Strings.Name.SideMenu.Tutorial,
                        Strings.Name.SideMenu.Save,
                        Strings.Name.SideMenu.Battle
                    };

                    var values = new[] {
                        Strings.Description.SideMenu.Junction,
                        Strings.Description.SideMenu.Item,
                        Strings.Description.SideMenu.Magic,
                        Strings.Description.SideMenu.GF,
                        Strings.Description.SideMenu.Status,
                        Strings.Description.SideMenu.Ability,
                        Strings.Description.SideMenu.Switch,
                        Strings.Description.SideMenu.Card,
                        Strings.Description.SideMenu.Config,
                        Strings.Description.SideMenu.Tutorial,
                        Strings.Description.SideMenu.Save,
                        Strings.Description.SideMenu.Battle
                    };

                    if (keys.Distinct().Count() == keys.Length && values.Length == keys.Length)
                    {
                        Data.TryAdd(SectionName.SideMenu, SideMenu.Create((from i in Enumerable.Range(0, keys.Length)
                                                                           select i).ToDictionary(x => keys[x], x => values[x])));
                    }
                    else
                    {
                        Data.TryAdd(SectionName.SideMenu, null);
                    }
                }
            };

            Memory.ProcessActions(actions);
            Func <bool> sideMenuInputs = null;

            if (Data[SectionName.SideMenu] != null)
            {
                sideMenuInputs = Data[SectionName.SideMenu].Inputs;
            }
            InputDict = new Dictionary <Mode, Func <bool> >
            {
                { Mode.ChooseItem, sideMenuInputs },
                { Mode.ChooseChar, Data[SectionName.PartyGroup].Inputs },
            };
            SetMode((Mode)0);
        }