53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
using Assets.Scripts.Player;
|
|
|
|
namespace Assets.Scripts.InteractableObjects
|
|
{
|
|
public class Chest : InteractableObject
|
|
{
|
|
bool gotItem = false;
|
|
|
|
public override void handleInteraction(GameObject player){
|
|
if (gotItem)
|
|
{
|
|
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("alreadyLooted"));
|
|
}
|
|
else
|
|
{
|
|
gameObject.transform.Find("Lid").GetComponent<Animator>().Play("ChestOpen");
|
|
Item item;
|
|
int luck = player.GetComponent<PlayerGameObject>().getPlayerStat("Luck").getAmount();
|
|
int type = new System.Random().Next(3);
|
|
switch (type)
|
|
{
|
|
case 0:
|
|
// Maybe add luck to increase chance for equipment
|
|
item = new Equipment(luck);
|
|
break;
|
|
/*case 1:
|
|
//Removed lore for now... no idea for lore
|
|
break;*/
|
|
default:
|
|
item = new Item(luck, false);
|
|
break;
|
|
}
|
|
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(item);
|
|
}
|
|
gotItem = true;
|
|
}
|
|
|
|
public bool saveChest(){
|
|
return gotItem;
|
|
}
|
|
|
|
public void loadChest(bool gotItem){
|
|
this.gotItem = gotItem;
|
|
if(gotItem){
|
|
gameObject.transform.Find("Lid").GetComponent<Animator>().Play("ChestOpen");
|
|
}
|
|
}
|
|
}
|
|
} |