wand power value affects spells

This commit is contained in:
joonasp
2022-04-25 12:55:41 +03:00
parent 06045c07fb
commit 270acfd18d
12 changed files with 754 additions and 746 deletions

View File

@@ -13,6 +13,8 @@ public class ActionGestureInteraction : MonoBehaviour
public float projectileSpeed = 30;
private bool holdingWand;
private float wandPower;
private string wandElement;
public AudioSource noEssenceAudio;
@@ -28,6 +30,7 @@ public class ActionGestureInteraction : MonoBehaviour
if (player.GetComponent<PlayerInfo>().GetRightHand() != null)
{
if (player.GetComponent<PlayerInfo>().GetRightHand().name.StartsWith("wand")) holdingWand = true;
wandPower = player.GetComponent<PlayerInfo>().GetRightHand().GetComponent<WandData>().power;
}
else holdingWand = false;
@@ -55,6 +58,7 @@ public class ActionGestureInteraction : MonoBehaviour
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));
shield.GetComponent<ShieldController>().health = 3 * wandPower;
}
else
{
@@ -182,6 +186,7 @@ public class ActionGestureInteraction : MonoBehaviour
{
Debug.LogWarning("INSTANTIATE BOLT");
var projectileObj = Instantiate(item, rightHandTransform.position, playerCamera.transform.rotation) as GameObject;
projectileObj.GetComponent<Projectile>().damage = 1 * wandPower;
projectileObj.GetComponent<Rigidbody>().velocity = (playerCamera.transform.forward).normalized * projectileSpeed;
}
}

View File

@@ -7,6 +7,8 @@ public class Projectile : MonoBehaviour
private bool collided;
Vector3 oldEulerAngles;
public float damage;
private void Start()
{
// Will always be destroyed after 10 seconds.
@@ -29,7 +31,7 @@ public class Projectile : MonoBehaviour
if (collision.gameObject.tag != "IceBolt" && collision.gameObject.tag != "Player" && !collided)
{
collided = true;
if (collision.gameObject.name == "Dummy") Destroy(collision.gameObject); //REPLACE WITH ENEMY TAG CHECK
if (collision.gameObject.name == "Dummy") Destroy(collision.gameObject); //REPLACE WITH ENEMY TAG CHECK AND DAMAGE CHECKING
Destroy(gameObject);
}

View File

@@ -1,3 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -53,7 +54,7 @@ public class CraftingTable : MonoBehaviour
if (item1.name.StartsWith("wand"))
{
WandData data = item1.GetComponent<WandData>();
data.SetDamage(data.damage + 0.5f);
data.SetPower(data.power + 0.5f);
item1.transform.position = output.position;
Destroy(item2.gameObject);
item2 = null;
@@ -61,7 +62,7 @@ public class CraftingTable : MonoBehaviour
else
{
WandData data = item2.GetComponent<WandData>();
data.SetDamage(data.damage + 0.5f);
data.SetPower(data.power + 0.5f);
item2.transform.position = output.position;
Destroy(item1.gameObject);
item1 = null;

View File

@@ -4,13 +4,13 @@ using UnityEngine;
public class WandData : MonoBehaviour
{
public float damage = 1f;
public float power = 1f;
//public string element = "water";
public void SetDamage(float dam)
public void SetPower(float pow)
{
damage = dam;
power = dam;
}
}