/* Main Functions */

    void Start()
    {
        UnityEngine.Random.InitState((int)(System.DateTime.Now.Ticks));

        triggers      = gameObject.GetComponent <AITriggerManager>(); // must be initialized first
        movement      = gameObject.GetComponent <AIMovementManager>();
        inventory     = gameObject.GetComponent <AIInventoryManager>();
        weaponManager = gameObject.GetComponent <AIWeaponManager>();

        BuildingSpawner buildingSpawner = GameObject.Find("BuildingSpawner").GetComponent <BuildingSpawner>();

        buildingsGLOBAL = buildingSpawner.buildingLocations;
        placesToLoot    = new List <GameObject>(buildingsGLOBAL);

        CharacterSpawner charSpawner = GameObject.Find("CharacterSpawner").GetComponent <CharacterSpawner>();

        threatsGLOBAL = charSpawner.threats;
        //threats = new List<AIThreat>(threatsGLOBAL);

        status           = gameObject.AddComponent <Status>();
        status.health    = 100;
        status.maxHealth = 100;
        status.armor     = 0;
        status.maxArmor  = 100;

        lootLevel = 0;

        skill      = (int)(UnityEngine.Random.value * 8 + 2);
        aggression = (int)(UnityEngine.Random.value * 9 + 1);

        positionOptions = new List <GameObject>();

        StartCoroutine(AILoop());
    }
Example #2
0
    IEnumerator FixPath()
    {
        if (fixingPath == false && agent != null && target != null && !agent.CalculatePath(target.position, agent.path))
        {
            fixingPath = true;

            // create temp target
            Destroy(tempObject);
            tempObject      = new GameObject();
            tempObject.tag  = "Temporary";
            tempObject.name = "Temporary AI Waypoint";
            tempObject.transform.position = this.target.position;

            // hold on to original target
            originalObject = target.gameObject;

            AIMovementManager movement = GetComponent <AIMovementManager>();

            Vector3 newPos = gameObject.DirectionToObject(originalObject);
            newPos.Normalize();
            yield return(null);

            tempObject.transform.position = gameObject.transform.position += (new Vector3(newPos.x * 8, newPos.y * 2, newPos.z * 8));

            movement.RemoveTarget(0);
            movement.AddTarget(tempObject);
            yield return(null);
        }
        yield return(null);

        fixingPath = false;
    }
    public void TriggerExit(Collider other)
    {
        GameObject        player = other.gameObject;
        AIMovementManager ai     = player.GetComponent <AIMovementManager>();

        if (ai != null && aiInBuilding.Contains(ai.gameObject))
        {
            aiInBuilding.Remove(player);
        }
    }
    public void TriggerEnter(Collider other)
    {
        GameObject        player = other.gameObject;
        AIMovementManager ai     = player.GetComponent <AIMovementManager>();

        if (ai != null && !aiInBuilding.Contains(ai.gameObject))
        {
            ai.StructureReached(gameObject);
            aiInBuilding.Add(player);
        }
    }
    // Use this for initialization
    void Start()
    {
        base.Initialize();

        ai                 = GetComponent <EnemyAI>();
        movement           = GetComponent <AIMovementManager>();
        weaponManager      = GetComponent <AIWeaponManager>();
        base.weaponManager = weaponManager;

        desiredItems = new List <GameObject>();

        AITriggerManager triggers = GetComponent <AITriggerManager>();

        triggers.AddTrigger("Item View Distance", 4, ItemTriggered);
        triggers.AddTrigger("Item Grab Distance", 1.5f, GrabTriggered);
    }
Example #6
0
    protected override void Awake()
    {
        base.Awake();

        movementManager = GetComponent <AIMovementManager>();
    }