shield costs 1 essence, sound played if trying with 0 essence, shield despawns in 5 sec

This commit is contained in:
joonasp
2022-04-18 11:52:14 +03:00
parent ad1a931c41
commit a997c06e99
15 changed files with 1052 additions and 823 deletions

View File

@@ -14,6 +14,8 @@ public class ActionGestureInteraction : MonoBehaviour
private bool holdingWand;
public AudioSource noEssenceAudio;
void Start()
{
player = gameObject;
@@ -48,9 +50,17 @@ public class ActionGestureInteraction : MonoBehaviour
if (holdingWand)
{
Debug.LogWarning("WAND VERTICAL");
Vector3 spawnPoint = transform.position + playerCamera.transform.forward;
spawnPoint = new Vector3(spawnPoint.x, spawnPoint.y + 1, spawnPoint.z);
Instantiate(objects[1], spawnPoint, Quaternion.Euler(-90,playerCamera.transform.eulerAngles.y-180,180));
if (PlayerInfo.Instance.AddEssenceBasic(-1))
{
Vector3 spawnPoint = transform.position + playerCamera.transform.forward;
spawnPoint = new Vector3(spawnPoint.x, spawnPoint.y + 1, spawnPoint.z);
GameObject shield = Instantiate(objects[1], spawnPoint, Quaternion.Euler(-90, playerCamera.transform.eulerAngles.y - 180, 180));
Destroy(shield, 5);
}
else
{
noEssenceAudio.Play();
}
}
else
{

View File

@@ -25,7 +25,7 @@ public class EssenceNodeController : MonoBehaviour
private void Awake()
{
nodeMaterial = GetComponent<Renderer>().material;
//playerInfo = PlayerInfo.Instance;
playerInfo = PlayerInfo.Instance;
playerInventory = GameObject.Find("Inventory").GetComponent<Inventory>();
}

View File

@@ -23,22 +23,29 @@ public class PlayerInfo : MonoBehaviour
leftHandHeld = null;
}
public void AddHealth(int value)
public bool AddHealth(int value)
{
health += value;
if (health <= 0)
{
Debug.Log("NO HEALTH REMAINING");
return false;
}
return true;
}
public void AddEssenceBasic(int value)
public bool AddEssenceBasic(int value)
{
if (essence_basic + value < 0)
{
Debug.Log("NOT ENOUGH ESSENCE");
return false;
}
else
{
essence_basic += value;
return true;
}
else essence_basic += value;
}
public void AddLeftHand(GameObject obj)

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShieldController : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: add865683e185ac43b2093091d499b6a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: c99047a61fb87224a853c5e5bd2e8b06
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant: