Exemplo n.º 1
0
    public override Command[] GetOptions()
    {
        if (transform.forward != Vector3.down && (!Level.Singleton.ContainsElement(transform.position + Vector3.down) || !Level.Singleton.getEntity(transform.position + Vector3.down) is BasicSensor))
        {
            setMood(Mood.Happy);
        }
        List <Command> commands = new List <Command>();

        if (!stuck || !CubeHelper.IsFree(new Vector3Int(transform.position + Vector3.down)))
        {
            commands = CubeHelper.GetListOptions(base.GetOptions());
            Vector3Int pos;
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.forward, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.forward);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.back, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.back);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.right, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.right);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.left, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.left);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
        }
        else
        {
            Vector3Int pos;
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.down, out pos, GetJumpHeight()))
            {
                commands.Add(new Move(this, pos));
            }
        }
        return(commands.ToArray());
    }