public void SetContent() { perkData = ItemDatabase.Instance.PerkDatas[perkDataId]; perkNameText.text = perkData.Name; // if unlocked, set text to unlockedColour // if cant afford, outOfReachColour if (perkMenu.PerkController != null) { if (perkMenu.PerkController.ActivePerks.ContainsKey(perkDataId)) { fillImage.color = unlockedColour; } else { if (perkMenu.PerkPoints >= perkData.Cost) { fillImage.color = lockedColour; } else { fillImage.color = outOfReachColour; } } } }
////////////////////////////////////////// /// TrainPerk() ////////////////////////////////////////// public void TrainPerk(string i_strKey) { // get the perk's data PerkData dataPerk = IDL_Perks.GetData(i_strKey); if (dataPerk != null) { // make sure the player can train the perk and the perk has another level to train int nLevel = GetPerkLevel(i_strKey); int nCost = dataPerk.GetCostToTrain(nLevel); int nXP = GetCurrentXP(); if (nCost > 0 && nXP >= nCost) { // update player's xp int nNewXP = nXP - nCost; SetProperty("XP", nNewXP); // update the perk's level Dictionary <string, int> dictPerks = GetPropertyValue <Dictionary <string, int> >("Perks"); dictPerks[i_strKey] = nLevel + 1; SetProperty("Perks", dictPerks); Save(); } } }
////////////////////////////////////////// /// CanTrainPerk() /// Returns whether or not the player /// can train the incoming perk. ////////////////////////////////////////// public bool CanTrainPerk(string i_strKey) { // get the player's perks Dictionary <string, int> dictPerks = GetPropertyValue <Dictionary <string, int> >("Perks"); // get the perk data PerkData dataPerk = IDL_Perks.GetData(i_strKey); if (dataPerk != null) { // go through all the requirements and make sure the player has the perks at that level foreach (KeyValuePair <string, int> req in dataPerk.PerkRequirements) { // the player doesn't even have required perk? fail if (dictPerks.ContainsKey(req.Key) == false) { return(false); } // the player has the required perk but not at the required level? fail if (dictPerks[req.Key] < req.Value) { return(false); } } } return(true); }
public void RemovePerk(PerkData perk) { //revert modifiers if (perk.speedMod > 0.0f) { _playerSpeed.speedMultiplier = 1.0f; } _playerWeapons.RevertBuff(perk.fireRateMod, perk.damageMod, perk.reloadMod); _perks.Remove(perk.type); _perkEnding.Remove(perk.type); }
public void AddPerk(Perk perk) { PerkData settings = perk.settings; // stash perk settings _perks[settings.type] = settings; // apply modifiers if (settings.speedMod > 0.0f) { _playerSpeed.speedMultiplier = settings.speedMod; } _playerHealth.Heal(settings.healthMod); _playerWeapons.SetBuff(settings.fireRateMod, settings.damageMod, settings.reloadMod); if (settings.shield) { _playerHealth.immune = true; shield.gameObject.SetActive(true); shield.ResetShield(); } if (settings.gunDrop != null) { if (_playerWeapons.weapons.Count >= 2) { _playerWeapons.RemoveSpecialWeapon(); } _playerWeapons.weapons.Add(settings.gunDrop); _playerWeapons.perk = settings; _playerWeapons.NewSpecialWeapon(); } if (settings.duration > 0.0f) { // cancel existing coroutine if (_perkEnding.ContainsKey(settings.type)) { //StopCoroutine( _perkEnding[settings.type] ); // This is causing unity (the editor) to crash. It's a bug within unity, we'll have to work around it. } // start new coroutine _perkEnding[settings.type] = StartCoroutine(RemoveAfterDelay(settings)); } }
public static PerkData GetExample() { PerkData ex = new PerkData(); ex.ID = "PERK_1"; ex.PerkRequirements = new Dictionary <string, int>(); ex.PerkRequirements.Add("Perk_2", 3); ex.Benefits = new List <PerkBenefit>(); PerkBenefit benefit = new PerkBenefit(); benefit.Stat = "HP"; benefit.BonusList = new List <int>() { 3, 4, 5 }; ex.Benefits.Add(benefit); ex.ExpList = new List <int>(); ex.ExpList.Add(100); return(ex); }
////////////////////////////////////////// /// GetData() /// Returns a perk's data by ID. ////////////////////////////////////////// public static PerkData GetData(string i_strKey) { // if our dictionary of data is null, we must load it if (m_dictData == null) { m_dictData = new Dictionary <string, PerkData>(); DataUtils.LoadData <PerkData>(m_dictData, "Perks"); } // get the data and send an error if it's null PerkData data = null; if (m_dictData.ContainsKey(i_strKey)) { data = m_dictData[i_strKey]; } else { Debug.LogError("Looking for perk data with key " + i_strKey + " but not found!"); } return(data); }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "FULL": if (Name == null) { Name = new SimpleSubrecord <String>(); } Name.ReadBinary(reader); break; case "DESC": if (Description == null) { Description = new SimpleSubrecord <String>(); } Description.ReadBinary(reader); break; case "ICON": if (LargeIcon == null) { LargeIcon = new SimpleSubrecord <String>(); } LargeIcon.ReadBinary(reader); break; case "MICO": if (SmallIcon == null) { SmallIcon = new SimpleSubrecord <String>(); } SmallIcon.ReadBinary(reader); break; case "CTDA": if (Requirements == null) { Requirements = new List <Condition>(); } Condition tempCTDA = new Condition(); tempCTDA.ReadBinary(reader); Requirements.Add(tempCTDA); break; case "DATA": if (Data == null) { Data = new PerkData(); } Data.ReadBinary(reader); break; case "PRKE": if (Effects == null) { Effects = new List <PerkEffect>(); } PerkEffect tempPRKE = new PerkEffect(); tempPRKE.ReadBinary(reader); Effects.Add(tempPRKE); break; default: throw new Exception(); } } }
public Perk(SimpleSubrecord <String> EditorID, SimpleSubrecord <String> Name, SimpleSubrecord <String> Description, SimpleSubrecord <String> LargeIcon, SimpleSubrecord <String> SmallIcon, List <Condition> Requirements, PerkData Data, List <PerkEffect> Effects) { this.EditorID = EditorID; this.Description = Description; this.Data = Data; }
public Perk() { EditorID = new SimpleSubrecord <String>("EDID"); Description = new SimpleSubrecord <String>("DESC"); Data = new PerkData("DATA"); }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("Name", false, out subEle)) { if (Name == null) { Name = new SimpleSubrecord <String>(); } Name.ReadXML(subEle, master); } if (ele.TryPathTo("Description", false, out subEle)) { if (Description == null) { Description = new SimpleSubrecord <String>(); } Description.ReadXML(subEle, master); } if (ele.TryPathTo("Icon/Large", false, out subEle)) { if (LargeIcon == null) { LargeIcon = new SimpleSubrecord <String>(); } LargeIcon.ReadXML(subEle, master); } if (ele.TryPathTo("Icon/Small", false, out subEle)) { if (SmallIcon == null) { SmallIcon = new SimpleSubrecord <String>(); } SmallIcon.ReadXML(subEle, master); } if (ele.TryPathTo("Requirements", false, out subEle)) { if (Requirements == null) { Requirements = new List <Condition>(); } foreach (XElement e in subEle.Elements()) { Condition tempCTDA = new Condition(); tempCTDA.ReadXML(e, master); Requirements.Add(tempCTDA); } } if (ele.TryPathTo("Data", false, out subEle)) { if (Data == null) { Data = new PerkData(); } Data.ReadXML(subEle, master); } if (ele.TryPathTo("Effects", false, out subEle)) { if (Effects == null) { Effects = new List <PerkEffect>(); } foreach (XElement e in subEle.Elements()) { PerkEffect tempPRKE = new PerkEffect(); tempPRKE.ReadXML(e, master); Effects.Add(tempPRKE); } } }
public void CmdInteractions() //Used to check all interactions between the player and the environment/entities. { if (Input.GetKeyDown(KeyCode.E)) //Checks whether or not the player is attempting to interact and shoots a raycast out. { Vector3 mousePosition = camera.GetComponentInChildren <Camera>().ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0)); RaycastHit hit; if (Physics.Raycast(mousePosition, camera.transform.forward, out hit, interactRange)) //Checks whether or not the raycast has hit anything. { if (hit.collider.tag == "Player") //If the raycast hits another player while they are downed, begin reviving. { hit.collider.GetComponent <Player>().beingRevived = true; revivingPlayer = true; } if (hit.collider.tag == "PerkMachine") //If the raycast hits a PerkMachine, check whether or not the player is able to buy said perk and add it to the curPerk list if they can. { PerkMachine perkHitRef = hit.collider.GetComponent <PerkMachine>(); if (PerkCheck(perkHitRef.Perk) == false) //Checks whether or not the player has already received this perk. { if (money >= perkHitRef.Cost) //Checks if the player has enough money for the perk. { money -= perkHitRef.Cost; curPerks.Add(PerkData.AddPerk(perkHitRef.Perk)); curPerks[curPerks.Count - 1].ApplyStats(this); } } } if (hit.collider.tag == "GunVendor") //If the raycast hits a GunVendor, check whether or not the player does not already have said gun and either allow the player to buy said gun or refill ammo. { WeaponVendor weaponHitRef = hit.collider.GetComponent <WeaponVendor>(); Debug.Log("Registered Weapon Vendor"); if (WeaponCheck(weaponHitRef.WeaponName) == false) //Checks whether or not the player already has the gun. { Debug.Log("Name Check Complete Weapon Vendor"); if (money >= weaponHitRef.Cost) //Checks whether or not the player has enough money for the gun and if they do, buys it. { money -= weaponHitRef.Cost; curWeapons.Add(WeaponType.AddWeapon(weaponHitRef.WeaponName)); } } else //If the player alreay has the gun, allows the player to buy a ammo refill. { if (money >= weaponHitRef.Cost) //Checks whether or not the player has enough money for the refill. { money -= weaponHitRef.Cost; for (int i = 0; i < curWeapons.Count; i++) //Checks whether or not the weapon is in the current weapon slot and applies the ammo refill. { if (curWeapons[i].Name == weaponHitRef.WeaponName) { curWeapons[i].Ammo = curWeapons[i].AmmoMax; } } } } } if (hit.collider.tag == "Door") //If the raycast hits a Door, check whether or not the player has enough money to open said door { Door doorHitRef = hit.collider.GetComponentInParent <Door>(); int doorIndex = GetNumberFromString(hit.collider.name); if (doorHitRef.doorOpen[doorIndex] == false) //Checks whether or not the door has already been openned. { if (money >= doorHitRef.cost[doorIndex]) //If the player has enough money for the door, buys the door and opens it. { money -= doorHitRef.cost[doorIndex]; doorHitRef.OpenDoor(doorIndex); } } } } } }
public void RemovePerk( PerkData perk ) { //revert modifiers if ( perk.speedMod > 0.0f ) { _playerSpeed.speedMultiplier = 1.0f; } _playerWeapons.RevertBuff( perk.fireRateMod, perk.damageMod, perk.reloadMod ); _perks.Remove( perk.type ); _perkEnding.Remove( perk.type ); }
public IEnumerator RemoveAfterDelay( PerkData settings ) { yield return new WaitForSeconds( settings.duration ); RemovePerk( settings ); }
public IEnumerator RemoveAfterDelay(PerkData settings) { yield return(new WaitForSeconds(settings.duration)); RemovePerk(settings); }