Commit before OS change, No new Version
This commit is contained in:
@@ -11,6 +11,7 @@ public class Controls : MonoBehaviour
|
||||
GameObject worldGen;
|
||||
GameObject playerCam;
|
||||
UIHandler uihandler;
|
||||
GameObject currentHouse;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -65,6 +66,14 @@ public class Controls : MonoBehaviour
|
||||
target.GetComponent<NPC>().interact();
|
||||
break;
|
||||
case "House":
|
||||
currentHouse = target;
|
||||
target.GetComponent<House>().interact();
|
||||
break;
|
||||
case "Door":
|
||||
currentHouse.GetComponent<House>().leaveHouse();
|
||||
break;
|
||||
case "Chest":
|
||||
currentHouse.GetComponent<House>().getItem();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
79
Assets/Scripts/House.cs
Normal file
79
Assets/Scripts/House.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class House : MonoBehaviour
|
||||
{
|
||||
bool hasInteracted;
|
||||
public GameObject houseObject;
|
||||
public Vector3 playerPosition;
|
||||
GameObject houseInstance;
|
||||
bool gotItem;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
hasInteracted = false;
|
||||
gotItem = false;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void interact()
|
||||
{
|
||||
if (hasInteracted)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;You already entered this house");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerPosition = GameObject.Find("Player").transform.position;
|
||||
houseInstance = Instantiate(houseObject);
|
||||
houseInstance.transform.position = new Vector3(playerPosition.x, 50, playerPosition.z);
|
||||
houseInstance.transform.localScale = new Vector3(1, 1, 1);
|
||||
GameObject.Find("Player").transform.position = new Vector3(playerPosition.x, 51, playerPosition.z);
|
||||
}
|
||||
hasInteracted = true;
|
||||
}
|
||||
|
||||
public void getItem()
|
||||
{
|
||||
if (gotItem)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;You already looted this chest");
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item;
|
||||
int luck = GameObject.Find("Player").GetComponent<Player>().getStats()[11];
|
||||
int type = new System.Random().Next(3);
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
item = new Equipment(luck);
|
||||
break;
|
||||
case 1:
|
||||
item = new Book(luck);
|
||||
break;
|
||||
default:
|
||||
item = new Item(luck);
|
||||
break;
|
||||
}
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(item);
|
||||
}
|
||||
gotItem = true;
|
||||
}
|
||||
|
||||
public void leaveHouse()
|
||||
{
|
||||
GameObject.Find("Player").transform.position = playerPosition;
|
||||
Destroy(houseInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/House.cs.meta
Normal file
11
Assets/Scripts/House.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14e8c3bbd04c0574da570d1bc8d00649
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -67,8 +67,21 @@ namespace Assets.Scripts
|
||||
case "house":
|
||||
displayInformation("House");
|
||||
break;
|
||||
case "door":
|
||||
displayInformation("Exit");
|
||||
break;
|
||||
case "chest":
|
||||
displayInformation("Chest");
|
||||
break;
|
||||
default:
|
||||
uihandler.hideInformation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uihandler.hideInformation();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Assets.Scripts.Slimes
|
||||
public Item getItem()
|
||||
{
|
||||
int rand = new System.Random().Next(100) + 1;
|
||||
if (rand < 10000)//10 + luck)
|
||||
if (rand < 10 + luck)
|
||||
{
|
||||
int type = new System.Random().Next(3);
|
||||
switch (type)
|
||||
|
||||
@@ -32,6 +32,27 @@ public class Tile : MonoBehaviour
|
||||
generateContent();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
GameObject obj;
|
||||
GameObject player = GameObject.Find("Player");
|
||||
for (int i = 0; i < gameObject.transform.childCount; i++)
|
||||
{
|
||||
obj = gameObject.transform.GetChild(i).gameObject;
|
||||
if (!obj.GetComponent<Renderer>().enabled )
|
||||
{
|
||||
if (!deadEnemies.Contains(obj))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!obj.tag.Contains("House") && obj.tag.Contains("Object"))
|
||||
{
|
||||
obj.transform.LookAt(new Vector3(player.transform.position.x, obj.transform.position.y, player.transform.position.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBorders()
|
||||
{
|
||||
borderNorth = position.z * 100 + 50;
|
||||
|
||||
Reference in New Issue
Block a user