public void AddItem(ChimneyTileTemplate newItem, int itemValue, int chimneyTileIndex) { tileStored[freeSpace] = newItem; slots[freeSpace].GetComponent <SpriteRenderer>().sprite = newItem.artwork; slots[freeSpace].GetComponent <InventorySlot>().ItemValue = itemValue; slots[freeSpace].GetComponent <InventorySlot>().ChimneyTileTemplateIndex = chimneyTileIndex; itemValues[freeSpace].text = itemValue.ToString(); // Give them the correct backgrounds switch (tileStored[freeSpace].catagory) { case ChimneyTileTemplate.Catagory.ARMOUR: tileBackgrounds[freeSpace].GetComponent <SpriteRenderer>().sprite = catagoryTileBackground[0]; break; case ChimneyTileTemplate.Catagory.WEAPON: tileBackgrounds[freeSpace].GetComponent <SpriteRenderer>().sprite = catagoryTileBackground[1]; break; case ChimneyTileTemplate.Catagory.POTION: tileBackgrounds[freeSpace].GetComponent <SpriteRenderer>().sprite = catagoryTileBackground[2]; break; case ChimneyTileTemplate.Catagory.SKIPTOOL: tileBackgrounds[freeSpace].GetComponent <SpriteRenderer>().sprite = catagoryTileBackground[3]; break; case ChimneyTileTemplate.Catagory.ENEMY: tileBackgrounds[freeSpace].GetComponent <SpriteRenderer>().sprite = catagoryTileBackground[4]; break; case ChimneyTileTemplate.Catagory.BOMB: tileBackgrounds[freeSpace].GetComponent <SpriteRenderer>().sprite = catagoryTileBackground[5]; break; default: break; } tileBackgrounds[freeSpace].transform.position = new Vector3(slots[freeSpace].transform.position.x, slots[freeSpace].transform.position.y, slots[freeSpace].transform.position.z); slots[freeSpace].GetComponent <InventorySlot>().TileBackgroundSprite = tileBackgrounds[freeSpace].GetComponent <SpriteRenderer>().sprite; }
// Update is called once per frame void Update() { //Update the UI moneyText.text = "\u00A3" + currentMoney; hitPointsText.text = currentHitPoints + "/" + maxHitPoints; armourHitPointsText.text = currentArmourHitPoints + "/" + maxArmourHitPoints; if (currentHitPoints > maxHitPoints) { currentHitPoints = maxHitPoints; } if (tileSwipeLeft.CollisionWithEnemyTile && !endDayMenu.activeSelf) { tileSwipeRight.CollisionWithTile = false; if (Input.GetMouseButtonUp(0)) { ToggleEndDayMenu(); tileSwipeLeft.CollisionWithEnemyTile = false; } } // Handles swiping tiles to the left LeftSwipingHandler(); // Handles swiping tiles to the right RightSwipingHandler(); // Check if an item is being used CheckIfUsingItem(); // Deal with armour ui UpdateArmourUI(); // Activate gameovermenu if hit points are at 0 if (currentHitPoints <= 0 && gameOverMenu.activeSelf != true) { gameOverMenu.SetActive(!gameOverMenu.activeSelf); onToggleEndDayMenu.Invoke(gameOverMenu.activeSelf); } //// Make it so that you can't move the chimney about when the description screen is active //if (tileDescriptionMenu.activeSelf == true) //{ // onToggleEndDayMenu.Invoke(tileDescriptionMenu.activeSelf); //} // Set the current tile type currentTileType = tileManager.ChimneyTileTemplateArray[tileManager.CurrentlySelectedTile.GetComponent <ChimneyTile>().RandomTileTypeNum]; // Passing the current money value between scenes StaticValueHolder.DailyMoney = currentMoney - StaticValueHolder.TotalMoney; if (resurrectionActive) { resurrectionIconObject.SetActive(true); } else { resurrectionIconObject.SetActive(false); } }