TheKingsRace/Assets/Scripts/KingScripts/KingAbilities/HailArea.cs
Katherine f20dbd6032 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
2021-11-17 12:27:35 -06:00

44 lines
1.2 KiB
C#

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);
}
}