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 class SteampunkBoss : MonoBehaviour
|
||||||
{
|
{
|
||||||
public GameObject Player;
|
public GameObject Player;
|
||||||
|
public int randomNumber = 0;
|
||||||
public Vector3 TargetJumpPosition;
|
public float stallTimer = 0;
|
||||||
|
public bool setTimer = false;
|
||||||
|
public Vector3 TargetPosition;
|
||||||
public bool setposition = false;
|
public bool setposition = false;
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
@@ -16,36 +18,114 @@ public class SteampunkBoss : MonoBehaviour
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
JumpAttack();
|
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()
|
void JumpAttack()
|
||||||
{
|
{
|
||||||
|
if (!setTimer)
|
||||||
|
{
|
||||||
|
stallTimer = 1;
|
||||||
|
setTimer = true;
|
||||||
|
}
|
||||||
if (!setposition)
|
if (!setposition)
|
||||||
{
|
{
|
||||||
TargetJumpPosition = Player.transform.position;
|
TargetPosition = Player.transform.position;
|
||||||
setposition = true;
|
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()
|
void RocketAttack()
|
||||||
{
|
{
|
||||||
|
if (!setTimer)
|
||||||
|
{
|
||||||
|
stallTimer = 1;
|
||||||
|
setTimer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
stallTimer -= Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LungeAttack()
|
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()
|
void SlashAttack()
|
||||||
{
|
{
|
||||||
|
if (!setTimer)
|
||||||
|
{
|
||||||
|
stallTimer = 1;
|
||||||
|
setTimer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
stallTimer -= Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Block()
|
void Block()
|
||||||
{
|
{
|
||||||
|
if (!setTimer)
|
||||||
|
{
|
||||||
|
stallTimer = 1;
|
||||||
|
setTimer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
stallTimer -= Time.deltaTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user