Beispiel #1
0
		public void itemsFromString(string aString) {
			string decomp = Base64Compressor.Base64Decode(aString);
			string[] split = decomp.Split(new char[] {','});
			for(int i = 0;i<split.Length;i++) {
				InventoryItem item = new InventoryItem();
				item.ItemAsString = split[i];
				if((item.item!=null)&&(item.count>0)) {
					_myItems.Add(item);
				}
			}
		}
Beispiel #2
0
		public void initItem(InventoryItem aItem) {
			itemTitle.text = aItem.item.Name();
			texture = transform.FindChild("Texture").gameObject.GetComponent<UITexture>();
			texture.mainTexture = aItem.item.texture();
			itemCount.text = aItem.count.ToString();
			UIButton b = this.GetComponent<UIButton>();
			b.onClick.Add(new EventDelegate(this,"onItemClicked"));
			item = aItem;
			if(!listening) {
				listening = true;
				PlayerMain.REF.onInventoryChanged += onInventoryChanged;
			}
			
		}
Beispiel #3
0
		public void initFromList(BetterList<MonsterDataMain> aList,InventoryItem aItem) {
			Debug.Log ("AssignItemToMonster->initFromList");
			this.gameObject.SetActive(true);
			item = aItem;
			for(int i = 0;i<monsterItems.Length;i++) {
				monsterItems[i].gameObject.SetActive(false);
			}
			
			for(int i = 0;i<aList.size;i++) {
				if(aList[i]!=null) {
					monsterItems[i].init(aList[i],aItem);
					monsterItems[i].gameObject.SetActive(true);
				}
			}
			if(item.count==0) {
				
				this.gameObject.SetActive(false);
			}
			
		}
Beispiel #4
0
		public void update(InventoryItem aItem) {
			itemCount.text = item.count.ToString();
			
		}
Beispiel #5
0
		private void onInventoryChanged(InventoryItem aItem) {
			
			itemCount.text = item.count.ToString();
		}
Beispiel #6
0
		public void init(MonsterDataMain aMonster,InventoryItem aItem) {
			
			monster = aMonster;
			
			monster.LevelChanged += onMonsterChanged;
			_item = aItem;
			monsterName.text = aMonster.name;
			monsterLevel.text = aMonster.level.ToString();
			initUnusedMovePointsLevel();
			UIButton b = this.GetComponent<UIButton>();
			b.defaultColor = aMonster.elementType.color;
			
			UISprite s = this.GetComponent<UISprite>();
			s.color = aMonster.elementType.color;
			
			if(monster!=null) {
				monster.LevelChanged += onMonsterChanged;
				initMonster();
				initUnusedMovePointsLevel();
				b.defaultColor = aMonster.elementType.color;
				UITexture t = transform.Find("Sprite").GetComponent<UITexture>();
				t.enabled = true;
				t.mainTexture = (Texture) Resources.Load("FlatMonsters/"+this.monster.monsterBreedRef.Name.ToLower().Replace(" ",""));
				
				s.color = aMonster.elementType.color;
				
			} else {
				progress.gameObject.SetActive(false);
				b.defaultColor = new Color(0.11f,0.11f,0.11f);
				s.color = new Color(0.11f,0.11f,0.11f);
				this.monsterName.text = "Empty";
				this.monsterLevel.text = "";
				this.initUnusedMovePointsLevel();
				UITexture t = this.GetComponentInChildren<UITexture>();
				t.enabled = false;
			}
			
		}
Beispiel #7
0
		private void onInventoryChanged(InventoryItem aItem) {
			if(item.count==0) {
				this.gameObject.SetActive(false);
			}
		}
Beispiel #8
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();
			}
			
		}