예제 #1
0
	public void init(ITMItem aItem) {
		_itemRef = aItem;
		itemTitle.text = aItem.Name();
		itemDescription.text = aItem.Description();
		if(aItem.SoftCost()>0) {
			itemCost.text = aItem.SoftCost().ToString();
			bagIcon.spriteName = "terracoins";
		} else {
			itemCost.text = aItem.HardCost().ToString();
			bagIcon.spriteName = "terradollars";
		}
		
		
		/*
		UISprite newSprite = aItem.Sprite();
		if(newSprite!=null) {
			
			Destroy (itemSprite);
			itemSprite = newSprite;
			newSprite.transform.parent = currentParent;
			newSprite.transform.localScale = currentScale;
			newSprite.transform.position = new Vector3(0f,0f,0f);
			newSprite.transform.localPosition = new Vector3(0f,0f,0f);
			newSprite.depth = currentSpriteOrder;
		}*/
		itemTexture.mainTexture = aItem.texture();
		amountOwned.text = PlayerMain.REF.amountOwned(aItem).ToString();
	}
예제 #2
0
	public EItemUsageType useBaitOnMonster(ITMItem aItem,bool fullConsume) {
		if(onMonsterCaughtAttempt!=null) {
			if(this._isWild) {
				if(!fullConsume) {
					return EItemUsageType.CouldUse;
				}
				byte catchRate = this.modifiedCatchRate((ItemBait) aItem);
				byte rand = (byte) UnityEngine.Random.Range (0,255);
				if(rand<catchRate) {
					onMonsterCaughtAttempt((ItemBait) aItem,EMonsterCatchResult.Caught);
				} else {
					if(catchRate>200) {
						onMonsterCaughtAttempt((ItemBait) aItem,EMonsterCatchResult.Close);
					} else if(catchRate>100) {
						onMonsterCaughtAttempt((ItemBait) aItem,EMonsterCatchResult.NotClose);
					}
					else {
						onMonsterCaughtAttempt((ItemBait) aItem,EMonsterCatchResult.Missed);
					}
				}
				return EItemUsageType.Consumed;
			}
		}
		return EItemUsageType.UseFailed;
	}
예제 #3
0
		public int amountOwned(ITMItem aItem) {
			for(int i = 0;i<_myItems.size;i++) {
				if(_myItems[i].item==aItem) {
					return _myItems[i].count;
				}
			}
			return 0;
		}
예제 #4
0
		public override bool consumeItem(ITMItem aItem) {
		
			if(base.consumeItem(aItem)) {
				this.removeFromInventory(aItem);
				return true;
			}
			return false;
		}
예제 #5
0
		public MoveQueueItem(ITMItem aItem,BattleMonsterWithMoves aActionMonster) {
			this._actionMonster = aActionMonster;
			_forcedSpeed = float.MaxValue;
			_useThisMove = null;
			targetTeam = ETeamPosition.RightTeam;
			targetMonster = EMonsterPos.Unset;
			actionPosition = EMonsterPos.Unset;
			usedItem = aItem;
			firstHit = true;
		}
예제 #6
0
	public EItemUsageType consumeItem(ITMItem aItem,bool aFullConsume) {
		switch(aItem.Type()) {
		case(EItemType.Bait):return useBaitOnMonster(aItem,aFullConsume);
		case(EItemType.BattleBoost):return useBattleBoostOnMonster(aItem,aFullConsume);
		case(EItemType.Collar):return useCollarOnMonster(aItem,aFullConsume);
		case(EItemType.Recovery):return useRecoveryItemOnMonster((ItemRecoveryItem) aItem,aFullConsume);
		case(EItemType.Quest):return useQuestItemOnMonster(aItem,aFullConsume);
		case(EItemType.Vitamin):return useVitaminOnMonster((ItemVitamin) aItem,aFullConsume);
		}
		return EItemUsageType.UseFailed;
	}
예제 #7
0
		public void setMoveToUseItem(ITMItem aItem,MonsterDataMain aMonster) {
			this._itemsForTurn[this.indexForMonster(aMonster)] = aItem;
			
			BetterList<BattleMonster> ms = this.monstersAsBattleMonster;
			
			for(int i = 0;i<ms.size;i++) {
				if(ms[i]!=null&&ms[i].monster==aMonster) {
					ms[i].setFutureMove(aItem);
				}
			}
		}
예제 #8
0
		public void initButton(ITMItem aItem) {
			itemTitle.text = aItem.Name();

			_item = aItem;
			active = true;
			if(itemBagLabel==null) {
				itemBagLabel = this.transform.FindChild("Price Container").FindChild("TerraCoinImg").gameObject.GetComponent<UISprite>();
			}
			if(itemCost==null) {
				itemCost = this.transform.FindChild("Price Container").FindChild("TerraCoinValue").gameObject.GetComponent<UILabel>();
			}
			itemSprite = this.GetComponentInChildren<UITexture>();
			itemSprite.mainTexture = aItem.texture();
			
			if(aItem.SoftCost()>0) {
				itemCost.text = aItem.SoftCost().ToString();
				itemBagLabel.spriteName = "terracoins";
			} else {
				itemCost.text = aItem.HardCost().ToString();
				itemBagLabel.spriteName = "terradollars";
			}
		}
예제 #9
0
		public IEnumerator consumeItem(ITMItem aItem,MoveQueueItem aMoveQueue) {
			yield return new WaitForSeconds(0.5f);
			float hpBefore = this._monsterRef.hp;
			float energyBefore = this._monsterRef.energy;
			this._monsterRef.consumeItem(aItem,true);
			if(aItem.Type()==EItemType.BattleBoost) {
				this.applyStatEffectsFromMove((BattleBoostItem) aItem,aMoveQueue);
			}
			float hpNow = this._monsterRef.hp;
			float hpDiff = hpNow - hpBefore;
			this._monsterRef.hp -= hpDiff;
			if(hpDiff>0) {
					this.addHP(hpDiff,aMoveQueue.actioningTeam.teamPosition,aMoveQueue.actionPosition);
					
				}
			float energyNow = this._monsterRef.energy;
			float energyDiff = energyNow-energyBefore;
			if(energyDiff>0) {
				this.addEnergy(energyDiff,aMoveQueue.actioningTeam.teamPosition,aMoveQueue.actionPosition);
			}
			yield return new WaitForSeconds(0.5f);
			aMoveQueue.skipToFinish();
		}
예제 #10
0
		public void setFutureMove(ITMItem aItem) {
			
			SelectedMoveData moveData = new SelectedMoveData(aItem);
			
			if(_futureMoveInfo!=null) {
				_futureMoveInfo.cleanUp();
				_futureMoveInfo =null;
			}
			_futureMoveInfo = new MoveQueueItem(aItem,this);
			if(onMoveSet!=null) {
				Debug.Log("Setting Future Move From Item: "+aItem.Name());
				onMoveSet(this as BattleMonster,this._futureMoveInfo.moveData,false);
			}
			
		}
예제 #11
0
		private void onItemSelected(ITMItem aItem) {
			Debug.Log ("On Item Selected!");
			this.playersTeam.setMoveToUseItem(aItem,this.barController.currentMonster);
			this.cleanInventoryListeners();
			
		}
예제 #12
0
		public void onItemClicked(ITMItem aItem) {
			showSingleItem();
			this.storeItemFull.init(aItem);
			Debug.Log ("Store Item Clicked!"+aItem);
		}
예제 #13
0
		public bool canBuyItem(ITMItem aItem) {
			return this.softCurrency>=aItem.SoftCost()&&this.hardCurrency>=aItem.HardCost();
		}
예제 #14
0
		public void createStoreItem(ITMItem aItem,int aIndex) {
			StoreSingleItem b = this.items[aIndex];
			b.initButton(aItem);
			b.itemSelected += onItemClicked;
			
		}
예제 #15
0
		public void removeFromInventory(ITMItem aItem) {
			for(int i = 0;i<_myItems.size;i++) {
				if(_myItems[i].item==aItem) {
					_myItems[i].count--;
					InventoryItem item = _myItems[i];
					if(_myItems[i].count<=0) {
						_myItems.RemoveAt(i);
					}
					if(onInventoryChanged!=null) {
						onInventoryChanged(item);
					}
					saveInventory();
					return;
				}
			}
		}
예제 #16
0
	public EItemUsageType useCollarOnMonster(ITMItem aItem,bool aFullConsume) {
		return EItemUsageType.UseFailed;
	
	}
예제 #17
0
	public EItemUsageType useBattleBoostOnMonster(ITMItem aItem,bool aFullConsume) {
		EItemUsageType usageType = EItemUsageType.UseFailed;
		if(!aFullConsume)
			return EItemUsageType.CouldUse; else 
				return EItemUsageType.Consumed;
	}
예제 #18
0
	public SelectedMoveData (ITMItem aItemToUse)
	{
		item = aItemToUse;
	//	_moveSelected = new MoveTreeCompletionDataRow(item);
	}
예제 #19
0
		private void onItemSelected(ITMItem aItem) {
			this._monsterRef.monster.consumeItem(aItem,true);
			onHideInventory();
			
		}
예제 #20
0
		public void addToInventory(ITMItem aItem) {
			if(aItem!=null) {
			for(int i = 0;i<_myItems.size;i++) {
				if(_myItems[i].item.Name()==aItem.Name()) {
					_myItems[i].count++;
					
					saveInventory();
					return;
				}
			}
				InventoryItem item = new InventoryItem();
				item.count = 1;
				item.item = aItem;
				_myItems.Add(item);
				
				saveInventory();
			}
			
		}