Pedro Gomes e1755999a3 Necromancer updates
- increase summon cost
- reduce amount of class resource drained on melee hits
- increased amount of class resource drained on spell with cooldown hits
- minions scaling with owner's stats
- bugfixing npc/minion decision making corner cases
2024-07-22 21:13:48 +01:00

110 lines
2.5 KiB
C#

using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MinionNPCController : BasicEnemyNPCController
{
protected bool isReady = false;
protected override void Start()
{
base.Start();
isReady = false;
}
public virtual void OnSummonAnimationEnded()
{
isReady = true;
}
protected override void Update()
{
if (!photonView.IsMine) return;
if (isDead) return;
if (!isReady)
{
SetAgentMoving(false);
return;
}
counter += Time.deltaTime;
if (HasTarget())
{
ChasingUpdate();
}
else
{
PatrollingUpdate();
}
}
protected override void PatrollingUpdate()
{
if (!HasAvailableTargets())
{
Debug.Log("BRAIN: !HasAVailableTargetsInside");
if (currentTarget != null)
{
Debug.Log("BRAIN: TargetWasNull");
currentTarget = null;
}
if (agent.destination == null)
{
Debug.Log("BRAIN: DEstination Null");
FollowOwner();
}
else if (agent.remainingDistance < distanceToChangePatrolDestination)
{
Debug.Log("BRAIN: StoppingDistanceReached");
FollowOwner();
}
else
{
Debug.Log("BRAIN: Else");
FollowOwner();
}
}
else
{
Debug.Log("BRAIN: Else Else");
FollowOwner();
if (currentTarget == null)
{
UpdateCurrentTarget(GetClosestTarget());
}
}
}
protected virtual void FollowOwner()
{
agent.speed = patrolAgentSpeed;
patrolDestination = ((RiftPlayer)photonView.Owner.TagObject).transform.position;
patrolDestination.y = 0f;
UpdatePatrolTarget(patrolDestination);
SetAgentMoving(true);
Debug.Log("BRAIN: Following owner");
}
[PunRPC]
protected override void RPC_OnDeath(bool lootDropped)
{
if (isDead) return;
Debug.Log($"{this.gameObject.name} died!");
isDead = true;
agent.enabled = false;
//experienceOnDeath.Raise(health.GetMaxValue() * GameConstants.GameBalancing.HealthIntoExperienceMultiplier);
//dropTable.DropLoot(lootDropped);
animatorController.SetDead();
if (!photonView.IsMine) return;
}
}