public void CmdSetUISlot(string eventName, GameObject obj) { ServerCache[eventName] = obj; ItemAttributes att = obj.GetComponent <ItemAttributes>(); if (eventName == "leftHand" || eventName == "rightHand") { equipment.SetHandItemSprite(eventName, att); } else { if (eventName == "id" || eventName == "storage01" || eventName == "storage02" || eventName == "suitStorage") { } else { if (att.spriteType == UI.SpriteType.Clothing) { // Debug.Log("eventName = " + eventName); Epos enumA = (Epos)Enum.Parse(typeof(Epos), eventName); equipment.syncEquipSprites[(int)enumA] = att.clothingReference; } } } }
public void SetInventorySlot(string slotName, GameObject obj) { _inventory[slotName] = obj; ItemAttributes att = obj.GetComponent <ItemAttributes>(); if (slotName == "leftHand" || slotName == "rightHand") { equipment.SetHandItemSprite(slotName, att); } else { if (slotName == "id" || slotName == "storage01" || slotName == "storage02" || slotName == "suitStorage") { //Not setting onPlayer sprites for these as they don't have any } else { if (att.spriteType == SpriteType.Clothing) { // Debug.Log("slotName = " + slotName); Epos enumA = (Epos)Enum.Parse(typeof(Epos), slotName); equipment.syncEquipSprites[(int)enumA] = att.clothingReference; } } } }
// /// <summary> /// Clear any sprite slot by setting the slot to -1 via the slotName (server). If the /// specified slot has no associated player sprite, nothing will be done. /// </summary> /// <param name="slotName">name of the slot (should match an Epos enum)</param> public void ClearItemSprite(string slotName) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), slotName); if (hasPlayerSprite(enumA)) { syncEquipSprites[(int)enumA] = -1; } }
//To set the actual sprite on the player obj public void SetHandItemSprite(string slotName, ItemAttributes att) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), slotName); if (slotName == "leftHand") { syncEquipSprites[(int)enumA] = att.NetworkInHandRefLeft(); } else { syncEquipSprites[(int)enumA] = att.NetworkInHandRefRight(); } }
//To set the actual sprite on the player obj public void SetHandItemSprite(ItemAttributes att, string hand) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), hand); if (hand == "leftHand") { syncEquipSprites[(int)enumA] = att.NetworkInHandRefLeft(); } else { syncEquipSprites[(int)enumA] = att.NetworkInHandRefRight(); } }
//To set the actual sprite on the player obj public void SetHandItemSprite(ItemAttributes att) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), playerNetworkActions.activeHand); if (playerNetworkActions.activeHand == "leftHand") { syncEquipSprites[(int)enumA] = att.NetworkInHandRefLeft(); } else { syncEquipSprites[(int)enumA] = att.NetworkInHandRefRight(); } }
public void UpdatePlayerEquipSprites(InventorySlot fromSlot, InventorySlot toSlot) { //Checks both slots and determnes the player equip sprites (only call this after a slot change) if (fromSlot != null) { if (fromSlot.IsUISlot) { if (IsEquipSpriteSlot(fromSlot)) { if (fromSlot.Item == null) { //clear equip sprite SyncEquipSprite(fromSlot.SlotName, -1); } } } } if (toSlot != null) { if (toSlot.IsUISlot) { if (IsEquipSpriteSlot(toSlot)) { if (toSlot.Item != null) { var att = toSlot.Item.GetComponent <ItemAttributes>(); if (toSlot.SlotName == "leftHand" || toSlot.SlotName == "rightHand") { equipment.SetHandItemSprite(att, toSlot.SlotName); } else if (att.spriteType == SpriteType.Clothing || att.hierarchy.Contains("headset") || att.hierarchy.Contains("storage/backpack") || att.hierarchy.Contains("storage/bag") || att.hierarchy.Contains("storage/belt") || att.hierarchy.Contains("tank")) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), toSlot.SlotName); equipment.syncEquipSprites[(int)enumA] = att.clothingReference; } } } } } }
private void SetItem(string eventName, GameObject prefab) { if (prefab == null) { return; } GameObject item = Instantiate(prefab, Vector2.zero, Quaternion.identity) as GameObject; NetworkServer.Spawn(item); ItemAttributes att = item.GetComponent <ItemAttributes>(); EquipmentPool.AddGameObject(gameObject, item); playerNetworkActions.TrySetItem(eventName, item); //Sync all clothing items across network using SyncListInt syncEquipSprites if (att.spriteType == UI.SpriteType.Clothing) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), eventName); syncEquipSprites[(int)enumA] = att.clothingReference; } }
private void SyncEquipSprite(string slotName, int spriteRef) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), slotName); equipment.syncEquipSprites[(int)enumA] = spriteRef; }
//Clear any sprite slot with -1 via the slotName (server) public void ClearItemSprite(string eventName) { Epos enumA = (Epos)Enum.Parse(typeof(Epos), eventName); syncEquipSprites[(int)enumA] = -1; }
/// <summary> /// /// </summary> /// <param name="slot"></param> /// <returns>true iff the specified Epos has an associated player sprite.</returns> private bool hasPlayerSprite(Epos slot) { return(slot != Epos.id && slot != Epos.storage01 && slot != Epos.storage02 && slot != Epos.suitStorage); }
public Epos(Epos other) { this.X = other.X; }
public Epos2(Epos other, string s) : base(other) { this.S = s; }