resource limits added
This commit is contained in:
@ -21,7 +21,25 @@ public class FlareBeacon : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
transform.localEulerAngles = new Vector3(-89.98f, 0, 0);
|
||||
Ray r = new Ray();
|
||||
r.direction = -transform.forward;
|
||||
r.origin = transform.position;
|
||||
RaycastHit hit;
|
||||
RaycastHit[] rays = Physics.RaycastAll(r);
|
||||
foreach(RaycastHit _hit in rays)
|
||||
{
|
||||
if (_hit.transform.gameObject.GetComponent<FlareBeacon>() != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
transform.position = _hit.point;
|
||||
break;
|
||||
}
|
||||
if(Physics.Raycast(r,out hit)){
|
||||
// transform.position = hit.point;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
8
Assets/Scripts/Item/FlareBeacon.meta
Normal file
8
Assets/Scripts/Item/FlareBeacon.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8f50dd997a71e548881cf0a65dff80f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -7,6 +7,9 @@ public class BulletComponent : MonoBehaviour
|
||||
[SerializeField]
|
||||
private float duration = 5f;
|
||||
private float existed = 0f;
|
||||
[SerializeField]
|
||||
private string type = "flare";
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
@ -15,7 +15,9 @@ public class PistolComponent : MonoBehaviour
|
||||
[SerializeField]
|
||||
GameObject targetObjectPrefab;
|
||||
[SerializeField]
|
||||
private GameObject projectilePrefab;
|
||||
public GameObject projectilePrefab;
|
||||
[SerializeField]
|
||||
public string projectileName;
|
||||
[SerializeField]
|
||||
private Transform bulletSpawnPoint;
|
||||
[SerializeField]
|
||||
|
127
Assets/Scripts/Item/SpecialItemCycler.cs
Normal file
127
Assets/Scripts/Item/SpecialItemCycler.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
[System.Serializable]
|
||||
public class ItemImageRef
|
||||
{
|
||||
public string name;
|
||||
public GameObject item;
|
||||
public Sprite icon;
|
||||
}
|
||||
|
||||
public class SpecialItemCycler : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private List<ItemImageRef> spawnableItems =new List<ItemImageRef>();
|
||||
[SerializeField]
|
||||
private List<ItemImageRef> shootableItems = new List<ItemImageRef>();
|
||||
|
||||
[SerializeField]
|
||||
private PlayerInteractionHandler interactionHandler;
|
||||
[SerializeField]
|
||||
private PistolComponent pistol;
|
||||
private int spawnableIndex = 0;
|
||||
private int shootableIndex = 0;
|
||||
[SerializeField]
|
||||
//private Inventory invent;
|
||||
private TempInventory invent;
|
||||
[SerializeField]
|
||||
private Image selectedImage;
|
||||
[SerializeField]
|
||||
private TMP_Text selectedQuantityText;
|
||||
private Color sqtInitColor;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
sqtInitColor = selectedQuantityText.color;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (interactionHandler.GunEnabled)
|
||||
{
|
||||
pistol.projectilePrefab = shootableItems[shootableIndex % shootableItems.Count].item;
|
||||
pistol.projectileName = shootableItems[shootableIndex % shootableItems.Count].name;
|
||||
}
|
||||
SetImage();
|
||||
if (Input.GetButtonDown("CycleItems"))
|
||||
{
|
||||
if (interactionHandler.GunEnabled)
|
||||
{
|
||||
this.shootableIndex = (shootableIndex + 1) % shootableItems.Count;
|
||||
selectedImage.sprite = shootableItems[this.shootableIndex].icon;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.spawnableIndex = (spawnableIndex+1)%spawnableItems.Count;
|
||||
selectedImage.sprite = spawnableItems[this.spawnableIndex].icon;
|
||||
|
||||
}
|
||||
if (selectedImage.sprite == null)
|
||||
{
|
||||
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 1);
|
||||
}
|
||||
}
|
||||
if (Input.GetButtonDown("TempPlace"))
|
||||
{
|
||||
if (invent.GetQuantityOf(spawnableItems[spawnableIndex].name)>0)
|
||||
if (!interactionHandler.GunEnabled && spawnableItems[spawnableIndex].item!= null)
|
||||
{
|
||||
GameObject prefab = spawnableItems[spawnableIndex].item;
|
||||
GameObject instance = Instantiate(prefab,interactionHandler.CarryingPos);
|
||||
instance.transform.localPosition = Vector3.zero;
|
||||
instance.transform.parent = null;
|
||||
invent.Remove(spawnableItems[spawnableIndex].name);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SetImage()
|
||||
{
|
||||
|
||||
if (interactionHandler.GunEnabled)
|
||||
{
|
||||
|
||||
selectedImage.sprite = shootableItems[this.shootableIndex].icon;
|
||||
selectedQuantityText.text = invent.GetQuantityOf(shootableItems[this.shootableIndex].name).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
selectedImage.sprite = spawnableItems[this.spawnableIndex].icon;
|
||||
selectedQuantityText.text = invent.GetQuantityOf(spawnableItems[this.spawnableIndex].name).ToString();
|
||||
|
||||
}
|
||||
if (selectedImage.sprite == null)
|
||||
{
|
||||
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 0);
|
||||
selectedQuantityText.gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedImage.color = new Color(selectedImage.color.r, selectedImage.color.g, selectedImage.color.b, 1);
|
||||
selectedQuantityText.gameObject.SetActive(true);
|
||||
if (selectedQuantityText.text == "0")
|
||||
{
|
||||
selectedQuantityText.color = Color.red;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedQuantityText.color = sqtInitColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Item/SpecialItemCycler.cs.meta
Normal file
11
Assets/Scripts/Item/SpecialItemCycler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57edf3fe88ab13c42b4f2b0cab83a3b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user