Exemplo n.º 1
0
    // COMMANDS /////////////////////////////////////////////

    private IEnumerator ground(ARGUMENTS args)
    {
        // Build ground
        for (int i = 0; i < args.length; i++)
        {
            yield return(new WaitForEndOfFrame());

            if (IsCursorOnLevel())
            {
                break;
            }

            DestroyTileOnCursor();

            Instantiate(pfGround, _cursor.position, Quaternion.identity, _tilesParent);

            if (IsMovementOutOfBounds(args.direction))
            {
                break;
            }

            _cursor.Translate(args.direction);

            SoundManager.PlaySound("tile");
        }
    }
Exemplo n.º 2
0
    /////////////////////////////////////////////////////////

    public void Execute(string command, char direction, int length)
    {
        // Check null or negative length
        if (length < 1)
        {
            Logger.instance.LogError("Invalid value.");
            return;
        }

        // Get direction vector.
        Vector3 dir = Vector3.zero;

        switch (direction)
        {
        case 'l': dir = Vector3.left; break;

        case 'r': dir = Vector3.right; break;

        case 'u': dir = Vector3.up; break;

        case 'd': dir = Vector3.down; break;

        case '\n': dir = Vector3.zero; break;

        default:
            Logger.instance.LogError("Invalid direction: " + direction + ".");
            return;
        }

        // Execute command
        ARGUMENTS args = new ARGUMENTS(dir, length);

        StartCoroutine(command, args);
    }
Exemplo n.º 3
0
    private IEnumerator build(ARGUMENTS args)
    {
        yield return(new WaitForEndOfFrame());

        GameManager.instance.FreezeFrame(.1f);
        GameManager.instance.ScreenShake(.1f, 1f, 50);

        FindObjectOfType <Bot>().Run();

        SoundManager.PlaySound("build");
    }
Exemplo n.º 4
0
    private IEnumerator reset(ARGUMENTS args)
    {
        yield return(new WaitForEndOfFrame());

        GameManager.instance.FreezeFrame(.1f);
        GameManager.instance.ScreenShake(.1f, 1f, 50);

        FindObjectOfType <Version>().Restart();

        SoundManager.PlaySound("reset");
    }
Exemplo n.º 5
0
    private IEnumerator laser(ARGUMENTS args)
    {
        // Build laser
        yield return(new WaitForEndOfFrame());

        if (!IsCursorOnLevel())
        {
            DestroyTileOnCursor();
            Instantiate(pfLaser, _cursor.position, Quaternion.identity, _tilesParent);
        }

        SoundManager.PlaySound("tile");
    }
Exemplo n.º 6
0
    private IEnumerator clear(ARGUMENTS args)
    {
        // Clear tiles
        while (_tilesParent.childCount > 1)
        {
            yield return(new WaitForEndOfFrame());

            Destroy(_tilesParent.GetChild(0).gameObject);
        }

        GameManager.instance.FreezeFrame(.1f);
        GameManager.instance.ScreenShake(.1f, 1f, 50);

        SoundManager.PlaySound("clear");
    }
Exemplo n.º 7
0
    private IEnumerator move(ARGUMENTS args)
    {
        // Move cursor
        for (int i = 0; i < args.length; i++)
        {
            yield return(new WaitForEndOfFrame());

            if (IsMovementOutOfBounds(args.direction))
            {
                break;
            }

            _cursor.Translate(args.direction);
        }

        SoundManager.PlaySound("button");
    }
Exemplo n.º 8
0
    private IEnumerator delete(ARGUMENTS args)
    {
        // Delete tiles
        for (int i = 0; i < args.length; i++)
        {
            yield return(new WaitForEndOfFrame());

            DestroyTileOnCursor();

            if (IsMovementOutOfBounds(args.direction))
            {
                break;
            }

            _cursor.Translate(args.direction);
        }

        SoundManager.PlaySound("bug");
    }
Exemplo n.º 9
0
    private IEnumerator quit(ARGUMENTS args)
    {
        yield return(new WaitForEndOfFrame());

        Application.Quit();
    }