Untitled

 avatar
unknown
csharp
2 months ago
2.0 kB
5
Indexable
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.AI;

public class GeneralBehaviourManager : MonoBehaviour
{
    //Determines what the entity is supposed to be doing, while also setting some tags for it, without calling for any particular ability
    private GameManager gameManager;

    public string charactersName;

    public EntityStats entityStats;
    public HealthBarManager health;
    public bool isDead;
    public GameObject deadVFXIndicator;
    public ResourceManager resource;
    public GeneralistAbilityManager generalistAbilityManager;
    public NavMeshTargetSetter navMeshTargetSetter;

    public enum EntityAllegianceTag { ENEMY, PLAYER };
    public enum EntityGroupTag { MELEE, RANGED };
    public enum EntityPlayerTypeTag { TANK, HEALER, DPS };

    private void Awake ()
    {
        gameManager = FindAnyObjectByType<GameManager> ();    
    }

    private void Update ()
    {

        if (!gameManager.isCombatTimeRunning || isDead) 
        { 
            return; 
        }

        SetAgentStoppingDistance (generalistAbilityManager.preferredFocusDistance);

    }

    private void LateUpdate()
    {

        if (!gameManager.isCombatTimeRunning) 
        { 
            return; 
        }

        if (deadVFXIndicator != null)
        {
            deadVFXIndicator.SetActive (isDead);
        }

        navMeshTargetSetter.agent.enabled = !isDead;

    }


    public void SetAgentStoppingDistance (float distance)
    {

       navMeshTargetSetter.SetStoppingDistance (distance);

    }

    //Most scripts check for the isDead state to set the player to be so
    public void KillEntity ()
    {

        isDead = true;

        //Check if this is a player or an enemy
        if (generalistAbilityManager.playerAggro == null)
        {
            Destroy(this.gameObject);
        }

    }
}
Editor is loading...
Leave a Comment