예제 #1
0
    private IEnumerator actualUse(LowLevelAI_SCR lowBrain)
    {
        beingUsed = true;

        // Try to get in line of sight
        bool looking      = true;
        int  lookingCount = 0;

        while (looking)
        {
            yield return(new WaitForSeconds(0));

            lookingCount++;

            if (!lowBrain.moving && !shooting)
            {
                // Pick a random place to move to
                Vector3 target = new Vector3(this.transform.parent.position.x + Random.Range(-20, 20), this.transform.parent.position.y + Random.Range(-20, 20), 0);
                lowBrain.MoveTo(target);
            }

            // If can see player then shoot the laser
            Vector3      dir = player.transform.position - this.transform.position;
            Ray2D        ray = new Ray2D(this.transform.position, dir * 5);
            RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, 1000);

            if (hit.collider.name == "Player" && !shooting)
            {
                looking = false;
                StartCoroutine(ShootLaser());
                lowBrain.StopMoving();
            }

            // If cycled too many times kick out and do something else
            if (lookingCount > Random.Range(5, 20))
            {
                Debug.Log("Using something else");
                looking = false;
            }
        }

        if (!shooting)
        {
            beingUsed = false;
        }

        this.transform.parent.GetComponent <HighLevelAI_SCR>().makeDecision = true;
    }
    private IEnumerator actualUse(LowLevelAI_SCR bossBrain)
    {
        beingUsed = true;

        bool looking      = true;
        int  lookingCount = 0;

        while (looking)
        {
            lookingCount++;
            // If cycled too many times kick out and do something else
            if (lookingCount > Random.Range(5, 10))
            {
                Debug.Log("Using something else");
                looking = false;
            }

            // Stop moving to update player target pos
            bossBrain.StopMoving();

            // Not close to player, then move towards him
            if (Vector3.Distance(this.transform.position, bossBrain.god.player.transform.position) > 5)
            {
                if (!bossBrain.moving)
                {
                    bossBrain.MoveTo(bossBrain.god.player.transform.position);
                }
                yield return(new WaitForSeconds(1f));
            }
            else
            {
                Instantiate(stunner, this.transform.position, Quaternion.identity);
                yield return(new WaitForSeconds(1));

                looking = false;
            }
        }

        // Make new decision
        beingUsed = false;
        this.transform.parent.GetComponent <HighLevelAI_SCR>().makeDecision = true;
    }
예제 #3
0
    // Telegraph that we're using this item before using it
    private IEnumerator telegraph(LowLevelAI_SCR lowBrain)
    {
        // Scale up
        Vector3 orig   = this.transform.localScale;
        Vector3 target = this.transform.localScale * 2;
        bool    going  = true;

        while (going)
        {
            yield return(new WaitForFixedUpdate());

            this.transform.localScale = Vector3.Lerp(this.transform.localScale, target, Time.deltaTime * 10);

            if ((this.transform.localScale.x) > target.x - 0.1)
            {
                going = false;
            }
        }

        // Scale down
        going = true;
        while (going)
        {
            yield return(new WaitForFixedUpdate());

            this.transform.localScale = Vector3.Lerp(this.transform.localScale, orig, Time.deltaTime * 10);

            if ((this.transform.localScale.x) < orig.x + 0.1)
            {
                going = false;
            }
        }

        StartCoroutine(actualUse(lowBrain));
        yield return(new WaitForSeconds(0));
    }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     body     = this.GetComponent <BossBody_SCR>();
     lowBrain = this.GetComponent <LowLevelAI_SCR>();
 }
예제 #5
0
 public override void Use(LowLevelAI_SCR lowBrain)
 {
     StartCoroutine(telegraph(lowBrain));
 }
예제 #6
0
 // Use this item, however it is intended to be used, will be different and unique for every item.
 // Also this contains some unique behavior for how the boss should act before and after using this item.
 public virtual void Use(LowLevelAI_SCR bossBrain)
 {
 }