Boss Jump and Lunge
This commit is contained in:
BIN
Assets/Scenes/Scene1-Boss.unity
LFS
BIN
Assets/Scenes/Scene1-Boss.unity
LFS
Binary file not shown.
@@ -3,8 +3,10 @@ using UnityEngine;
|
||||
public class SteampunkBoss : MonoBehaviour
|
||||
{
|
||||
public GameObject Player;
|
||||
|
||||
public Vector3 TargetJumpPosition;
|
||||
public int randomNumber = 0;
|
||||
public float stallTimer = 0;
|
||||
public bool setTimer = false;
|
||||
public Vector3 TargetPosition;
|
||||
public bool setposition = false;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
@@ -15,37 +17,115 @@ public class SteampunkBoss : MonoBehaviour
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (stallTimer <= 0)
|
||||
{
|
||||
randomNumber = Random.Range(1, 6);
|
||||
setTimer = false;
|
||||
}
|
||||
|
||||
if (randomNumber == 1)
|
||||
{
|
||||
JumpAttack();
|
||||
}
|
||||
else if (randomNumber == 2)
|
||||
{
|
||||
RocketAttack();
|
||||
}
|
||||
else if (randomNumber == 3)
|
||||
{
|
||||
LungeAttack();
|
||||
}
|
||||
else if (randomNumber == 4)
|
||||
{
|
||||
SlashAttack();
|
||||
}
|
||||
else if (randomNumber == 5)
|
||||
{
|
||||
Block();
|
||||
}
|
||||
}
|
||||
|
||||
void JumpAttack()
|
||||
{
|
||||
if (!setTimer)
|
||||
{
|
||||
stallTimer = 1;
|
||||
setTimer = true;
|
||||
}
|
||||
if (!setposition)
|
||||
{
|
||||
TargetJumpPosition = Player.transform.position;
|
||||
TargetPosition = Player.transform.position;
|
||||
setposition = true;
|
||||
}
|
||||
transform.position = Vector3.MoveTowards(transform.position, new Vector3(TargetJumpPosition.x, 20, TargetJumpPosition.z), 20 * Time.deltaTime);
|
||||
transform.position = Vector3.MoveTowards(transform.position, new Vector3(TargetPosition.x, 20, TargetPosition.z), 20 * Time.deltaTime);
|
||||
if ((transform.position.x == TargetPosition.x) && (transform.position.z == TargetPosition.z))
|
||||
{
|
||||
transform.position = Vector3.MoveTowards(transform.position, TargetPosition, 80 * Time.deltaTime);
|
||||
}
|
||||
if (transform.position == TargetPosition)
|
||||
{
|
||||
stallTimer -= Time.deltaTime;
|
||||
}
|
||||
if (stallTimer <= 0)
|
||||
{
|
||||
setposition = false;
|
||||
}
|
||||
}
|
||||
|
||||
void RocketAttack()
|
||||
{
|
||||
if (!setTimer)
|
||||
{
|
||||
stallTimer = 1;
|
||||
setTimer = true;
|
||||
}
|
||||
|
||||
stallTimer -= Time.deltaTime;
|
||||
}
|
||||
|
||||
void LungeAttack()
|
||||
{
|
||||
|
||||
if (!setTimer)
|
||||
{
|
||||
stallTimer = 0.5f;
|
||||
setTimer = true;
|
||||
}
|
||||
if (!setposition)
|
||||
{
|
||||
TargetPosition = Player.transform.position;
|
||||
setposition = true;
|
||||
}
|
||||
transform.position = Vector3.MoveTowards(transform.position, TargetPosition, 30 * Time.deltaTime);
|
||||
if (transform.position == TargetPosition)
|
||||
{
|
||||
stallTimer -= Time.deltaTime;
|
||||
}
|
||||
if (stallTimer <= 0)
|
||||
{
|
||||
setposition = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SlashAttack()
|
||||
{
|
||||
if (!setTimer)
|
||||
{
|
||||
stallTimer = 1;
|
||||
setTimer = true;
|
||||
}
|
||||
|
||||
stallTimer -= Time.deltaTime;
|
||||
}
|
||||
|
||||
void Block()
|
||||
{
|
||||
if (!setTimer)
|
||||
{
|
||||
stallTimer = 1;
|
||||
setTimer = true;
|
||||
}
|
||||
|
||||
stallTimer -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user