public void Initialize(InventaryViewer inventary_viewer, InventaryGroup group) { this.inventary_viewer = inventary_viewer; this.mtransform = this.transform; this.thisGroup = group; itemViewers = new List <InventaryItemViewer>(GetComponentsInChildren <InventaryItemViewer>()); while (itemViewers.Count > 0) { InventaryItemViewer viewer = itemViewers[0]; Destroy(viewer.gameObject); itemViewers.RemoveAt(0); } itemViewers.Clear(); for (int i = 0; i < thisGroup.MaxCapacity; i++) { InventaryItemViewer itemViewer = Instantiate <InventaryItemViewer>(ItemViewerPrefab, this.mtransform); itemViewer.Initialize(this); itemViewers.Add(itemViewer); if (thisGroup.items != null && i < thisGroup.items.Count) { itemViewer.SetItem(thisGroup.items[i]); } } thisGroup.AddedItem += new ItemEvent(AddItem); thisGroup.RemovedItem += new ItemEvent(RemoveItem); }
public ItemController GetSelectedAt(string group) { InventaryGroup invgroup = GetGroup(group); if (invgroup == null) { return(null); } return(invgroup.GetSelected()); }
public override void Use(CharController character) { InventaryGroup g = character.inventary.GetGroup("Ammo"); if (g != null) { ItemController it = g.GetItemByName(getGunStats().ammoName); if (it != null && it is ConsumableItem) { ConsumableItem consumable = (it as ConsumableItem); int lack = (this.getGunStats().maxClip - ActualAmmo); if (lack <= 0) { return; } else { int getUnits = (consumable.Units < lack ? consumable.Units : lack); reloading = consumable; consumable.Use(character); consumable.Units -= getUnits; ActualAmmo += getUnits; int index = character.anim.GetLayerIndex(Stats.animLayer); character.anim.Play(Stats.animation, index); character.anim.SetLayerWeight(index, 1); character.ik.DisableLeftHand = consumable.getConsumableStats().DisableLeftHand; character.ik.DisableRightHand = consumable.getConsumableStats().DisableRightHands; Debug.Log(Stats.animation); Debug.Log(index); } } } base.Use(character); }
internal void Initialize(InventaryController inventaryController) { inventary = inventaryController; foreach (InventaryGroupViewer v in viewers) { if (!mappedViewers.ContainsKey(v.SlotType)) { mappedViewers.Add(v.SlotType, v); InventaryGroup group = inventaryController.GetGroup(v.SlotType); if (group != null) { v.Initialize(this, group); } } } SceneViewer.Initialize(this, new InventaryGroup() { MaxCapacity = MaxSceneItems }); Scroll.Initialize(); }
public void GunControl() { ItemController selectedWeapon = inventary.GetSelectedAt("PrimaryWeapon"); if (selectedWeapon != null) { selectedWeapon.Show(); if (selectedWeapon is GunController) { states.Armed = true; GunController GUN = (selectedWeapon as GunController); this.SetHandState(GUN.getGunStats().HandsState); ik.LeftHandPosition = GUN.leftHandPosition; ik.LeftElbowPosition = GUN.leftElbowPosition; if (Player) { GUN.DrawCrossHair(cam); if (!states.Inventary) { if (states.Shooting) { if (!GUN.Attack(this)) { notShooting = false; } } else if (states.Reloading) { GUN.Use(this); } else if (states.FireMode) { GUN.NextFireState(); } } } } else { states.Armed = false; } } else { states.Armed = false; } InventaryGroup weaponGroup = inventary.GetGroup("PrimaryWeapon"); if (weaponGroup != null) { if (states.W1) { weaponGroup.Select(0); } if (states.W2) { weaponGroup.Select(1); } if (states.W3) { weaponGroup.Select(2); } } }