Beispiel #1
0
    public void Move()
    {
        if (Vector3.Distance(transform.position, TargetPosition) > 2f)
        {
            actionType = GuardionActionType.move;

            anim.SetBool("Move", true);

            if (transform.position.x >= TargetPosition.x)
            {
                Right();
                Axis = -1;
            }
            else
            {
                Left();
                Axis = 1;
            }
        }
        else
        {
            if (homeDestination)
            {
                transform.SetParent(PointInHous);
                transform.position = PointInHous.position;
                actionType         = GuardionActionType.move;
            }
            Axis = 0;
            Idle();
            anim.SetBool("Move", false);
        }

        rb.velocity = new Vector2(Axis * moveSpeed, rb.velocity.y);
    }
Beispiel #2
0
    public IEnumerator Delay(float time)
    {
        actionType = GuardionActionType.none;
        yield return(new WaitForSeconds(time));

        Vector3 target = PointList[Random.Range(0, PointList.Count)].position;

        SetTarget(target);
    }
Beispiel #3
0
    public IEnumerator Dead()
    {
        yield return(new WaitForSeconds(1f));

        //Destroy(gameObject);
        actionType = GuardionActionType.none;
        anim.SetTrigger("Dead");
        rb.velocity    = new Vector2(0 * moveSpeed, rb.velocity.y);
        rb.isKinematic = true;
        GetComponent <CapsuleCollider2D>().isTrigger = true;
    }
Beispiel #4
0
    IEnumerator DelayAttack()
    {
        if (PlayerPrefs.GetInt("LittleGuardInHome") == 1)
        {
            actionType = GuardionActionType.attac;
            Right();
            anim.SetTrigger("Attack");
            yield return(new WaitForSeconds(2f));

            DestroyWall?.Invoke();
            PlayerPrefs.SetInt("LittleGuardInHome", 3);
        }
    }