Exemplo n.º 1
0
    IEnumerator Idle()
    {
        var duration = Random.Range(0.5f, 0.7f);

        yield return(new WaitForSeconds(duration));

        var dir = HushPuppy.GenerateValidPosition(
            () => new Vector3(
                Random.Range(-distance, distance),
                Random.Range(-distance, distance)),
            (vec) => {
            var hit = Physics2D.BoxCast(
                this.transform.position,
                Vector2.one,
                0f,
                vec.normalized,
                vec.magnitude,
                1 << LayerMask.NameToLayer("Walls")
                    | (1 << LayerMask.NameToLayer("Stairs"))
                    | TilemapHelper.GetLayerMaskCreatureCollision(this.currFloorLevel)
                );
            var outOfBounds = !TilemapHelper.InsideSameRoom(
                this.transform.position,
                this.transform.position + vec,
                RoomManager.Get().dimensions
                );
            return(!hit && !outOfBounds);
        });

        this.target = this.transform.position + dir;
    }
Exemplo n.º 2
0
    void Generate()
    {
        Vector3 position = HushPuppy.GenerateValidPosition(
            () => this.transform.position + (Vector3)(this.spreadRadius * Random.insideUnitCircle),
            (vec) => mapManager.IsPositionValid(vec));

        Generate(position);
    }
Exemplo n.º 3
0
    IEnumerator RandomWalk()
    {
        Vector3 destination = HushPuppy.GenerateValidPosition(
            () => this.transform.position + 3f * ((Vector3)Random.insideUnitCircle),
            (vec) => mapManager.IsPositionValid(vec)
            );

        yield return(WalkTo(destination));
    }