Implemented Hail and reoganised Abilities

>Hail is spawned at a rondom spot in an area
>Hail creates a Shadow directly underneath it
>Hail falls, and shadow scales to the correct size
>Abilites moved into their own folder
>King Implementation Scene Created and King Movement Created
This commit is contained in:
Katherine
2021-11-17 12:27:35 -06:00
parent 8e0b76f9ff
commit f20dbd6032
25 changed files with 2580 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 14595e0094b28384c8078f76053166e3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Boulder : MonoBehaviour
{
private Rigidbody boulder;
void Start() {
boulder = GetComponent<Rigidbody>();//Gets the rigidbody attached to the bolder
}
void OnTriggerEnter(Collider other) {
if (other.tag == "Player") {
GameObject player = other.gameObject;//Turns the collider into a game object
Vector3 Dir = boulder.velocity;//Finds the bolder's velocity
float Power = boulder.velocity.magnitude * 250;//Finds the power of the boulder by using it's velocity and a scaler
Dir = Vector3.Normalize(Dir);//Normalizes the vector to be used as a knockback direction
player.GetComponent<PlayerMovement>().AddImpact(Dir, Power); //Ragdolls the player in the direction of the bolder depending on it's speed
}
}
//Coppied from player for easy Boulder Testing/Demonstration
void FixedUpdate() {
Respawn();
}
private void Respawn()
{
if (transform.position.y < -1) {
transform.position = new Vector3(74.67f, 34.68f, 7.15f);
}
}
}

View File

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

View File

@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bumper : MonoBehaviour {
// Is called whenever something collides with the bumper
void OnTriggerEnter(Collider other) {
//Debug.Log("Bump!");
GameObject player = other.gameObject;//Turns the collider into a game object
Vector3 DirBump = player.GetComponent<PlayerMovement>().vel * -1;//Inverts the Player Velocity
DirBump = Vector3.Normalize(DirBump);//Normalizes the vector to be used as a bump direction
player.GetComponent<PlayerMovement>().AddImpact(DirBump, 200); //Launches tthe player directly away from the bumper
}
}

View File

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

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Goo : MonoBehaviour
{
int Lifetime = 0;
void FixedUpdate() {
Lifetime++;
if(Lifetime == 550) {
Destruction();
}
}
//Makes the player sliperly whenever they step on the goo
void OnTriggerEnter(Collider other) {
Debug.Log("Slippy!");
GameObject player = other.gameObject;//Turns the collider into a game object
player.GetComponent<PlayerStats>().Traction = 1.5f;//Make it slippy
}
void Destruction() {
Destroy(gameObject);
}
}

View File

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

View File

@@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hail : MonoBehaviour
{
private Rigidbody hail;
public GameObject shadow;
private float ShadStSz = 0;
private float m;
private GameObject ShadTemp = null;
void Start() {
hail = GetComponent<Rigidbody>();//Gets the rigidbody attached to the bolder
ShadTemp = Instantiate(shadow);//Creates the shadow
ShadTemp.transform.position = new Vector3(hail.transform.position.x, 0, hail.transform.position.z);//Sets it properly directly under the hail
ShadTemp.transform.localScale = new Vector3(ShadStSz, 0, ShadStSz);//Scales it to the proper start size
m = (hail.transform.localScale.x - ShadStSz) / 30;//Find the proper rate of growth
}
void FixedUpdate() {
float y = m * (hail.transform.position.y-30) + ShadStSz;//Find the proper current size
ShadTemp.transform.localScale = new Vector3(y, 0, y);//Scales the shadow to that size
Destruction();//Sees if it needs to destroy both
}
void OnTriggerEnter(Collider other) {
if (other.tag == "Player") {
GameObject player = other.gameObject;//Turns the collider into a game object
float Power = hail.velocity.magnitude * 100;//Finds the power of the hail by using it's velocity and a scaler
//Find the dirrection of launch by finding the direction between the two points of the player and the Hail
float px = player.transform.position.x;
float pz = player.transform.position.z;
float hx = hail.transform.position.x;
float hz = hail.transform.position.z;
//Direction pointing away from the center of the Hail
Vector3 Dir = new Vector3(px - hx, 0, pz - hz);
player.GetComponent<PlayerMovement>().AddImpact(Dir, Power); //Ragdolls the player in the direction of the bolder depending on it's speed
}
}
//Destroys the Hail and its shadow
void Destruction() {
if(hail.transform.position.y <= 0) {
Destroy(ShadTemp);
Destroy(gameObject);
}
}
}

View File

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

View File

@@ -0,0 +1,43 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HailArea : MonoBehaviour
{
// Update is called once per frame
public float Xmax = 15f;
public float Xmin = -15f;
public float Zmax = -85f;
public float Zmin = -115f;
public GameObject Hail;
int timer = 0;
// FixedUpdate is called once per .02 seconds (or 50 times a second)
void FixedUpdate()
{
if (timer == 50) {
timer = 0;
//Random diameter 4->8
float diameter = Random.Range(4, 8);
float radius = diameter / 2.0f;
//Random pos X Xmax-radius -> Xmin+radius
//Random pos Z Zmax-radius -> Zmin+radius
Vector3 position = new Vector3(Random.Range(Xmin + radius, Xmax - radius), 30, Random.Range(Zmin + radius, Zmax - radius));
SpawnHail(diameter, position);
}
timer++;
}
// Spawns a singular Hail piece
void SpawnHail(float size, Vector3 pos)
{
//Spawn HailBall and its shadow
GameObject HailTemp = null;
HailTemp = Instantiate(Hail);
HailTemp.transform.position = pos;
HailTemp.transform.localScale = new Vector3(size, size, size);
}
}

View File

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

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Slime : MonoBehaviour
{
float MoveDir;
int GooTimer = 0;
Vector3 offset = new Vector3(0.0f, 0.4f, 0.0f);
public GameObject Goo;
public GameObject Folder;
public int StartPos = -29;
public int EndPos = -57;
// Start is called before the first frame update
void Start()
{
MoveDir = Time.deltaTime;
}
// FixedUpdate is called once per .02 seconds (or 50 times a second)
void FixedUpdate()
{
//create goo underneath them slime
if (GooTimer == 6) {
GameObject GooTrail = null;
GooTrail = Instantiate(Goo, transform.position - offset, transform.rotation);
GooTrail.transform.parent = Folder.transform;
GooTimer = 0;
}
//attempt to move forward (Raycast for objects, how to make sure it didn't fall off a cliff?)
if (transform.position.z >= StartPos || transform.position.z <= EndPos) {//Rough way of keeping turning it around when it reaches an end
MoveDir = -MoveDir;
}
//if can't Turn around 180 degrees
//otherwise actually move forward
transform.Translate(0, 0, MoveDir);
GooTimer++;
}
void OnTriggerStay(Collider other) {
//slow down player
GameObject player = other.gameObject;//Turns the collider into a game object
//Get the Player's speed
float CurVel = player.GetComponent<PlayerStats>().CurVel;
player.GetComponent<PlayerStats>().CurVel = CurVel - (CurVel/10);
//Cut it in half?
}
}

View File

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

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Wind : MonoBehaviour
{
public Vector3 DirWind;
// Start is called before the first frame update
void Start()
{
DirWind = Vector3.forward;
}
// Update is called once per frame
void OnTriggerStay(Collider other)
{
other.GetComponent<PlayerMovement>().AddImpact(DirWind, 1);
}
}

View File

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

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KingMove : MonoBehaviour
{
public float speed = 30.0f;
public float rotSpeed = 30.0f;
private Vector3 newPos;
// Update is called once per frame
void Update() {
float translation = Input.GetAxis("HorizontalCam") * speed;
float rotation = Input.GetAxis("HorizontalCam") * rotSpeed;
// Make it move 10 meters per second instead of 10 meters per frame...
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
// Move translation along the object's z-axis
if (transform.position.z <= 61 && transform.position.z >= -80) {
transform.Translate(0, 0, -translation);//Is negated to make the Left arrow go left and the right arraow go right
transform.rotation = Quaternion.Euler(0, 0, 0);
}
else if (transform.position.z > 61) {
transform.position = new Vector3(-42, 30, 61);//Keeps them from going too far left
}
else if (transform.position.z < -80) {//Once they rech a certain point they begin to cirlce around the mountain (radius of 42, x^2+z^2=42^2)
transform.Rotate(0, -rotation, 0);// Rotates the player as they move along the circumfurance
float z = transform.position.z - 0.5f;
float x = Mathf.Sqrt((42 * 42) - ((z + 80) * (z + 80)));//Add something based off translation to X and calculate the corespondent Z Z = sqrt(42^2-x^2)-80
newPos = new Vector3(-x, 30, z); // make a Vector3 out of the new X and Z
transform.position = newPos;//Sets the player's new position on the cirlce
}
else {
Debug.Log("Aw, Beans");
transform.position = new Vector3(-42, 30, 0);
}
}
}

View File

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