parent
75ab7e5ddd
commit
155ed2046f
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class SetItem : MonoBehaviour
|
||||
{
|
||||
public int i = 0;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerStay(Collider collision)
|
||||
{
|
||||
// Debug.Log(collision.gameObject.name);
|
||||
Camera.main.GetComponent<Player>().Hp -= Time.deltaTime;
|
||||
Camera.main.GetComponent<Player>().SetHp();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider collision)
|
||||
{
|
||||
Camera.main.GetComponent<Player>().inTarget = true;
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider collision)
|
||||
{
|
||||
Camera.main.GetComponent<Player>().inTarget = false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d92369e002efaf498dc21efc50e777a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,18 +1,40 @@
|
||||
using StarterAssets;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TakeItem : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public GameObject ui;
|
||||
public GameObject box;
|
||||
public GameObject bag;
|
||||
public GameObject Player;
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
||||
if (other.gameObject.tag == "Player") {
|
||||
ui.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
|
||||
if (other.gameObject.tag == "Player")
|
||||
{
|
||||
ui.SetActive(false);
|
||||
box.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.E))
|
||||
{
|
||||
box.SetActive(!box.activeInHierarchy);
|
||||
if(box.activeInHierarchy)
|
||||
{
|
||||
bag.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class item : MonoBehaviour
|
||||
{
|
||||
|
||||
public bool inBox = true;
|
||||
public GameObject target;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void pick() {
|
||||
public void pick()
|
||||
{
|
||||
if (inBox)
|
||||
{
|
||||
transform.parent = GameObject.Find("Bag").transform;
|
||||
transform.SetParent(GameObject.Find("Bag").transform);
|
||||
inBox = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Camera.main.GetComponent<Player>().inTarget) {
|
||||
int i = target.GetComponent<SetItem>().i;
|
||||
if(i<= target.transform.childCount)
|
||||
{
|
||||
|
||||
target.transform.GetChild(i).gameObject.SetActive(true);
|
||||
target.GetComponent<SetItem>().i=i+1;
|
||||
|
||||
gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue