91 lines
1.9 KiB
C#
91 lines
1.9 KiB
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DragonEnemyNPCController : BasicEnemyNPCController
|
|
{
|
|
[Header("Boss Related:")]
|
|
[SerializeField] protected GameEvent onBossDead;
|
|
[SerializeField] protected GameEvent onDragonDead;
|
|
|
|
DragonAnimatorController dragonAnimator;
|
|
|
|
protected bool isFlying = false;
|
|
protected bool isAwake = false;
|
|
|
|
public bool IsFlying => isFlying;
|
|
public bool IsAwake => isAwake;
|
|
|
|
protected int attackCounter = 0;
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
|
|
dragonAnimator = (DragonAnimatorController)animatorController;
|
|
|
|
isAwake = false;
|
|
dragonAnimator.SetAwake(IsAwake);
|
|
}
|
|
|
|
public void SetAwakeState(bool isAwake)
|
|
{
|
|
this.isAwake = isAwake;
|
|
|
|
dragonAnimator.SetAwake(isAwake);
|
|
}
|
|
|
|
public void SetFlyingState(bool flying)
|
|
{
|
|
this.isFlying = flying;
|
|
|
|
dragonAnimator.SetFlying(flying);
|
|
}
|
|
|
|
[PunRPC]
|
|
protected override void RPC_OnDeath(bool lootDropped)
|
|
{
|
|
if (isDead) return;
|
|
|
|
onBossDead.Raise();
|
|
onDragonDead.Raise();
|
|
|
|
base.RPC_OnDeath(lootDropped);
|
|
}
|
|
|
|
protected override void OnNewTargetIdentified()
|
|
{
|
|
if (!isAwake)
|
|
SetAwakeState(true);
|
|
|
|
base.OnNewTargetIdentified();
|
|
}
|
|
|
|
protected override void TryAttack()
|
|
{
|
|
base.TryAttack();
|
|
}
|
|
|
|
public override void OnAttackAnimationEventTriggered()
|
|
{
|
|
base.OnAttackAnimationEventTriggered();
|
|
|
|
if (!photonView.IsMine) return;
|
|
|
|
attackCounter++;
|
|
if (attackCounter >= GameConstants.GameBalancing.DragonAttacksNeededToChangeStance)
|
|
{
|
|
attackCounter = 0;
|
|
SetFlyingState(!isFlying);
|
|
}
|
|
}
|
|
|
|
protected override void PatrollingUpdate()
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
if (!isAwake) return;
|
|
base.PatrollingUpdate();
|
|
}
|
|
}
|