コード例 #1
0
    //this method is used to fetch and load data from the JSON text file
    public void loadPlayerDataFromFile()
    {
        if (File.Exists(Application.dataPath + "/Resources/SaveData/FloorTransitionData.txt"))
        {
            //fetching and creating references to players current scripts
            player_log       = gameObject.GetComponent <Player_Log>();
            characterStats   = gameObject.GetComponent <CharacterStats>();
            player_Inventory = gameObject.GetComponent <Player_Inventory>();
            skillsManager    = gameObject.GetComponent <SkillsManager>();

            Data = (PlayerObjectData)ScriptableObject.CreateInstance("PlayerObjectData");
            TextAsset jsonFile = Resources.Load("SaveData/FloorTransitionData") as TextAsset;
            JsonUtility.FromJsonOverwrite(jsonFile.text, Data);

            characterStats.loadData(Data);
            skillsManager.loadData(Data);
            player_log.loadData(Data);
            player_Inventory.loadData(Data);

            Debug.Log("Data Loaded from previous Floor");
        }
        else
        {
            Debug.Log("Transition Save Data not found");
        }
    }
コード例 #2
0
    public void savePlayerDataToFile()
    {
        //fetching and creating references to players current scripts
        player_log       = gameObject.GetComponent <Player_Log>();
        characterStats   = gameObject.GetComponent <CharacterStats>();
        player_Inventory = gameObject.GetComponent <Player_Inventory>();
        skillsManager    = gameObject.GetComponent <SkillsManager>();

        //creating scriptable instance of the PlayerObjectData that will be saved as JSON
        Data = (PlayerObjectData)ScriptableObject.CreateInstance("PlayerObjectData");

        //adding Data from different classes

        //adding Data from CharacterStats
        Data.saveCharacterStatData(characterStats.getStatBaseValue("HP"), characterStats.getCurrentHP(), characterStats.getStatBaseValue("Attack"), characterStats.getStatBaseValue("Defence"),
                                   characterStats.getStatBaseValue("Agility"), characterStats.CharacterLevel, characterStats.getExperiencePoints(), characterStats.Level_Experience_Required);

        //adding Data from inventory
        Data.saveInventoryItems(player_Inventory.getInventory());

        //Adding Data from SkillManager
        Data.saveSkillManager(skillsManager.getAllPlayerSkills(), skillsManager.getSlot1Skill(), skillsManager.getSlot2Skill());

        //Adding Data from Attacklog
        Data.savePlayerLog(player_log);

        //Saving instance to new file
        File.WriteAllText(Application.dataPath + "/Resources/SaveData/FloorTransitionData.txt",
                          JsonUtility.ToJson(Data));

        if (!transitionFloorInt.Equals(-1))
        {
            SceneManager.LoadScene(transitionFloorInt, LoadSceneMode.Single);
        }
    }
コード例 #3
0
    //updates the status of the quest
    public void updateQuestCompleteStatus(Player_Log player_Log)
    {
        currentDefeatedCount = player_Log.getTotalDefeatedViaEnemyType(targetName) - countAtAddedTime;

        if (currentDefeatedCount == requiredDefeatCount)
        {
            questComplete = true;

            //fire a notification of quest completion
            DialogueSystem.Main.displayNotification("You Have Completed " + questName + ", go to " + questGiver + " to finish and get your reward");
            Debug.Log(questComplete);
        }

        List <GameObject> temp = new List <GameObject>();

        for (int i = 0; i < targets.Count; i++)
        {
            if (targets[i] != null)
            {
                temp.Add(targets[i]);
            }
        }

        targets = temp;
    }
コード例 #4
0
    public void performQuickAttack(Player_Log playersLog)
    {
        //calulate damage from quick attack then set the amount
        float multiplier = 1.1f;

        CurrentDamageTotal = (int)calculateReducedDamage(PlayerAttack, enemy.GetComponent <EnemyBaseClass>().getDefenceStat(), multiplier);
        currentAttack      = Player_Log.QuickAttack;

        animator.SetTrigger("quickAttack");
    }
コード例 #5
0
    public void performHeavyAttack(Player_Log playersLog)
    {
        //calulate damage from heavy attack then set the amount
        float multiplier = 1.4f;

        if (enemy != null)
        {
            CurrentDamageTotal = (int)calculateReducedDamage(PlayerAttack, enemy.GetComponent <EnemyBaseClass>().getDefenceStat(), multiplier);
        }

        currentAttack = Player_Log.HeavyAttack;

        animator.SetTrigger("heavyAttack");
    }
コード例 #6
0
    //checking if the NPC Markers have been triggered
    public void updateQuestCompleteStatus(Player_Log player_Log)
    {
        bool spokenWithNPCs = true;

        for (int i = 0; i < targets.Count; i++)
        {
            if (!targets[i].GetComponent <FindNPCQuestMarker>().hasTargetNPCBeenFoundAndSpokenTo())
            {
                spokenWithNPCs = false;
            }
        }

        if (spokenWithNPCs)
        {
            questComplete = true;
        }
    }
コード例 #7
0
    //called by quest manager to update quest status
    public void updateQuestCompleteStatus(Player_Log player_Log)
    {
        bool reached = true;

        //checking the status of the markers
        for (int i = 0; i < targets.Count; i++)
        {
            if (!targets[i].GetComponent <ReachQuestLocationMarker>().checkIfMarkerIsReached())
            {
                reached = false;
            }
        }

        if (reached)
        {
            questComplete = true;
        }
    }
コード例 #8
0
 //Saving the attackLog
 public void savePlayerLog(Player_Log player_Log)
 {
     this.attackLog = player_Log.getAttackLog().ToArray();
     totalSpirits   = player_Log.getTotalDefeatedViaEnemyType(Player_Log.SpiritEnemy);
 }
コード例 #9
0
    //this method is used for calculating the percentage that the attack will hit,
    //based on the current hit change and the previous attack

    /*
     * Attack cooldowns:
     * - Heavy Attack = 10s, 15s with 5s offset
     * - Quick Attack = 3s, 5s with 2s offset
     */
    public int getHitEvadePercentage()
    {
        //Initializing required datatypes
        Player_Log player_Log         = player.GetComponent <Player_Log>();
        Dictionary <string, int> temp = new Dictionary <string, int>(); //used for temperarily holding values


        //this for each uses the player's combat history to calculate the base percentage changes
        foreach (var attackType in percentages)
        {
            float tempCount         = player_Log.getLogDataForSpecificAttack(attackType.Key);
            float tempTotal         = player_Log.getTotalLoggedAttacks();
            float initialPercentage = (tempCount / tempTotal) * 100;

            temp.Add(attackType.Key, (int)initialPercentage);
        }

        //moving temp values into main Dictionary
        foreach (var newVal in temp)
        {
            percentages[newVal.Key] = newVal.Value;
        }

        //emptying temp holder
        temp.Clear();

        //these are percentage adjustments based on simple tactics and cooldown times

        //Heavy attack checks and adjustments

        //if it was the last attack
        if (player_Log.getLastAttack().Equals(Player_Log.HeavyAttack))
        {
            if (percentages[Player_Log.HeavyAttack] > 0)
            {
                int half = percentages[Player_Log.HeavyAttack] / 2;
                percentages[Player_Log.HeavyAttack] = percentages[Player_Log.HeavyAttack] - half;

                if (percentages[Player_Log.QuickAttack] + half < 100)
                {
                    percentages[Player_Log.QuickAttack] = percentages[Player_Log.QuickAttack] + half;
                }
            }
        }

        //if the last attack is within 15s, normally would be 100 percent, but allows a lucky attack to the player, hence 15%
        if (player_Log.getLastAttack().Equals(Player_Log.HeavyAttack) && (getAttackTimeDifference() < 10))
        {
            percentages[Player_Log.HeavyAttack]    = 0;
            percentages[Player_Log.QuickAttack]    = 85;
            percentages[Player_Log.StandardAttack] = 15;
        }


        //Quick attack checks and adjustments

        //if the last attack is within 5s
        if (player_Log.getLastAttack().Equals(Player_Log.QuickAttack) && (getAttackTimeDifference() <= 5))
        {
            percentages[Player_Log.HeavyAttack]    = 85;
            percentages[Player_Log.QuickAttack]    = 0;
            percentages[Player_Log.StandardAttack] = 25;
        }

        //      use method check 2nd last attack
        if (player_Log.get2ndLastAttack().Equals(Player_Log.QuickAttack) && (getAttackTimeDifference() > 5))
        {
            percentages[Player_Log.HeavyAttack]    = percentages[Player_Log.HeavyAttack] - 10;
            percentages[Player_Log.QuickAttack]    = percentages[Player_Log.QuickAttack] + 30;
            percentages[Player_Log.StandardAttack] = percentages[Player_Log.StandardAttack] - 10;
        }

        lastAttackTimeSeconds = Time.time;
        return(0);
    }