/// <summary> /// Save inventory data. /// </summary> public void Save() { DadCell[] dadCells = GetComponentsInChildren <DadCell>(true); QuickCell[] quickCells = GetComponentsInChildren <QuickCell>(true); PlayerPrefs.SetString("DaD Inventory", "0.2.0"); // Stored data format version PlayerPrefs.SetInt("Cells count", dadCells.Length); // Stored count of dad cells PlayerPrefs.SetInt("Quick count", quickCells.Length); // Stored count of quick cells if (priceGroup != null) { PlayerPrefs.SetInt("Cash amount", priceGroup.GetCash()); // Stored player's cash } for (int i = 0; i < dadCells.Length; ++i) { GameObject item = dadCells[i].GetItem(); if (item != null) { PlayerPrefs.SetString("Cell_" + i + " item", item.name); // Stored item's name StackItem stackItem = item.GetComponent <StackItem>(); if (stackItem != null) { PlayerPrefs.SetInt("Cell_" + i + " stack", stackItem.GetStack()); // Stored item's stack } else { PlayerPrefs.SetInt("Cell_" + i + " stack", 0); // Stored item's stack } } else { PlayerPrefs.SetString("Cell_" + i + " item", "null"); // Stored item's name } } for (int i = 0; i < quickCells.Length; ++i) { QuickItem quickitem = quickCells[i].GetQuickItem(); if (quickitem != null && quickitem.itemSource != null) { for (int k = 0; k < dadCells.Length; ++k) { if (dadCells[k].GetItem() == quickitem.itemSource.gameObject) { PlayerPrefs.SetInt("Quick_" + i + " link", k); // Stored item's link break; } } } else { PlayerPrefs.SetInt("Quick_" + i + " link", -1); // Stored item's link } } Debug.Log("Inventory saved"); }
/// <summary> /// Create a new item entry /// </summary> private void cmAddItem_Click(object sender, EventArgs e) { var form = new QuickItem(); if (form.ShowDialog() == DialogResult.OK) { // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert (tCat.SelectedNode.Tag as List <object>).Add(form.Item); // Issue 10 - End var catNode = tCat.SelectedNode; tCat.SelectedNode = null; tCat.SelectedNode = catNode; foreach (TreeNode t in tItems.Nodes) { if (t.Tag as BoxItem == form.Item) { tItems.SelectedNode = t; break; } } UpdateData(); } }
/// <summary> /// Edit an existing item /// </summary> private void cmEditItem_Click(object sender, EventArgs e) { if (SelectedItem != null) { var form = new QuickItem(); form.Item = SelectedItem; if (form.ShowDialog() == DialogResult.OK) { var catNode = tCat.SelectedNode; tCat.SelectedNode = null; tCat.SelectedNode = catNode; foreach (TreeNode t in tItems.Nodes) { if (t.Tag as BoxItem == form.Item) { tItems.SelectedNode = t; break; } } UpdateData(); } } }
/// <summary> /// Creates the quick item. /// </summary> /// <returns>The quick item.</returns> /// <param name="item">Item.</param> public QuickItem CreateQuickItem(GameObject item) { QuickItem res = null; DadCell dadCell = GetComponent <DadCell>(); if (item != null && dadCell != null) { ClickItem clickItem = item.GetComponent <ClickItem>(); if (clickItem != null) { // Remove old quick item RemoveQuickItem(); // Load quick item template GameObject newQuickItem = Instantiate(Resources.Load <GameObject>("QuickItemPrefab")); newQuickItem.name = item.name; res = newQuickItem.GetComponent <QuickItem>(); res.itemSource = clickItem; Image myImage = newQuickItem.GetComponent <Image>(); Image sourceImage = item.GetComponent <Image>(); if (myImage != null && sourceImage != null) { myImage.sprite = sourceImage.sprite; myImage.color = sourceImage.color; } // Place quick item to quick cell dadCell.AddItem(newQuickItem.gameObject); } } return(res); }
void Update() { if (Input.anyKeyDown == true) { int key = -1; for (int i = 1; i <= 9; ++i) { if (Input.GetKeyDown(i.ToString()) == true) { key = i; break; } } if (key != -1) { QuickCell[] quickCells = GetComponentsInChildren <QuickCell>(); if (quickCells.Length >= key - 1) { QuickItem quickItem = quickCells[key - 1].GetQuickItem(); if (quickItem != null) { quickItem.UseQuickItem(); } } } } }
// Token: 0x06001088 RID: 4232 RVA: 0x000663F8 File Offset: 0x000645F8 private void InitializeQuickItem(GameObject quickItemObject, LoadoutSlotType slot, InventoryItem inventoryItem) { int slotIndex = this.GetSlotIndex(slot); QuickItem component = quickItemObject.GetComponent <QuickItem>(); if (component) { component.gameObject.SetActive(true); for (int i = 0; i < component.gameObject.transform.childCount; i++) { component.gameObject.transform.GetChild(i).gameObject.SetActive(false); } component.gameObject.name = inventoryItem.Item.Name; component.transform.parent = GameState.Current.Player.WeaponAttachPoint; if (component.rigidbody) { component.rigidbody.isKinematic = true; } ItemConfigurationUtil.CopyProperties <UberStrikeItemQuickView>(component.Configuration, inventoryItem.Item.View); ItemConfigurationUtil.CopyCustomProperties(inventoryItem.Item.View, component.Configuration); if (component.Configuration.RechargeTime <= 0) { int index = slotIndex; QuickItemBehaviour behaviour = component.Behaviour; behaviour.OnActivated = (Action)Delegate.Combine(behaviour.OnActivated, new Action(delegate() { this.UseConsumableItem(inventoryItem); this.Restriction.DecreaseUse(index); this.NextCooldownFinishTime = Time.time + 0.5f; })); this.Restriction.InitializeSlot(slotIndex, component, inventoryItem.AmountRemaining); } else { component.Behaviour.CurrentAmount = component.Configuration.AmountRemaining; } component.Behaviour.FocusKey = this.GetFocusKey(slot); IGrenadeProjectile grenadeProjectile = component as IGrenadeProjectile; if (grenadeProjectile != null) { grenadeProjectile.OnProjectileEmitted += delegate(IGrenadeProjectile p) { Singleton <ProjectileManager> .Instance.AddProjectile(p, Singleton <WeaponController> .Instance.NextProjectileId()); GameState.Current.Actions.EmitQuickItem(p.Position, p.Velocity, inventoryItem.Item.View.ID, GameState.Current.PlayerData.Player.PlayerId, p.ID); }; } if (this._quickItems[slotIndex]) { UnityEngine.Object.Destroy(this._quickItems[slotIndex].gameObject); } this._quickItems[slotIndex] = component; } else { Debug.LogError("Failed to initialize QuickItem"); } GameData.Instance.OnQuickItemsChanged.Fire(); }
// Token: 0x06001062 RID: 4194 RVA: 0x0000B6A1 File Offset: 0x000098A1 public QuickItemBehaviour(QuickItem item, Action onActivated) { this._item = item; this.OnActivated = onActivated; this._machine = new StateMachine(); this._coolDownState = new QuickItemBehaviour.CoolingDownState(this); this._machine.RegisterState(1, this._coolDownState); }
/// <summary> /// Removes the quick item. /// </summary> public void RemoveQuickItem() { QuickItem quickItem = GetComponentInChildren <QuickItem>(); if (quickItem != null) { quickItem.Remove(); } }
// Token: 0x060016D3 RID: 5843 RVA: 0x0007E5C8 File Offset: 0x0007C7C8 public void SetQuickItem(QuickItem item, bool selected) { base.gameObject.SetActive(item != null); if (item == null) { return; } this.ammo.enabled = (item.Logic == QuickItemLogic.AmmoPack); this.armor.enabled = (item.Logic == QuickItemLogic.ArmorPack); this.health.enabled = (item.Logic == QuickItemLogic.HealthPack); this.offensiveGrenade.enabled = (item.Logic == QuickItemLogic.ExplosiveGrenade); this.springGrenade.enabled = (item.Logic == QuickItemLogic.SpringGrenade); this.amount.text = item.Behaviour.CurrentAmount.ToString(); this.SetCooldown(item.Behaviour.CooldownProgress, selected); }
// Token: 0x060010AA RID: 4266 RVA: 0x00066D44 File Offset: 0x00064F44 public void Init(QuickItem item = null) { if (item != null) { this.ItemId = item.Configuration.ID; this._totalUsesPerGame = ((item.Configuration.UsesPerGame <= 0) ? int.MaxValue : item.Configuration.UsesPerGame); this._totalUsesPerRound = ((item.Configuration.UsesPerRound <= 0) ? int.MaxValue : item.Configuration.UsesPerRound); this._totalUsesPerLife = ((item.Configuration.UsesPerLife <= 0) ? int.MaxValue : item.Configuration.UsesPerLife); } else { this.ItemId = 0; this._totalUsesPerGame = int.MaxValue; this._totalUsesPerRound = int.MaxValue; this._totalUsesPerLife = int.MaxValue; } this.RenewGameUses(); }
/// <summary> /// Raises the DaD group event. /// </summary> /// <param name="desc">Desc.</param> public void OnDadGroupEvent(DadCell.DadEventDescriptor desc) { switch (desc.triggerType) { case DadCell.TriggerType.DropEnd: GameObject item = desc.sourceCell.GetItem(); if (item != null) { // Create quick item from original item CreateQuickItem(item); } break; case DadCell.TriggerType.EmptyDrop: QuickItem myQuickItem = GetComponentInChildren <QuickItem>(); if (myQuickItem != null) { // Clear cell on drop quick item out of all cells myQuickItem.Remove(); } break; } }
// Token: 0x0600109B RID: 4251 RVA: 0x00066BA0 File Offset: 0x00064DA0 public void InitializeSlot(int index, QuickItem quickItem = null, int amountRemaining = 0) { if (index >= 0 && index < this._quickItemRestrictions.Length) { if (this.IsEnabled && quickItem != null) { if (quickItem.Configuration.ID != this._quickItemRestrictions[index].ItemId) { this._quickItemRestrictions[index].Init(quickItem); } } else { this._quickItemRestrictions[index].Init(null); } this._quickItemRestrictions[index].RenewLifeUses(); if (quickItem != null) { int num = Mathf.Min(amountRemaining, this._quickItemRestrictions[index].RemainingLifeUses); quickItem.Behaviour.CurrentAmount = num; quickItem.Configuration.AmountRemaining = num; } } }
// Token: 0x060010D0 RID: 4304 RVA: 0x000672C8 File Offset: 0x000654C8 public GameObject Create(Vector3 position, Quaternion rotation) { if (UnityItemConfiguration.Instance.IsPrefabAvailable(this.View.PrefabName)) { string prefabPath = UnityItemConfiguration.Instance.GetPrefabPath(this.View.PrefabName); Debug.Log(string.Concat(new object[] { "Create Item:", this.View.ID, ", ", this.View.Name, ", ", prefabPath })); UnityEngine.Object @object = Resources.Load <GameObject>(prefabPath); this.Prefab = (GameObject)@object; } else { Debug.Log(string.Concat(new object[] { "Create DEFAULT Item:", this.View.ID, ", ", this.View.Name, ", ", this.View.PrefabName })); this.Prefab = UnityItemConfiguration.Instance.GetDefaultItem(this.View.ItemClass); } if (this.View.ItemType == UberstrikeItemType.QuickUse) { QuickItem component = this.Prefab.GetComponent <QuickItem>(); if (component != null && component.Sfx) { Singleton <QuickItemSfxController> .Instance.RegisterQuickItemEffect(component.Logic, component.Sfx); } } GameObject gameObject = null; if (this.Prefab != null) { if (this.View.ItemClass == UberstrikeItemClass.GearHolo) { HoloGearItem component2 = this.Prefab.GetComponent <HoloGearItem>(); if (component2 && component2.Configuration.Avatar) { gameObject = (UnityEngine.Object.Instantiate(component2.Configuration.Avatar.gameObject) as GameObject); } } else { gameObject = (UnityEngine.Object.Instantiate(this.Prefab, position, rotation) as GameObject); } if (gameObject && this.View.ItemType == UberstrikeItemType.Weapon) { WeaponItem component3 = gameObject.GetComponent <WeaponItem>(); if (component3) { ItemConfigurationUtil.CopyCustomProperties(this.View, component3.Configuration); if (this.View.ItemProperties.ContainsKey(ItemPropertyType.CritDamageBonus)) { component3.Configuration.CriticalStrikeBonus = this.View.ItemProperties[ItemPropertyType.CritDamageBonus]; } else { component3.Configuration.CriticalStrikeBonus = 0; } } } } else { Debug.LogError("Trying to create item prefab, but it was null. Item Name:" + this.View.Name); } this.IsLoaded = true; return(gameObject); }
public void AppendQuickItem(QuickItem qi) { if (qi != null) { try { if (qi.SubItems.Count == 0) // causes crash if null { //Due to Issues where the updating of a textbox or richtextbox via a binding would cause //the cursor position to reset we were forced to rely on the messager service here to //access the append and inset methods GalaSoft.MvvmLight.Messaging.Messenger.Default.Send <string>(qi.Content, "ProcessQI"); //if (text.Length < 2) //{ // if (Properties.Settings.Default.DashinNotes) // { // Text += "- " + qi.Content; // } // else // { // Text += qi.Content; // } // return; //} //if(Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) //{ // var temp = CaretPoisition; // if(Text[CaretPoisition - 1] == ' ') // { // Text = Text.Insert(CaretPoisition, qi.Content); // } // else // { // Text = Text.Insert(CaretPoisition, " " + qi.Content); // temp++; // } // CaretPoisition = temp + qi.Content.Length; //} //else //{ // var substring = Text.Substring(Text.Length - 2, 2); // if (substring == "\r\n" || substring == "- ") // { // Text += qi.Content; // } // else // { // if (Properties.Settings.Default.DashinNotes) // { // Text += Environment.NewLine + "- " + qi.Content; // } // else // { // Text += Environment.NewLine + qi.Content; // } // } // CaretPoisition = Text.Length; //} } } catch (Exception e) { log.Error(e); var temp = MetroMessageBox.Show("NOPE!", e.ToString()); } } }