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(); }
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; }
public int amountOwned(ITMItem aItem) { for(int i = 0;i<_myItems.size;i++) { if(_myItems[i].item==aItem) { return _myItems[i].count; } } return 0; }
public override bool consumeItem(ITMItem aItem) { if(base.consumeItem(aItem)) { this.removeFromInventory(aItem); return true; } return false; }
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; }
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; }
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); } } }
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"; } }
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(); }
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); } }
private void onItemSelected(ITMItem aItem) { Debug.Log ("On Item Selected!"); this.playersTeam.setMoveToUseItem(aItem,this.barController.currentMonster); this.cleanInventoryListeners(); }
public void onItemClicked(ITMItem aItem) { showSingleItem(); this.storeItemFull.init(aItem); Debug.Log ("Store Item Clicked!"+aItem); }
public bool canBuyItem(ITMItem aItem) { return this.softCurrency>=aItem.SoftCost()&&this.hardCurrency>=aItem.HardCost(); }
public void createStoreItem(ITMItem aItem,int aIndex) { StoreSingleItem b = this.items[aIndex]; b.initButton(aItem); b.itemSelected += onItemClicked; }
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; } } }
public EItemUsageType useCollarOnMonster(ITMItem aItem,bool aFullConsume) { return EItemUsageType.UseFailed; }
public EItemUsageType useBattleBoostOnMonster(ITMItem aItem,bool aFullConsume) { EItemUsageType usageType = EItemUsageType.UseFailed; if(!aFullConsume) return EItemUsageType.CouldUse; else return EItemUsageType.Consumed; }
public SelectedMoveData (ITMItem aItemToUse) { item = aItemToUse; // _moveSelected = new MoveTreeCompletionDataRow(item); }
private void onItemSelected(ITMItem aItem) { this._monsterRef.monster.consumeItem(aItem,true); onHideInventory(); }
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(); } }