public void EquipWeapon(Item itemToEquip) { if (EquippedWeapon != null) { UnequipWeapon(); } EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); if (EquippedWeapon.GetComponent <IProjectileWeapon>() != null) { EquippedWeapon.GetComponent <IProjectileWeapon>().ProjectileSpawn = spawnProjectile; } //EquippedWeapon.transform.SetParent(playerHand.transform); equippedWeapon.Stats = itemToEquip.BaseStats; currentlyEquippedItem = itemToEquip; characterStats.AddStatBonus(itemToEquip.BaseStats); if (itemToEquip.RndSuffixStats != null) { characterStats.AddStatBonus(itemToEquip.RndSuffixStats); } UIEventHandler.ItemEquipped(itemToEquip); UIEventHandler.StatsChanged(); }
public void EquipWeapon(Item itemToEquip) { // check if player has already equiped weapon then remove it and with its stats if (EquippedWeapon != null) { characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } else { // find the weapon object from the resources folder and parent it to the playerhand gameobject EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); Debug.Log("Created an item"); activeWeapon = EquippedWeapon.GetComponent <IWeapon>(); if (EquippedWeapon.GetComponent <IProjectTiles>() != null) { EquippedWeapon.GetComponent <IProjectTiles>().projectilePoint = spawnProjectile; } activeWeapon.Stats = itemToEquip.Stats; EquippedWeapon.transform.SetParent(playerHand.transform); characterStats.AddStatBonus(itemToEquip.Stats); Debug.Log(activeWeapon.Stats[0].GetCalculatedStatValue()); } }
public void EquipWeapon(Item itemToEquip) { if (EquippedWeapon != null) //判断当前是否有武器 { characterStats.RemoveStatBonus(equippedWeapon.Stats); //移除该武器的属性增益 Destroy(EquippedWeapon.transform.gameObject); } EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); //获得武器接口 //判断是否法杖武器 if (EquippedWeapon.GetComponent <IProjectileWeapon>() != null) { //设定法球生成位置 EquippedWeapon.GetComponent <IProjectileWeapon>().ProjectlitSpawn = spawnProjectile; } //判断是否枪械武器 if (EquippedWeapon.GetComponent <IGun>() != null) { //设置子弹生成位置 EquippedWeapon.GetComponent <IGun>().ProjectlitSpawn = bulletSpawn; } EquippedWeapon.transform.SetParent(playerHand.transform); equippedWeapon.Stats = itemToEquip.stats; currentlyEquippedItem = itemToEquip; characterStats.AddStatBonus(itemToEquip.stats); //实现武器带来的属性增益 UIEventHandler.ItemEquipped(itemToEquip); //UI事件驱动 UIEventHandler.StatsChanged(); //UI事件驱动 }
public void EquipWeapon(Item itemToEquip) { if (EquippedWeapon != null) { InventoryController.Instance.GiveItem(currentlyEquippedItem.ObjectSlug); characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } EquippedWeapon = Instantiate((GameObject)Resources.Load("Prefabs/Items/Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); if (EquippedWeapon.GetComponent <IProjectileWeapon>() != null) { EquippedWeapon.GetComponent <IProjectileWeapon>().ProjectileSpawn = spawnProjectile; } EquippedWeapon.transform.SetParent(playerHand.transform); currentlyEquippedItem = itemToEquip; equippedWeapon.Stats = itemToEquip.Stats; characterStats.AddStatBonus(itemToEquip.Stats); UIEventHandler.ItemEquipped(itemToEquip); UIEventHandler.StatsChanged(characterStats); }
public void EquipWeapon(Item itemToEquip) { if (EquipedWeapon != null) { characterStats.RemoveStatBonus(EquipedWeapon.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } EquipedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equipedWeapon = EquipedWeapon.GetComponent <IWeapon> (); if (EquipedWeapon.GetComponent <IProjectileWeapon> () != null) { EquipedWeapon.GetComponent <IProjectileWeapon> ().ProjectileSpawn = spawnProjectile; } equipedWeapon.Stats = itemToEquip.Stats; EquipedWeapon.transform.SetParent(playerHand.transform); characterStats.AddStatBonus(itemToEquip.Stats); //Debug.Log (equipedWeapon.Stats[0]); }
public void EquipWeapoon(Item itemToEquip) { if (EquipedWeapon != null) { UnequipWeapon(); } EquipedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), PlayerHand.transform.position, PlayerHand.transform.rotation); _equippedWeapon = EquipedWeapon.GetComponent <IWeapon>(); if (EquipedWeapon.GetComponent <IProjectileWeapon>() != null) { EquipedWeapon.GetComponent <IProjectileWeapon>().ProjectileSpawn = _projectileSpawn; } EquipedWeapon.transform.SetParent(PlayerHand.transform); _equippedWeapon.Stats = itemToEquip.Stats; _currentlyEquipedItem = itemToEquip; _characterStats.AddStatBonus(itemToEquip.Stats); UIEventHandler.ItemEquiped(itemToEquip); UIEventHandler.StatsChanged(); }
public void EquipWeapon(Item _Item) { if (_Item == null) { return; } if (EquippedWeapon != null) { playerCharacterStats.RemoveStatBonus(equippedIWeapon.Stats); Destroy(transformRightHand.GetChild(0).gameObject); } GameObject Weapon = Resources.Load <GameObject>("Weapons/" + _Item.ObjectSlug); if (Weapon == null) { Debug.Log("Weapon == NULL (Resources.Load failed to find a GameObject)"); return; } EquippedWeapon = (GameObject)Instantiate(Weapon, transformRightHand.position, Weapon.transform.rotation); EquippedWeapon.transform.SetParent(transformRightHand); equippedIWeapon = EquippedWeapon.GetComponent <IWeapon>(); if (equippedIWeapon != null) { equippedIWeapon.Stats = _Item.Stats; } playerCharacterStats.AddStatBonus(_Item.Stats); }
public void EquipWeapon(Item itemToEquip) { // This destroy the already equiped weapon, to be changed so it puts it back in inventory/ground... . if (EquippedWeapon != null) { characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } EquippedWeapon = Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); if (EquippedWeapon.GetComponent <IProjectileWeapon>() != null) { EquippedWeapon.GetComponent <IProjectileWeapon>().ProjectileSpawn = projectileSpawn; } equippedWeapon.Stats = itemToEquip.Stats; EquippedWeapon.transform.SetParent(playerHand.transform); characterStats.AddStatBonus(itemToEquip.Stats); Debug.Log(characterStats.Stats[0].GetCalculatedStatValue()); }
public void AddEffect(TimedEffect effect) { Debug.Log(characterStats.stats[0].CalculateStatValue()); effect.StartTime = timer; timedEffects.Add(effect); characterStats.AddStatBonus(effect.Stats); Debug.Log(characterStats.stats[0].CalculateStatValue()); }
public void EquipWeapon(Item itemToEquip) { if (EquippedWeapon != null) { characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("sword/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); _equipedWeapon = EquippedWeapon.GetComponent <IWeapon>(); _equipedWeapon.Stats = itemToEquip.Stats; EquippedWeapon.transform.SetParent(playerHand.transform); characterStats.AddStatBonus(itemToEquip.Stats); }
public void EquipWeapon(Item itemToEquip) { if (EquippedWeapon != null) { characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); Destroy(EquippedWeapon.gameObject); } EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug)); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); equippedWeapon.Stats = itemToEquip.Stats; EquippedWeapon.transform.SetParent(swordArm.transform, false); characterStats.AddStatBonus(itemToEquip.Stats); Debug.Log(itemToEquip.Stats); }
public void EquipWeapon(Item itemToEquip) { if (EquippedWeapon != null) { UnEquipWeapon(); } EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Items/Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); EquippedWeapon.transform.SetParent(playerHand.transform); equippedWeapon.Stats = itemToEquip.Stats; currentlyEquippedItem = itemToEquip; characterStats.AddStatBonus(itemToEquip.Stats); UIEventHandler.ItemEquipped(itemToEquip); UIEventHandler.StatsChanged(); }
public void EquipWeapon(Item ItemToEquip) // Hele det her system, kan også bruges til f.eks. at equip helm { if (EquippedWeapon != null) { //Fjerner Stats characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); //Fjerner våbnet i hånden Destroy(playerHand.transform.GetChild(0).gameObject); } EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + ItemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); equippedWeapon.Stats = ItemToEquip.Stats; EquippedWeapon.transform.SetParent(playerHand.transform); characterStats.AddStatBonus(ItemToEquip.Stats); }
public void EquipWeapon(Item itemToEquip) { // if we are already holding a weapon if (EquippedWeapon != null) { //get the weapon interface stats and remove any bonuses from the char stats characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } // then we create a object by looking through our resources folder for an object named after itemToEquip's ObjectSlug EquippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject> ("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equippedWeapon = EquippedWeapon.GetComponent <IWeapon> (); //testing? equippedWeapon.Stats = itemToEquip.Stats; //EquippedWeapon.GetComponent<IWeapon> ().Stats = itemToEquip.Stats; //set weapon stats EquippedWeapon.transform.SetParent(playerHand.transform); //set the parent of weapon's transform to the hand's transform characterStats.AddStatBonus(itemToEquip.Stats); // add item's stats as bonus stats to the player Debug.Log(equippedWeapon.Stats[0].CalculateFinalValue()); }
//***** commenting every line for later overhall public void EquipGear(Item itemToEquip) { if (EquippedGear != null) { characterStats.RemoveStatBonus(EquippedGear.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } //Equipping gear other the weapon would have to locate the folder itemToEquip.ItemType + itemToEquip.ObjectSlug //instantiate the item from the Item itemToEquip... can get the type from here also EquippedGear = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); //sets the equippedWeapon to the IWeapon interface.. So it is only called once, and we can get the required info equippedWeapon = EquippedGear.GetComponent <IWeapon>(); //sets the stats of the weapon to the item that was equipped equippedWeapon.Stats = itemToEquip.Stats; //sets the equipment parent to the body part it needs. Needing for animations EquippedGear.transform.SetParent(playerHand.transform); //adds the stats from the item to the player characterStats.AddStatBonus(itemToEquip.Stats); //debug the value that was added form the items added Debug.Log(itemToEquip.Stats[0].GetCalculatedStatValue()); }
public void EquipWeapon(Item itemToEquip) { if (EquippedWeapon != null) { InventoryController.Instance.GiveItem(currentlyEquippedWeapon.ObjectSlug); characterStats.RemoveStatBonus(EquippedWeapon.GetComponent <IWeapon>().Stats); Destroy(playerHand.transform.GetChild(0).gameObject); } EquippedWeapon = Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); //스테프일때 if (EquippedWeapon.GetComponent <IProjectileWeapon>() != null) { //무기에 spawnProjectile을 넣어둔다 EquippedWeapon.GetComponent <IProjectileWeapon>().ProjectileSpawn = spawnProjectile; } else if (EquippedWeapon.GetComponent <Sword>() != null) { EquippedWeapon.GetComponent <Sword>().CharacterStats = characterStats; } EquippedWeapon.transform.SetParent(playerHand.transform); equippedWeapon.Stats = itemToEquip.Stats; currentlyEquippedWeapon = itemToEquip; List <BaseStat> tmpBase = itemToEquip.Stats; characterStats.AddStatBonus(tmpBase); UIEventHandler.ItemEquipped(itemToEquip); }
public void EquipWeapon(Item itemToEquip) { Item previousWeaponItem = currentlyEquipedWeaponItem; UnequipCurrentWeapon(); currentlyEquipedWeaponItem = itemToEquip; equippedWeapon = (GameObject)Instantiate( Resources.Load("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation ); weaponComponent = equippedWeapon.GetComponent <IWeapon>(); if (equippedWeapon.GetComponent <IProjectileWeapon>() != null) { equippedWeapon.GetComponent <IProjectileWeapon>().projectileSpawn = spawnProjectile; } equippedWeapon.GetComponent <IWeapon>().Stats = itemToEquip.Stats; equippedWeapon.transform.SetParent(playerHand.transform, false); Animator animator = equippedWeapon.GetComponent <Animator>(); if (animator != null) { animator.enabled = true; } characterStats.AddStatBonus(itemToEquip.Stats); UIEventHandler.ItemEquipped(currentlyEquipedWeaponItem); UIEventHandler.StatsChanged(); }