Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (pcList == null)
        {
            pcList = turnManager.GetPCList();
        }
        // Checks if the unit who is attacking has reached the destination point.
        // ** Had to change condition from checking agent.remainingDistance to Vector3.distance because for some reason the remaining distance is slow to update. It would break my movement before the enemy even started moving.
        if (currentState == UnitState.Attacking && inAction == true && Vector3.Distance(transform.position, nearestPC.transform.position) <= agent.stoppingDistance)
        {
            if (currentState == UnitState.Attacking && hasAttacked == false)
            {
                StartCoroutine(AttackPC());
            }
        }

        // Checks if the unit who is moving has reached the destination point.
        if (currentState == UnitState.Moving && inAction == true && Vector3.Distance(transform.position, nearestPC.transform.position) <= agent.stoppingDistance)
        {
            StopUnit();
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        //Grab TurnManagerScript
        turnManager = GameObject.Find("TurnManager").GetComponent <TurnManagerScript>();

        // Grabs the NavMeshAgent of object.
        agent = GetComponent <NavMeshAgent>();

        // Grabs the enemy CharacterTemplate script
        charTemplate = GetComponent <CharacterTemplate>();

        // Gets the animator component.
        animator = gameObject.GetComponent <Animator>();

        // Sets the default state of isAlerted bool to false;
        isAlerted = false;

        // Grabs PC list from Turn Manager Script.
        pcList = turnManager.GetPCList();

        // Sets inAction to false by default.
        inAction = false;

        // Sets unitTurnOver to false;
        unitTurnOver = true;

        // Sets the enemy unit to alive status;
        isDead = false;

        // Sets state to none.
        currentState = UnitState.None;

        // Sets state of attack to false;
        hasAttacked = false;

        // Sets the movementRadius to a default value from character stat.
        // ** NEED TO CHANGE THIS ONCE ENEMY STAT SCRIPT IS COMPLETE **
        movementRadius = 8;
    }
Exemplo n.º 3
0
 //To get and update PCList.
 public void UpdatePCList()
 {
     pcList = turnManager.GetPCList();
 }