예제 #1
0
파일: Enemy.cs 프로젝트: jackwedi/makaku
    private void Start()
    {
        _body = GetComponent <Rigidbody2D>();
        _anim = GetComponent <Animator>();
        _box  = GetComponent <BoxCollider2D>();
        _npc  = GetComponent <WanderingNPC>();

        this.speed     = _npc.Speed();
        this.jumpForce = _npc.JumpForce();
        this.jumpReset = _npc.JumpReset();
        this.direction = _npc.Direction();
        layerMask      = (1 << LayerMask.NameToLayer("Player")) | (1 << LayerMask.NameToLayer("Enemy Limits"));

        StartCoroutine("RandomJump");
    }
예제 #2
0
파일: Enemy.cs 프로젝트: jackwedi/makaku
    private void Update()
    {
        this.direction = _npc.Direction();

        RaycastHit2D hit = Physics2D.Raycast(transform.position, new Vector2(direction, 0f), 2f, layerMask);

        if (hit && hit.collider.CompareTag("Player") && dashingAvailable)
        {
            StartCoroutine(Dash());
        }

        hit = Physics2D.Raycast(transform.position, new Vector2(direction, 0f), 0.25f, layerMask);

        if (hit && hit.collider.CompareTag("Enemy Limits"))
        {
            _npc.ChangeDirection();
        }
    }
예제 #3
0
    private void Update()
    {
        this.direction = _npc.Direction();

        if (_captured && !_secured)
        {
            this.transform.position = player.transform.position + new Vector3(0, .2f, 0);
            // Sets the baby behind the player
            this.transform.localScale = new Vector3(-player.transform.localScale.x, player.transform.localScale.y, player.transform.localScale.z);
        }

        RaycastHit2D hit = Physics2D.Raycast(transform.position, new Vector2(direction, 0f), 0.5f, layerMask);

        if (hit && hit.collider.CompareTag("Baby Limits"))
        {
            _npc.ChangeDirection();
        }
    }