Пример #1
0
    void Start()
    {
        controller   = GetComponent <Controller2D>();
        thisCollider = GetComponent <Collider2D>();
        pather       = GetComponent <PathManager>();
        animator     = GetComponent <Animator>();
        thisNode     = GetComponentInChildren <Node>();

        cam = Camera.main;

        bow            = gameObject.transform.Find("Bow");
        bow.localScale = new Vector3(1 / gameObject.transform.lossyScale.x, 1 / gameObject.transform.lossyScale.y, 1 / gameObject.transform.lossyScale.z);

        gravity      = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        print("Gravity: " + gravity + "  Jump Velocity: " + jumpVelocity);

        maxVelocityX = investigateSpeed * maxVelocityMultiple;
        maxVelocityY = jumpVelocity * maxVelocityMultiple;

        globalMaxInvestigateRange = localMaxInvestigateRange + transform.position;
        globalMinInvestigateRange = localMinInvestigateRange + transform.position;

        rangedEnemyState = RangedEnemyState.patrolling;
        faceDirX         = 1;
    }
Пример #2
0
    public void StartChasing()
    {
        this.state = RangedEnemyState.CHASING;

        // Start a new path to the targetPosition, call the the OnPathComplete function
        // when the path has been calculated (which may take a few frames depending on the complexity)
        path = null;
        seeker.StartPath(transform.position, player.transform.position, OnPathComplete);
    }
Пример #3
0
    IEnumerator SwitchToAlert()
    {
        if (!switchingState)
        {
            switchingState = true;
            foreach (Transform child in bow)
            {
                GameObject.Destroy(child.gameObject);
            }

            yield return(new WaitForSeconds(alertSwitchTime));

            rangedEnemyState = RangedEnemyState.alert;
            //lastStateTime = Time.time;
            switchingState = false;
        }
    }
Пример #4
0
    IEnumerator SwitchToInvestigating()
    {
        if (!switchingState)
        {
            switchingState = true;

            foreach (Transform child in bow)
            {
                GameObject.Destroy(child.gameObject);
            }

            yield return(new WaitForSeconds(investigateSwitchTime));

            rangedEnemyState     = RangedEnemyState.investigating;
            endInvestigationTime = Time.time + investigateAttentionSpan;
            //lastStateTime = Time.time;
            switchingState = false;
        }
    }
Пример #5
0
    IEnumerator SwitchToAttacking()
    {
        if (!switchingState)
        {
            switchingState = true;

            foreach (Transform child in bow)
            {
                GameObject.Destroy(child.gameObject);
            }
            arrowClone = LoadArrow();

            yield return(new WaitForSeconds(attackSwitchTime));

            rangedEnemyState = RangedEnemyState.attacking;

            //lastStateTime = Time.time;
            switchingState = false;
        }
    }
Пример #6
0
 public void StartAttacking()
 {
     this.state = RangedEnemyState.ATTACKING;
 }
Пример #7
0
 public void StartIdle()
 {
     this.state = RangedEnemyState.IDLE;
 }