Esempio n. 1
0
    void Awake()
    {
        base.Awake();
        //initialize child specific variables
        visionRadius = 5f;

        //get references to all attatched hitboxes and set the default
        Hitboxes = new List <BoxCollider2D>();
        Transform[] ts = GetComponentsInChildren <Transform>();
        foreach (Transform t in ts)
        {
            if (t.CompareTag("Hitbox"))
            {
                Hitboxes.Add(t.GetComponent <BoxCollider2D>());
            }
        }

        effectiveHitbox = Hitboxes[0];

        Path = GetComponent <Pathfinding.AIPath>();
        DestinationSetter = GetComponent <Pathfinding.AIDestinationSetter>();
        AIPatrol          = GetComponent <Pathfinding.Patrol>();

        Path.maxSpeed = movementSpeed;

        currentAIState  = AIState.idle;
        previousAIState = AIState.start;

        //TG
        //I am not searching on instantiation
        bIsSearching = false;
        bIsFleeing   = false;
        bIsCounting  = false;

        //Create chase waypoint
        chaseTarget = Instantiate(waypoint, gameObject.transform.position, new Quaternion(), GameObject.Find("waypointListContainer").transform);

        //Create patrol waypoints
        patrolPointArray[0] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x + 5f, gameObject.transform.position.y + 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[1] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x + 5f, gameObject.transform.position.y - 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[2] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x - 5f, gameObject.transform.position.y + 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[3] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x - 5f, gameObject.transform.position.y - 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
    }
Esempio n. 2
0
    void Awake()
    {
        base.Awake();

        baseAttack = 10.0f;

        dexterity     = .05f;
        vitality      = .01f;
        movementSpeed = 6.0f;

        //initialize child specific variables
        visionRadius = 8f;

        Path = GetComponent <Pathfinding.AIPath>();
        DestinationSetter = GetComponent <Pathfinding.AIDestinationSetter>();
        AIPatrol          = GetComponent <Pathfinding.Patrol>();

        Path.maxSpeed = movementSpeed;

        currentAIState  = AIState.idle;
        previousAIState = AIState.start;

        //TG
        //Sets the ray cast to trigger when colliding with player hurtbox
        layerMask = 1 << 10;


        //I am not searching on instantiation
        bIsSearching = false;
        bIsFleeing   = false;
        bIsCounting  = false;

        //Create chase waypoint
        chaseTarget = Instantiate(waypoint, gameObject.transform.position, new Quaternion(), GameObject.Find("waypointListContainer").transform);

        //Create patrol waypoints
        patrolPointArray[0] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x - 5.0f, gameObject.transform.position.y + 5.0f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[1] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x + 5.0f, gameObject.transform.position.y + 5.0f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[2] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x + 5.0f, gameObject.transform.position.y - 5.0f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[3] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x - 5.0f, gameObject.transform.position.y - 5.0f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
    }