void RemoveTribute(EquipmentObject obj) { var yourEquips = GameManager.Instance.Inventory.EquipmentPocket.items; upgradeTributes.Remove(obj.equipment.inventorySlot.slotIndex); itemButtons[buttonNumber].GetComponent <Button>().GetComponent <Image>().color = Color.white; itemButtons[buttonNumber].GetComponent <Button>().GetComponent <Image>().sprite = null; obj.equipment.equipment.DeactivateItem(obj.equipment.equipment, itemButtons[buttonNumber].gameObject); itemButtons[buttonNumber].name = "equip" + buttonNumber + 1; itemButtons[buttonNumber].GetComponentInChildren <TMP_Text>().text = ""; //make a new copy of the equipment being upgraded, then re-add all of the items already as a tribute so you can remove the exp the removed tribute was giving tempEquip = new Equipment(tempEquip.equipment); tempEquip.SetInventorySlot(activeEquip.inventorySlot); int newExp = 0; foreach (KeyValuePair <int, int> tribute in upgradeTributes) { newExp += tribute.Value; } CheckEXP(newExp); DisplayEquipment(); itemButtons[buttonNumber].GetComponent <Button>().onClick.RemoveListener(delegate { RemoveTribute(obj); }); itemButtons[buttonNumber].GetComponent <Button>().onClick.AddListener(delegate { DisplayEquipment(); }); }
public EquipmentObject Equip(EquipmentObject eq) { if (activeIndex == -1) { list.Add(Instantiate(eq.prefab).GetComponent <Equipment_Master>()); activeIndex = 0; return(null); } else { for (int i = 0; i < list.Count; i++) { if (list[i].equipment.inventoryItem == eq) { list[activeIndex].gameObject.SetActive(false); list[i].gameObject.SetActive(true); int x = activeIndex; activeIndex = i; return(list[x].equipment.inventoryItem); } } list.Add(Instantiate(eq.prefab).GetComponent <Equipment_Master>()); activeIndex = list.Count - 1; return(null); } }
public static List <EquipmentObject> GetAssignedMachine(int groupID) { try { string query = "Select a.EquipID as ID, b.EquipID as EquipID from MachineGroupRelationTable a left join EquipmentTable b on a.EquipID=b.ID where a.GroupID=" + groupID.ToString() + " order by a.EquipID asc"; DataTable dt = new DataTable(); dt = DBModel.CustomSelectQuery(query); List <EquipmentObject> obj = new List <EquipmentObject>(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { EquipmentObject temp = new EquipmentObject(); temp.ID = Convert.ToInt32(dr["ID"].ToString()); temp.EquipID = dr["EquipID"].ToString(); obj.Add(temp); } return(obj); } else { return(null); } } catch { return(null); } }
public void ChangeEquipment(EquipmentType equipmentType, EquipmentObject newEquipment) { //check if anything is currently equipped if(equipmentDict[equipmentType] != null) { //go through each stat stored in character's stat dictionary foreach(KeyValuePair<StatType, Stat> stat in statDict) { stat.Value.RemoveModifier(equipmentDict[equipmentType].modifierDict[stat.Key]); } equipmentDict[equipmentType] = null; } //assign new equipment to selected slot (or set to null if just removing equipment) if(newEquipment != null) { //go through each stat stored in character's stat dictionary foreach(KeyValuePair<StatType, Stat> stat in statDict) { stat.Value.AddModifier(newEquipment.modifierDict[stat.Key]); } equipmentDict[equipmentType] = newEquipment; } }
public void UnEquip(int slotIndex) { // if there is already something equiped, put it back in bag if (CurrentEquipment[slotIndex] != null) { EquipmentObject oldItem = CurrentEquipment[slotIndex]; inventory.AddItem(oldItem, 1); CurrentEquipment[slotIndex] = null; // Update when unequip // remove stat oldItem.Unequip(PlayerManager.instance.Player); /*if (onEquipmentChangedUpdateStats != null) * { * onEquipmentChangedUpdateStats.Invoke(null, oldItem); * }*/ // update equipment UI if (onEquipmentChangedUpdateUI != null) { onEquipmentChangedUpdateUI.Invoke(); } } }
private void UpdateItemSlotOverlayData(string slotName, EquipmentObject equipmentItem, bool ring = false, int ringIndex = 0) { GameObject slot = null; if (!ring) { slot = this.transform.Find("itemsSlots").Find(slotName).gameObject; } if (ring) { switch (ringIndex) { case 1: slot = this.transform.Find("itemsSlots").Find(RingsSlotsName.Ring1Slot.ToString()).gameObject; break; case 2: slot = this.transform.Find("itemsSlots").Find(RingsSlotsName.Ring2Slot.ToString()).gameObject; break; case 3: slot = this.transform.Find("itemsSlots").Find(RingsSlotsName.Ring3Slot.ToString()).gameObject; break; } } ColorBackgroundDeppendOfItemRarity(slot, equipmentItem); AddItemImageToSlot(slot, equipmentItem); }
void OnEquipmentChanged(EquipmentObject newItem, EquipmentObject oldItem) { if (oldItem != null) { //Armor.RemoveModifier(oldItem.Armor); //Damage.RemoveModifier(oldItem.Damage); if (oldItem.GetType() == typeof(EquipmentObject) && ((EquipmentObject)oldItem).equipSlotName == EquipmentSlotNames.Weapon) { // destroy equipment GameObject Destroy(playerHand.transform.GetChild(0).gameObject); equippedIWeapon = null; } } if (newItem != null) { //Armor.AddModifier(newItem.Armor); //Damage.AddModifier(newItem.Damage); if (newItem.GetType() == typeof(EquipmentObject) && ((EquipmentObject)newItem).equipSlotName == EquipmentSlotNames.Weapon) { // instanciate Weapon GameObject at playerHand position&rotation equippedWeapon = (GameObject)Instantiate( Resources.Load <GameObject>("Weapons/" + newItem.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); // make equippedWeapon child of playerHand equippedWeapon.transform.SetParent(playerHand.transform); equippedIWeapon = equippedWeapon.GetComponent <IWeapon>(); } } }
public bool CheckItemRequirmentsIfIsAbleToWear(EquipmentObject eqItem) { var playerInstance = GameObject.Find("Player").GetComponent <Player>(); bool wynik = true; if (playerInstance.Level < eqItem.reqLevel) { wynik = false; } if (playerInstance.Strength < eqItem.reqStr) { wynik = false; } if (playerInstance.Dexterity < eqItem.reqDex) { wynik = false; } if (playerInstance.Inteligence < eqItem.reqInt) { wynik = false; } return(wynik); }
/*public void RenderArmor(Armor newArmor) * { * int slotIndex = (int) newArmor.equipSlot; * * SetEquipmentBlendShapes(newArmor, 100); * * SkinnedMeshRenderer newMesh = Instantiate<SkinnedMeshRenderer>(newArmor.mesh, targetMesh.transform, true); * * newMesh.bones = targetMesh.bones; * newMesh.rootBone = targetMesh.rootBone; * * currentMesh[slotIndex] = newMesh; * }*/ /*public void Unequip(int slotIndex) * { * if (currentEquipment[slotIndex] != null) * { * if (currentMesh[slotIndex] != null) * { * Destroy(currentMesh[slotIndex].gameObject); * } * Equipment oldItem = currentEquipment[slotIndex]; * //TODO if for armors * SetEquipmentBlendShapes(oldItem, 0); * inventory.Add(oldItem); * if (currentEquipment[slotIndex].GetType() == typeof(Weapon)) * { * UnequipWeaponObject((Weapon) currentEquipment[slotIndex]); * } * * currentEquipment[slotIndex] = null; * * if (onEquipmentchanged != null) * { * onEquipmentchanged.Invoke(null, oldItem); * } * } * * }*/ /*public void SetEquipmentBlendShapes(Equipment item, int weight) * { * foreach (EquipmentMeshRegion blendShape in item.coveredMeshRegions) * { * targetMesh.SetBlendShapeWeight((int)blendShape, weight); * } * }*/ public void InstantaiateEquipment(Equipment item) { EquipmentSlot equipmentSlot = item.equipSlot; switch (equipmentSlot) { case EquipmentSlot.RangedWeapon: RangedWeaapon = item.EquipmentPrefab; if (equippedGun != null) { Destroy(equippedGun.gameObject); } equippedGun = Instantiate(item.EquipmentPrefab, weaponHold.position, weaponHold.rotation); equippedGun.transform.parent = weaponHold; _gunController.equippedGun = (Gun)equippedGun; break; case EquipmentSlot.MeleeWeapon: MeleeWeapon = item.EquipmentPrefab; break; case EquipmentSlot.Server: Server = item.EquipmentPrefab; break; } }
/// <summary> /// 通过Spine生成的json,atlas文件创建角色 /// </summary> /// <param name="skeletonJson">Skeleton json.</param> /// <param name="atlasText">Atlas text.</param> /// <param name="textures">Textures.</param> /// <param name="material">Material.</param> /// <param name="initialize">If set to <c>true</c> initialize.</param> /// <param name="skinName">Skin name.</param> /// <param name="animationName">Animation name.</param> /// <param name="loop">If set to <c>true</c> loop.</param> public void Create(SpineAvatarType avatarType, EquipmentObject eo, Material material, bool initialize, string name, string skinName, string animationName, bool loop, RoleEquipmentData data, Action <Avatar> createSucCallBack, Action <string> failCallBack, Action <bool> createQueueCallBack, bool isTP) { #if UNITY_ANDROID GameManager.Instance.StartCoroutine(Create(avatarType, eo, SkeletonDataAsset.CreateRuntimeInstance(eo.equipmentJsonAsset, AtlasAsset.CreateRuntimeInstance(eo.equipmentTxtAsset, eo.equipmentTexture_Alpha, eo.equipmentTexture_RGB, material, initialize, true), initialize), name, animationName, skinName, loop, data, createSucCallBack, failCallBack, createQueueCallBack, isTP)); #elif UNITY_IPHONE || UNITY_EDITOR GameManager.Instance.StartCoroutine(Create(avatarType, eo, SkeletonDataAsset.CreateRuntimeInstance(eo.equipmentJsonAsset, AtlasAsset.CreateRuntimeInstance(eo.equipmentTxtAsset, new Texture2D[] { eo.equipmentTexture }, material, initialize), initialize), name, animationName, skinName, loop, data, createSucCallBack, failCallBack, createQueueCallBack, isTP)); #endif }
private void ColorBackgroundDeppendOfItemRarity(GameObject slot, EquipmentObject item) { slot.transform.Find("BackgroundRarityColor").gameObject.SetActive(true); Color32 bgColor; rarityColors.TryGetValue(item.rarity.ToString(), out bgColor); slot.transform.Find("BackgroundRarityColor").GetComponent <Image>().color = bgColor; }
/// <summary> /// 通过TextAsset,Texture2D[],Material 获取AtlasRegion集合 /// </summary> /// <returns>The equipment atlas regions.</returns> /// <param name="textAsset">Text asset.</param> /// <param name="textures">Textures.</param> /// <param name="material">Material.</param> public List <AtlasRegion> GetEquipmentAtlasRegions(EquipmentObject eo, Material material) { #if UNITY_ANDROID return(AtlasAsset.CreateRuntimeInstance(eo.equipmentTxtAsset, eo.equipmentTexture_Alpha, eo.equipmentTexture_RGB, material, true, true).GetAtlas(true).AtlasRegionList); #elif UNITY_IPHONE || UNITY_EDITOR return(AtlasAsset.CreateRuntimeInstance(eo.equipmentTxtAsset, new Texture2D[] { eo.equipmentTexture }, material, true).GetAtlas().AtlasRegionList); #endif }
public EquipmentObject createEquipmentObject() { EquipmentObject equipmentObject = new EquipmentObject(); equipmentObject.Scale = 1; equipmentObject.Velocity = new Vector3(0, 0, 0); return(equipmentObject); }
public void ClearSlot() { item = null; icon.sprite = null; // not visible icon.enabled = false; removeButon.enabled = false; }
public void AddItem(EquipmentObject newItem) { item = newItem; icon.sprite = item.Icon; // visible icon.enabled = true; removeButon.enabled = true; }
public IActionResult AddEquipment([FromBody] EquipmentObject equipment) { if (equipment != null) { _service.AddEquipment(equipment); } return(Ok()); }
public static void ExchangeItemForCurrency(GearSlot gearSlot, InventoryObject sellerInv, CurrencyObject mainCurrency) { EquipmentObject eq = gearSlot.gear; int itemPrice = eq.SellPrice; mainCurrency.IncreaseAmount(itemPrice); sellerInv.RemoveGear(gearSlot); Debug.Log("Item sold"); }
public bool setEquipmentObject(EquipmentObject _EquipmentObject) { foreach (BodyPart var_BodyPart in this.bodyParts) { if (var_BodyPart.Id == _EquipmentObject.PositionInInventory) { var_BodyPart.setEquipmentObject(_EquipmentObject); } } return(false); }
public bool containsEquipmentObject(EquipmentObject _EquipmentObject) { foreach (BodyPart var_BodyPart in this.bodyParts) { if (var_BodyPart.Equipment == _EquipmentObject) { return(true); } } return(false); }
public bool setEquipmentObject(EquipmentObject _EquipmentObject) { if (this.equipment != null) { return(false); } else { this.equipment = _EquipmentObject; return(true); } }
public BodyPart(int _Id, Vector3 _Position, Color _Color, String _TexturePath) { this.position = _Position; this.color = _Color; this.texturePath = _TexturePath; this.direction = DirectionEnum.Down; this.animation = new Animation.Animations.StandAnimation(this); this.scale = 1.0f; this.size = new Vector3(32, 32, 0); this.equipment = null; this.id = _Id; this.acceptedItemTypes = new List<ItemEnum>(); }
public override void ClearData() { if (mObject == null) { InterruptDown(); } else { Destroy(mObject); mObject = null; } base.ClearData(); }
public void BuyItem(Transform transform) { int indexOfButton = transform.GetSiblingIndex(); if (indexOfButton < shopList.ItemsToBuy.Length) { EquipmentObject itemToBuy = shopList.ItemsToBuy[indexOfButton]; if (inventory.BuyItem(itemToBuy, currencyID)) { currentPlayerHealth.maxRunTimeValue = currentPlayerHealth.maxRunTimeValue + (itemToBuy.defenceBonus * 2); currentPlayerHealth.runTimeValue = currentPlayerHealth.maxRunTimeValue; playerHealthObserver.Raise(); } } }
public BodyPart(int _Id, Vector3 _Position, Color _Color, String _TexturePath) { this.position = _Position; this.color = _Color; this.texturePath = _TexturePath; this.direction = DirectionEnum.Down; this.animation = new StandAnimation(this); this.scale = 1.0f; this.size = new Vector3(32, 32, 0); this.equipment = null; this.id = _Id; this.acceptedItemTypes = new List <ItemEnum>(); this.standartTextureShift = new Vector2(0, 0); }
private void Awake() { if (instance != null) { Debug.LogWarning("More than one instance of EquipmentManager found !"); return; } instance = this; // init new Equipment Array with the length of EquipmentSlot that exist int numSlots = System.Enum.GetNames(typeof(EquipmentSlotNames)).Length; CurrentEquipment = new EquipmentObject[numSlots]; }
public BodyPart(SerializationInfo info, StreamingContext ctxt) { this.position = (Vector3)info.GetValue("position", typeof(Vector3)); this.color = (Color)info.GetValue("color", typeof(Color)); this.texturePath = (String)info.GetValue("texturePath", typeof(String)); this.standartTextureShift = (Vector2)info.GetValue("standartTextureShift", typeof(Vector2)); this.scale = (float)info.GetValue("scale", typeof(float)); this.size = (Vector3)info.GetValue("size", typeof(Vector3)); this.equipment = (EquipmentObject)info.GetValue("equipment", typeof(EquipmentObject)); this.id = (int)info.GetValue("id", typeof(int)); this.acceptedItemTypes = (List<ItemEnum>)info.GetValue("acceptedItemTypes", typeof(List<ItemEnum>)); this.animation = new Animation.Animations.StandAnimation(this); }
/// <summary> /// Instantie tous les objets physiques reliés à cet équipement /// </summary> /// <param name="parent">Objet sur lequel les équipements vont être instanciés</param> public List <EquipmentObject> InstantiateAllObjects(Transform parent, Ship ship) { spawnedEquipments = new List <EquipmentObject>(); foreach (EquipmentObject equipObject in relatedEquipmentObjectsPrefabs) { EquipmentObject spawnedEquip = Instantiate(equipObject, parent); spawnedEquip.SetUp(parent, ship); spawnedEquipments.Add(spawnedEquip); } return(spawnedEquipments); }
public BodyPart(SerializationInfo info, StreamingContext ctxt) { this.position = (Vector3)info.GetValue("position", typeof(Vector3)); this.color = (Color)info.GetValue("color", typeof(Color)); this.texturePath = (String)info.GetValue("texturePath", typeof(String)); this.standartTextureShift = (Vector2)info.GetValue("standartTextureShift", typeof(Vector2)); this.scale = (float)info.GetValue("scale", typeof(float)); this.size = (Vector3)info.GetValue("size", typeof(Vector3)); this.equipment = (EquipmentObject)info.GetValue("equipment", typeof(EquipmentObject)); this.id = (int)info.GetValue("id", typeof(int)); this.acceptedItemTypes = (List <ItemEnum>)info.GetValue("acceptedItemTypes", typeof(List <ItemEnum>)); this.positionInInventory = (Vector2)info.GetValue("positionInInventory", typeof(Vector2)); this.animation = new StandAnimation(this); }
public bool removeEquipment(EquipmentObject _EquipmentObject) { foreach (BodyPart var_BodyPart in this.bodyParts) { if (var_BodyPart.Equipment != null) { if (var_BodyPart.Equipment.Equals(_EquipmentObject)) { var_BodyPart.Equipment = null; return(true); } } } return(false); }
public static void TradeItem(GearSlot gearSlot, InventoryObject buyerInv, InventoryObject sellerInv) { EquipmentObject eq = gearSlot.gear; int itemPrice = eq.BuyPrice; if (ExchangeMainCurrency(itemPrice, buyerInv, sellerInv)) { buyerInv.AddGear(eq); Debug.Log("You acquired an item: " + eq); sellerInv.RemoveGear(gearSlot); } else { Debug.Log("Trade failed."); } }
private void createBodySettings(RaceObject _RaceObject, RaceEnum _ObjectRace, GenderEnum _ObjectGender) { switch (_ObjectRace) { case RaceEnum.Ogre: { _RaceObject.Body = new BodyHuman(); ((BodyHuman)_RaceObject.Body).MainBody.TexturePath = "Character/Ogre1"; _RaceObject.Size = new Vector3(80, 96, 0); _RaceObject.Body.setSize(new Vector3(80, 96, 0)); //npcObject.CollisionBounds.Add(new Rectangle(17 + (int)npcObject.Size.X / 2, 69 + (int)npcObject.Size.Y / 2, 49, 25)); break; } case RaceEnum.Human: { _RaceObject.Body = new BodyHuman(); switch (_ObjectGender) { case GenderEnum.Male: ((BodyHuman)_RaceObject.Body).MainBody.TexturePath = "Character/BodyMale"; break; case GenderEnum.Female: ((BodyHuman)_RaceObject.Body).MainBody.TexturePath = "Character/BodyFemale"; break; } _RaceObject.CollisionBounds.Add(new Rectangle(8, 20, 12, 2)); ((BodyHuman)_RaceObject.Body).Hair.TexturePath = "Character/Hair1"; EquipmentObject var_EquipmentObject_Armor = GameLibrary.Factory.EquipmentFactory.equipmentFactory.createEquipmentArmorObject(GameLibrary.Enums.ArmorEnum.GoldenArmor); var_EquipmentObject_Armor.PositionInInventory = 0; _RaceObject.Body.setEquipmentObject(var_EquipmentObject_Armor); EquipmentObject var_EquipmentObject_Sword = GameLibrary.Factory.EquipmentFactory.equipmentFactory.createEquipmentWeaponObject(GameLibrary.Enums.WeaponEnum.Sword); var_EquipmentObject_Sword.PositionInInventory = 1; _RaceObject.Body.setEquipmentObject(var_EquipmentObject_Sword); break; } } }
//from the list of selected equipment, the one clicked on is added to the corresponded spot in the item tributes public void SelectEquipment(EquipmentObject obj) { if (itemButtons[buttonNumber].GetComponent <Button>().GetComponent <Image>().sprite == null) { upgradeTributes.Add(obj.equipment.inventorySlot.slotIndex, obj.equipment.expGiven); itemButtons[buttonNumber].GetComponent <Button>().GetComponent <Image>().color = Color.white; itemButtons[buttonNumber].GetComponent <Button>().GetComponent <Image>().sprite = obj.equipment.equipment.sprite; obj.equipment.equipment.ActivateItem(obj.equipment.equipment, itemButtons[buttonNumber].gameObject); itemButtons[buttonNumber].name = obj.equipment.itemName + "(" + activeEquip.inventorySlot.itemLevel + ")"; itemButtons[buttonNumber].GetComponentInChildren <TMP_Text>().text = "Lv. " + obj.equipment.level; CheckEXP(obj.equipment.expGiven); DisplayEquipment(); itemButtons[buttonNumber].GetComponent <Button>().onClick.RemoveListener(delegate { DisplayEquipment(); }); itemButtons[buttonNumber].GetComponent <Button>().onClick.AddListener(delegate { RemoveTribute(obj); }); } }
public bool setEquipmentObject(EquipmentObject _EquipmentObject) { foreach (BodyPart var_BodyPart in this.bodyParts) { if (var_BodyPart.Id == _EquipmentObject.PositionInInventory) { var_BodyPart.setEquipmentObject(_EquipmentObject); } } return false; }
public bool containsEquipmentObject(EquipmentObject _EquipmentObject) { foreach (BodyPart var_BodyPart in this.bodyParts) { if (var_BodyPart.Equipment == _EquipmentObject) { return true; } } return false; }
public bool removeEquipment(EquipmentObject _EquipmentObject) { foreach (BodyPart var_BodyPart in this.bodyParts) { if(var_BodyPart.Equipment!=null) { if (var_BodyPart.Equipment.Equals(_EquipmentObject)) { var_BodyPart.Equipment = null; return true; } } } return false; }
public bool setEquipmentObject(EquipmentObject _EquipmentObject) { if (this.equipment != null) { return false; } else { this.equipment = _EquipmentObject; return true; } }