Example #1
0
	// Use this for initialization
	void Start () {
		myPhotonView = GetComponent<PhotonView>();
		construction = Storage.LoadById<RPGConstruction>(ID, new RPGConstruction());
		constructedNPC = Storage.LoadById<RPGNPC>(NPCID, new RPGNPC());
		if(construction != null)
		{
			GameObject.FindGameObjectWithTag("WorldManager").GetComponent<WorldManager>().AddConstruction(construction);
		}
		for (int i = 0; i < construction.requiredItems.Count; i++) {
			if(construction.requiredItems[i].PreffixTarget == PreffixType.ITEM)
			{
				InventoryItem newInventoryItem = new InventoryItem();
				newInventoryItem.GenerateNewInventoryItem(Storage.LoadById<RPGItem>(construction.requiredItems[i].TaskTarget, new RPGItem()), construction.requiredItems[i].Tasklevel, construction.requiredItems[i].AmountToReach);
				requiredItems.Add(newInventoryItem);
				requiredItemsQuantity.Add(construction.requiredItems[i].AmountToReach);
            }
        }
		if(trigger)
		{
			triggerCollider = trigger.GetComponent<Collider>();
			trigger.transform.localScale = startScale;
		}
		dragDropCollider.enabled = false;
		if(!PhotonNetwork.isMasterClient)
			RequestConstructionUpdate();
	}
	public void LoadRequiredItems()
	{
		for (int i = 0; i < requiredItems.Count; i++) {
			if(requiredItems[i].PreffixTarget == PreffixType.ITEM)
			{
				InventoryItem newInventoryItem = new InventoryItem();
				newInventoryItem.GenerateNewInventoryItem(Storage.LoadById<RPGItem>(requiredItems[i].TaskTarget, new RPGItem()), requiredItems[i].Tasklevel, requiredItems[i].AmountToReach);
			}
		}
	}
Example #3
0
	public void DisplayQuestItems()
	{
		questItemsGrid.SetActive(true);
		questItems.Clear();
		for (int i = 0; i < activeQuestStep.Tasks.Count; i++) {
			if(activeQuestStep.Tasks[i].TaskType == TaskTypeEnum.BringItem)
			{
				InventoryItem item = new InventoryItem();
				if(activeQuestStep.Tasks[i].PreffixTarget == PreffixType.ARMOR)
				{
					item.GenerateNewInventoryItem(Storage.LoadById<RPGArmor>(activeQuestStep.Tasks[i].TaskTarget, new RPGArmor()), activeQuestStep.Tasks[i].Tasklevel, activeQuestStep.Tasks[i].AmountToReach);
				}
				else if(activeQuestStep.Tasks[i].PreffixTarget == PreffixType.ITEM)
				{
					item.GenerateNewInventoryItem(Storage.LoadById<RPGItem>(activeQuestStep.Tasks[i].TaskTarget, new RPGItem()), activeQuestStep.Tasks[i].Tasklevel, activeQuestStep.Tasks[i].AmountToReach);
				}
				questItems.Add(item);
			}
		}
		int num = questItems.Count - itemTiles.Count;
		if(num>0)
		{
			for (int i = 0; i < num; i++) {
				GameObject itemTile = NGUITools.AddChild(questItemsPanelGrid.gameObject, itemTilePrefab);
				ItemTileButton tileButton = itemTile.GetComponent<ItemTileButton>();
				itemTiles.Add(tileButton);
				tileButton.index = itemTiles.Count-1;
			}
		}
		for (int i = 0; i < itemTiles.Count; i++) {
            if(i>=questItems.Count)
            {
                itemTiles[i].gameObject.SetActive(false);
            }
            else
            {
                itemTiles[i].gameObject.SetActive(true);
                itemTiles[i].LoadQuestDisplayTile(questItems[i], false);
            }
            questItemsPanelGrid.Reposition();
        }
		questItemsPanelGrid.Reposition();
	}
	public void UpdatePlayerShopitemList(List<ParseInventoryItem> items)
	{
		List<InventoryItem> newItemList = new List<InventoryItem>();
		for (int i = 0; i < items.Count; i++) 
		{
			InventoryItem newItem = new InventoryItem();
			if(items[i].UniqueItemId.IndexOf("ARMOR") != -1)
			{
				newItem.GenerateNewInventoryItem(Storage.LoadbyUniqueId<RPGArmor>(items[i].UniqueItemId, new RPGArmor()), items[i].ItemLevel, items[i].Amount);
			}
			else if(items[i].UniqueItemId.IndexOf("ITEM") != -1)
			{
				newItem.GenerateNewInventoryItem(Storage.LoadbyUniqueId<RPGItem>(items[i].UniqueItemId, new RPGItem()), items[i].ItemLevel, items[i].Amount);
			}
			newItemList.Add(newItem);
		}
		selectedItemList = newItemList;
		RefreshInventoryIcons();
	}
Example #5
0
	public void TakeItemsFromPlayer()
	{
		foreach(Task task in Tasks)
		{
			if(task.TaskType == TaskTypeEnum.BringItem && task.CanTaskBeFinished())
			{
				InventoryItem item = new InventoryItem();
				if(task.PreffixTarget == PreffixType.ARMOR)
				{
					item.GenerateNewInventoryItem(Storage.LoadById<RPGArmor>(task.TaskTarget, new RPGArmor()), task.Tasklevel, task.AmountToReach - task.CurrentAmount);
					PlayerManager.Instance.Hero.RemoveItem(item);
					task.CurrentAmount += (task.AmountToReach - task.CurrentAmount);
				}
				else if(task.PreffixTarget == PreffixType.ITEM)
				{
					item.GenerateNewInventoryItem(Storage.LoadById<RPGItem>(task.TaskTarget, new RPGItem()), task.Tasklevel, task.AmountToReach - task.CurrentAmount);
					task.CurrentAmount += (task.AmountToReach - task.CurrentAmount);
				}
			}
		}
	}
	public void GenerateRandomReward()
	{
		/*int id = Random.Range(6, 15);
		LootItem loot = new LootItem();
		loot.itemID.Add(id);
		loot.itemType = ItemType.Armor;
		loot.minQuantity = 1;
		loot.maxQuantity = 1;
		loot.itemLevel = 1;
		loot.dropRate = 1;
		return loot;*/
		InventoryItem item = new InventoryItem();
		item.GenerateNewInventoryItem( Storage.LoadById<RPGArmor>(Random.Range(5,16), new RPGArmor()), 1, 1);
		rewardItem = item;
		rewardItemInfo.LoadItemInfo(rewardItem);
	}
	public void LoadNakedArmors()
	{
		StartCoroutine(MoveCamera(introCutscene.interiorCamera, 0.3f, quickSingleInventoryCameraRectOffset));
		Debug.Log("load naked armor times!");
		nakedArmorPanelTween.Play(true);
		for (int i = 0; i < NakedArmorIDs.Length; i++) {
			//load in naked armors
			RPGArmor nakedArmor = Storage.LoadById<RPGArmor>(NakedArmorIDs[i], new RPGArmor());
			InventoryItem newItem = new InventoryItem();
			newItem.GenerateNewInventoryItem(nakedArmor, 1, 1);
			NakedArmors.Add(newItem);
			//newItem.GenerateNewInventoryItem(
		}
		LoadItemTiles(NakedArmors, itemTiles, inventoryGridRoot, itemTilePrefab, inventoryType);
		nakedArmorPanelGrid.Reposition();
		Invoke("DisplayTip", tipWaitTime);
	}
	public IEnumerator UpgradeItem()
	{
		doorsAnimation.Play();
		yield return new WaitForSeconds(0.8f);
		HidePageComponents();
		//play doors animation
		float luck = Random.Range(0.0f, 1.0f);
		Debug.Log("luck " + luck);
		float chance = usingBonus? 0.85f : 0.55f;
		if(usingBonus)
			PlayerManager.Instance.Hero.RemoveCurrency(bonusMagnetsCount, BuyCurrencyType.Magnets);
		//TODO block bonus usage when there isn't enough magnets
		
		if(luck < chance)
		{
			InventoryItem FinalItem = new InventoryItem();
			FinalItem.GenerateNewInventoryItem(selectedItem.rpgItem, selectedItem.Level +1, 1);
		
			PlayerManager.Instance.Hero.AddItem(FinalItem);
			PlayerManager.Instance.Hero.RemoveItem(selectedItem, 1);
			upgradedItem = PlayerManager.Instance.Hero.FindItem(FinalItem.rpgItem, FinalItem.Level);
			DisplaySuccessPage();
		}
		else
		{
			upgradedItem = null;
			PlayerManager.Instance.Hero.RemoveItem(selectedItem, 1);
			DisplayFailurePage();
		}
		yield return null;
		//play door animations
	}