void Awake() { Owner = GetComponent <AgentHuman>(); Owner.BlackBoard.ActionHandler += HandleAction; Gadgets = new Dictionary <E_ItemID, Item>(); Perk = new PerkInfo(E_PerkID.None); }
public void AddPerk(Perk perk, bool AddEffect = false) { PerkInfo newPerk = Instantiate(GC.PerkInfoPrefab, PerkContent); newPerk.CurrentPerk = perk; newPerk.CurrentPerk.Info = newPerk; newPerk.Text_Name.text = perk.Name; newPerk.empInfo = this; newPerk.info = GC.infoPanel; PerksInfo.Add(newPerk); if (AddEffect == true) { newPerk.CurrentPerk.AddEffect(); } }
// --------- protected override void OnShow() { base.OnShow(); for (int i = 0; i < m_GuiGadgets.Length; i++) { if (m_GuiGadgets[i] != null) { bool shouldBeVisible = i < Gadgets.Count && Gadgets[i] != E_ItemID.None ? true : false; m_GuiGadgets[i].m_Parent.Show(shouldBeVisible, true); } } PerkInfo perk = LocalPlayer.Owner.GadgetsComponent.Perk; if (m_Perk != null) { m_Perk.m_Parent.Show(!perk.IsEmpty(), true); } RegisterFloatingFireInteractions(); ShowSelection(true); }
// ----------- void UpdateGadgets() { if (!LocalPlayer) { return; } for (int i = 0; i < Gadgets.Count; i++) { if (i >= m_GuiGadgets.Length) { break; } if (Gadgets[i] == E_ItemID.None) { continue; } Item gadget = LocalPlayer.Owner.GadgetsComponent.GetGadget(Gadgets[i]); if (gadget.Settings.ItemBehaviour == E_ItemBehaviour.Booster) { if (gadget.IsAvailableForUse() || gadget.Active) { if (m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(false); } } else { if (!m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(true); } } UpdateGuiGadgetBar(m_GuiGadgets[i], gadget.Timer, m_GuiGadgets[i].m_Settings.BoostTimer, gadget.Count, gadget.OrigCount, true); } else { if (gadget.IsAvailableForUse()) { if (m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(false); } } else { if (!m_GuiGadgets[i].m_IsTransparent) { m_GuiGadgets[i].SetAllTransparent(true); } } UpdateGuiGadgetBar(m_GuiGadgets[i], gadget.Timer, m_GuiGadgets[i].m_Settings.Timer, gadget.Count, gadget.OrigCount, false); } } PerkInfo perk = LocalPlayer.Owner.GadgetsComponent.Perk; if (!perk.IsEmpty()) { UpdateGuiGadgetBar(m_Perk, perk.Timer, m_Perk.m_Settings.Timer, 0, 0, perk.IsSprint()); } }
// ----------- //create gadgets buttons public void CreateGadgetInventory(PlayerPersistantInfo ppi) { ResetGadgetsList(); // ---------- foreach (PPIItemData d in ppi.EquipList.Items) { if (d.ID == E_ItemID.None) { continue; } Gadgets[d.EquipSlotIdx] = d.ID; } for (int i = 0; i < m_GuiGadgets.Length; i++) { m_GuiGadgets[i] = new GuiGadget <ItemSettings>(); GUIBase_Widget parent = PrepareWidget(m_LayoutMain, "Gadget_" + (i + 1)); m_GuiGadgets[i].m_Parent = parent; m_GuiGadgets[i].m_Button = GuiBaseUtils.GetButton(m_LayoutMain, s_GadgetsBtnNames[i]); m_GuiGadgets[i].m_GadgetIcon = GuiBaseUtils.GetChildSprite(parent, "GadgetIcon").Widget; m_GuiGadgets[i].m_BarBck = GuiBaseUtils.GetChildSprite(parent, "Meter_Back").Widget; m_GuiGadgets[i].m_Progress = GuiBaseUtils.GetChildSprite(parent, "Meter_BAR").Widget; m_GuiGadgets[i].m_Div2 = GuiBaseUtils.GetChildSprite(parent, "Meter_Div2").Widget; m_GuiGadgets[i].m_Div3 = GuiBaseUtils.GetChildSprite(parent, "Meter_Div3").Widget; m_GuiGadgets[i].m_PrevScale = -1; if (i >= Gadgets.Count || Gadgets[i] == E_ItemID.None) { m_GuiGadgets[i].m_Parent.Show(false, true); continue; } m_GuiGadgets[i].m_Settings = ItemSettingsManager.Instance.Get(Gadgets[i]); GuiBaseUtils.RegisterButtonDelegate(m_LayoutMain, s_GadgetsBtnNames[i], s_GadgetsBtnDelegates[i], null); GUIBase_Sprite s = GuiBaseUtils.GetChildSprite(parent, "GadgetIcon"); s.Widget.CopyMaterialSettings(m_GuiGadgets[i].m_Settings.HudWidget); m_GuiGadgets[i].m_Parent.Show(true, true); m_GuiGadgets[i].SetAllTransparent(false); Item gadget = LocalPlayer.Owner.GadgetsComponent.GetGadget(Gadgets[i]); UpdateGuiGadgetBar(m_GuiGadgets[i], gadget.Timer, m_GuiGadgets[i].m_Settings.Timer, gadget.Count, gadget.OrigCount, false); } // ---------- m_Perk = new GuiGadget <PerkSettings>(); m_Perk.m_Parent = PrepareWidget(m_LayoutMain, "Perk"); m_Perk.m_Button = GuiBaseUtils.GetButton(m_LayoutMain, "GButton"); m_Perk.m_GadgetIcon = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "GadgetIcon").Widget; m_Perk.m_BarBck = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Back").Widget; m_Perk.m_Progress = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_BAR").Widget; m_Perk.m_Div2 = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Div2").Widget; m_Perk.m_Div3 = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Div3").Widget; m_Perk.m_PrevScale = -1; PerkInfo perk = LocalPlayer.Owner.GadgetsComponent.Perk; m_Perk.m_Settings = PerkSettingsManager.Instance.Get(ppi.EquipList.Perk); if (!perk.IsEmpty()) { GUIBase_Sprite s = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "GadgetIcon"); s.Widget.CopyMaterialSettings(m_Perk.m_Settings.HudWidget); m_Perk.m_Parent.Show(true, true); UpdateGuiGadgetBar(m_Perk, perk.Timer, m_Perk.m_Settings.Timer, 0, 0, perk.IsSprint()); } else { m_Perk.m_Parent.Show(false, true); } //m_Perk.SetAllTransparent(false); m_SelIndex = SelectFirst(); m_SelectionWidget = m_LayoutMain.GetWidget("GadgetSelection_Sprite", true); ShowSelection(true); m_Initialised = true; UpdateControlsPosition(); RegisterFloatingFireInteractions(); }
private void ReadSystemData() { #region Read ExpRequire from system data var expRequireReader = XmlReader.Create(Settings.ExpRequirePath(), new XmlReaderSettings { IgnoreComments = true }); var expRequireDocument = new XmlDocument(); expRequireDocument.Load(expRequireReader); var expList = expRequireDocument.SelectSingleNode("ExpRequire").ChildNodes; for (int i = 0; i < expList.Count; i++) { expRequire.Add(Int32.Parse((expList[i] as XmlElement).GetAttribute("exp"))); } #endregion #region Read MechanicMaster From System Data XmlDocument document = new XmlDocument(); document.Load(Settings.GenerateStreamingPath($"System/Perk/MechanicMaster/data.xml")); var attributeList = document.SelectSingleNode("Perk").ChildNodes[0]; var newPerk = new PerkInfo { uniquePerkName = GameSettings.perkNameList[0], maxLevel = 50 }; perkInfo.Add(newPerk); newPerk.attributeData.Add(new Dictionary <string, string> { { "factor", (attributeList.ChildNodes[0] as XmlElement).GetAttribute("factor") } }); newPerk.attributeData.Add(new Dictionary <string, string> { { "factor", (attributeList.ChildNodes[1] as XmlElement).GetAttribute("factor") } }); newPerk.attributeData.Add(new Dictionary <string, string> { { "deltaSpeed", (attributeList.ChildNodes[2] as XmlElement).GetAttribute("deltaSpeed") } }); newPerk.attributeData.Add(new Dictionary <string, string> { { "factor", (attributeList.ChildNodes[3] as XmlElement).GetAttribute("factor") } }); var skillList = document.SelectSingleNode("Perk").ChildNodes[1]; newPerk.skillData.Add(new Dictionary <string, string> { { "factor", (skillList.ChildNodes[0] as XmlElement).GetAttribute("factor") } }); newPerk.skillData.Add(new Dictionary <string, string> { { "factor", (skillList.ChildNodes[1] as XmlElement).GetAttribute("factor") } }); newPerk.skillData.Add(null); newPerk.skillData.Add(new Dictionary <string, string> { { "deltaSpeed", (skillList.ChildNodes[3] as XmlElement).GetAttribute("deltaSpeed") } }); newPerk.skillData.Add(new Dictionary <string, string> { { "factor1", (skillList.ChildNodes[4] as XmlElement).GetAttribute("factor1") }, { "factor2", (skillList.ChildNodes[4] as XmlElement).GetAttribute("factor2") }, { "factor3", (skillList.ChildNodes[4] as XmlElement).GetAttribute("factor3") }, { "duration1", (skillList.ChildNodes[4] as XmlElement).GetAttribute("duration1") } }); newPerk.skillData.Add(null); newPerk.skillData.Add(new Dictionary <string, string> { { "deltaSpeed1", (skillList.ChildNodes[6] as XmlElement).GetAttribute("deltaSpeed1") }, { "deltaSpeed2", (skillList.ChildNodes[6] as XmlElement).GetAttribute("deltaSpeed2") }, { "deltaSpeed3", (skillList.ChildNodes[6] as XmlElement).GetAttribute("deltaSpeed3") } }); newPerk.skillData.Add(new Dictionary <string, string> { { "factor", (skillList.ChildNodes[7] as XmlElement).GetAttribute("factor") } }); newPerk.skillData.Add(new Dictionary <string, string> { { "factor", (skillList.ChildNodes[8] as XmlElement).GetAttribute("factor") }, { "upperBound", (skillList.ChildNodes[8] as XmlElement).GetAttribute("upperBound") } }); newPerk.skillData.Add(new Dictionary <string, string> { { "factor1", (skillList.ChildNodes[9] as XmlElement).GetAttribute("factor1") }, { "factor2", (skillList.ChildNodes[9] as XmlElement).GetAttribute("factor2") }, { "factor3", (skillList.ChildNodes[9] as XmlElement).GetAttribute("factor3") }, }); #endregion #region Read MadBomber from System Data document.Load(Settings.GenerateStreamingPath("System/Perk/MadBomber/Data.xml")); attributeList = document.SelectSingleNode("Perk").ChildNodes[0]; newPerk = new PerkInfo { uniquePerkName = GameSettings.perkNameList[1], maxLevel = 50 }; perkInfo.Add(newPerk); newPerk.attributeData.Add(new Dictionary <string, string> { }); #endregion for (int i = 2; i <= 4; i++) { perkInfo.Add(new PerkInfo { uniquePerkName = GameSettings.perkNameList[i] }); } }