private void SetGUI(IGameItem gi, string parentName) { GameObject parent = GameObject.Find(parentName).gameObject; if (parent.transform.childCount > 2) { Destroy(parent.transform.GetChild(parent.transform.childCount - 1).gameObject); } GameObject itemEntry = Instantiate(SlotGUIEntry, new Vector3(0, 0, 0), Quaternion.identity, parent.transform) as GameObject; itemEntry.transform.localPosition = new Vector3(0, 0, 0); itemEntry.GetComponent <Image>().sprite = gi.GetItemBase().ItemIcon; itemEntry.GetComponent <SlotEntry>().SetGameLogic(this.gameObject); }
/// <summary> /// Given the item details, regarding game object will be attached the script type of /// detailed item type, and the content of the given item details will be copied to the new component. /// </summary> /// <param name="newEntry"></param> /// <param name="itemDetails"></param> public static void SetObjectDetails(GameObject newEntry, IGameItem itemDetails) { if (itemDetails.GetItemBase().MainType.Equals(ItemBase.MainItemType.Weapon)) { //Set the script details newEntry.AddComponent <Weapon>().SetItemBase(itemDetails.GetItemBase()); } else if (itemDetails.GetItemBase().MainType.Equals(ItemBase.MainItemType.Potion)) { //Set the script details newEntry.AddComponent <Potion>().SetItemBase(itemDetails.GetItemBase()); } else if (itemDetails.GetItemBase().MainType.Equals(ItemBase.MainItemType.Spell)) { //Set the script details newEntry.AddComponent <Spell>().SetItemBase(itemDetails.GetItemBase()); } }
private void RemoveFromInv(IGameItem item) { playerInv[currentPlayer].RemoveItemFromInventory(item.GetItemBase()); }
public void EndTurn() { if (discarded == null || equiped == null) { return; } RemoveFromInv(equiped); RemoveFromInv(discarded); if (discarded2 != null) { RemoveFromInv(discarded2); playerStat[currentPlayer].EnablePowerUp(); } equiped.UseItem(); playerInv[currentPlayer].SetGUI("BackgroundP" + (currentPlayer + 1).ToString()); playerInv[opponent].SetGUI("BackgroundP" + (opponent + 1).ToString()); playerAnim[currentPlayer].SendMessage(equiped.GetItemBase().AnimationName); PlaySound(equiped.GetItemBase().name); // End of Attack Validation if (playerStat[0].IsDead || playerStat[1].IsDead) { GameOver(); } ClearSlots(); playerStat[currentPlayer].UpdatePlayerStatus(); playerHB[currentPlayer].CurrentHealthPlayer = playerStat[currentPlayer].CurrentPlayerHealth; playerHB[opponent].CurrentHealthPlayer = playerStat[opponent].CurrentPlayerHealth; UpdateBuffsUI(0); UpdateBuffsUI(1); // End of Turn Validation if (playerStat[0].IsDead || playerStat[1].IsDead) { GameOver(); } // Change Turn int temp = currentPlayer; currentPlayer = opponent; opponent = temp; sacrificed = false; ChangeTurnUI(); // TODO: check for win condition // Give a new card to the player playerInv[currentPlayer].AddItemToInventory(cim.getRandomItem()); if (playerStat[currentPlayer].CurrentPlayerHealth <= 10) { playerInv[currentPlayer].AddItemToInventory(cim.getRandomItem()); } playerInv[currentPlayer].SetGUI("BackgroundP" + (currentPlayer + 1).ToString()); }