public void SetValues(GameObject ItemDisplayObject, GodStats God) { if (God) { CheckItems(God); } if (ItemDisplayObject) { ItemDisplay ID = ItemDisplayObject.GetComponent <ItemDisplay>(); if (ID.iName) { ID.iName.text = name; } if (ID.iIcon) { ID.iIcon.sprite = icon; } if (ID.iGold) { ID.iGold.text = goldNeeded.ToString() + "g"; } if (God.gold) { God.gold.text = "Gold: " + God.GodGold.ToString(); } } }
// Use this for initialization void Start() { pickupSkill = GameObject.Find("Pickup Skill").GetComponent <SkillCheck>(); arrowSkill = GameObject.Find("Arrow Skill").GetComponent <SkillCheck>(); healthSkill = GameObject.Find("Health Skill").GetComponent <SkillCheck>(); buffSkill = GameObject.Find("Buff Skill").GetComponent <SkillCheck>(); m_GodHandler = this.GetComponentInParent <GodHandler>().God; // Listener for the power change m_GodHandler.onPowerChange += ReactToChange; // Listener for level change m_GodHandler.onLevelChange += ReactToChange; // Listener for skill point change; m_GodHandler.onPointsChange += ReactToChange; if (skill) { skill.SetValues(this.gameObject, m_GodHandler); } EnableSkills(); }
// Get new item public bool GetItem(GodStats God) { God.GodGold -= goldNeeded; God.gold.text = "Gold: " + God.GodGold.ToString(); God.Inventory.Add(this); return(true); }
public void SetValues(GameObject SkillDisplayObject, GodStats God) { if (God) { CheckSkills(God); } if (SkillDisplayObject) { SkillDisplay SD = SkillDisplayObject.GetComponent <SkillDisplay>(); if (SD.sName) { SD.sName.text = name; } if (SD.sIcon) { SD.sIcon.sprite = icon; } if (SD.sLevel) { SD.sLevel.text = levelNeeded.ToString(); } if (SD.sPoints) { SD.sPoints.text = pointsNeeded.ToString() + " SP"; } } }
public void SaveGame() { SaveSystem.SaveGame(this); GodStats god = GameObject.Find("God").GetComponent <GodStats>(); god.SavePlayer(); }
// Check if the player is able to get the item public bool CheckItems(GodStats God) { // Check if god has enough gold if (God.GodGold < goldNeeded) { return(false); } return(true); }
public PlayerData(GodStats god) { level = god.GodLevel; power = god.GodPower; gold = god.GodGold; skillPoints = god.GodSkillPoints; skills = new int[god.GodSkills.Count]; items = new int[god.Inventory.Count]; foreach (Skills skill in god.GodSkills) { switch (skill.ID) { case 1: skills[sIndex] = 1; sIndex++; break; case 2: skills[sIndex] = 2; sIndex++; break; case 3: skills[sIndex] = 3; sIndex++; break; case 4: skills[sIndex] = 4; sIndex++; break; } } foreach (Items item in god.Inventory) { switch (item.ID) { case 1: items[iIndex] = 1; iIndex++; break; case 2: items[iIndex] = 2; iIndex++; break; } } }
public static void SavePlayer(GodStats god) { playerPath = Application.persistentDataPath + "/player.save"; BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(playerPath, FileMode.Create); PlayerData data = new PlayerData(god); formatter.Serialize(stream, data); stream.Close(); }
public void LoadGame() { GodStats god = GameObject.Find("God").GetComponent <GodStats>(); god.LoadPlayer(); GameData data = SaveSystem.LoadGame(); slider.value = data.dialogueVolume; slider1.value = data.mainVolume; SetVolume(audioSrc); SetVolume(audioSrc1); }
// Check if player already has item public bool EnableItem(GodStats God) { // go through all the items that the god currently has List <Items> .Enumerator items = God.Inventory.GetEnumerator(); while (items.MoveNext()) { var currItem = items.Current; if (currItem.name == this.name) { return(true); } } return(false); }
// Check if player already has skill public bool EnableSkill(GodStats God) { // go through all the skills that the god currently has; List <Skills> .Enumerator skills = God.GodSkills.GetEnumerator(); while (skills.MoveNext()) { var currSkill = skills.Current; if (currSkill.name == this.name) { return(true); } } return(false); }
// Check if the player is able to get the skill public bool CheckSkills(GodStats God) { // Check if god is right level if (God.GodLevel < levelNeeded) { return(false); } // Check if god has enough skill points if (God.GodSkillPoints < pointsNeeded) { return(false); } return(true); }
// Use this for initialization void Start() { healthPotion = GameObject.Find("Health Potion").GetComponent <ItemCheck>(); enragePotion = GameObject.Find("Enrage Potion").GetComponent <ItemCheck>(); m_GodHandler = this.GetComponentInParent <GodHandler>().God; // Listener for the gold change m_GodHandler.onGoldChange += ReactToChange; if (item) { item.SetValues(this.gameObject, m_GodHandler); } EnableItems(); }
// Use this for initialization void Start() { PauseGame gm = GameObject.Find("GameManager").GetComponent <PauseGame>(); GodStats god = GameObject.Find("Player").GetComponent <GodStats>(); string path = SaveSystem.gamePath; Debug.Log(path); if (File.Exists(path)) { gm.LoadGame(); SceneManager.LoadScene("MainMenu"); } else { gm.SaveGame(); SceneManager.LoadScene("MainMenu"); } }
// Get new skill public bool GetSkill(GodStats God) { God.GodSkillPoints -= pointsNeeded; God.GodSkills.Add(this); return(true); }