Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class AI : MonoBehaviour {
- public PlayerController Controller;
- public bool DoneHome;
- public Vector3 MoveVector = Vector3.zero;
- public bool GeneratedVector;
- public Waypoint CurWayPoint;
- public Waypoint LastWayPoint;
- public Location CurrentLocation;
- public LocationType CurrentActivity;
- public List<Waypoint> CurrentPath;
- public NavMeshAgent Agent;
- // Use this for initialization
- void Start () {
- if(Agent == null)
- {
- Agent = GetComponent<NavMeshAgent>();
- }
- Agent.baseOffset = -0.05f;
- }
- // Update is called once per frame
- void Update ()
- {
- if (!Controller.CanPlay)
- {
- if (DoneHome)
- {
- if (CurrentLocation == null)
- {
- CurrentActivity = (LocationType)Random.Range(0, 2);
- CurrentLocation = GameManager.Instance.FindLocationOfType(CurrentActivity);
- }
- else
- {
- Agent.SetDestination(CurrentLocation.transform.position);
- Controller.v = Agent.velocity.z;
- if (Vector3.Distance(transform.position, CurrentLocation.transform.position) < 0.2f)
- {
- Agent.Stop();
- CurrentLocation = null;
- }
- }
- }
- else
- {
- if (Vector3.Distance(transform.position, Controller.LocalCharacter.HomeSpawn.position) > 0.2f)
- {
- Agent.SetDestination(Controller.LocalCharacter.HomeSpawn.position);
- Controller.v = Agent.velocity.z;
- }
- else
- {
- DoneHome = true;
- Controller.v = 0;
- Agent.Stop();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement