예제 #1
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="x">x coordinate.</param>
    /// <param name="y">y coordinate.</param>
    /// <param name="parent">Parent object</param>
    /// <param name="dir">Direction to move in.</param>
    public Redirection(int x, int y, GameObject parent, Grid.Direction dir)
    {
        direction = dir;

        // size pulser settings
        float   r     = UnityEngine.Random.Range(0.1f, 0.9f);
        Vector2 small = new Vector2(0.95f, 0.95f);
        Vector2 big   = new Vector2(1.05f, 1.05f);

        // make Redirect
        GameObject rObject = ResourceLoader.GetSpriteGameObject(dir + "Redirect", parent, (float)x, (float)y, "Tools", 1, "Sprites/Tools/Redirect");

        pulse = rObject.AddComponent <SizePulser>();
        pulse.SetParams(true, r, small, big);

        // rotate sprite (if necessary)
        if (dir == Grid.Direction.Left)
        {
            rObject.transform.Rotate(Vector3.forward, 90.0f);
        }
        else if (dir == Grid.Direction.Right)
        {
            rObject.transform.Rotate(Vector3.forward, -90.0f);
        }
        else if (dir == Grid.Direction.Down)
        {
            rObject.transform.Rotate(Vector3.forward, 180.0f);
        }
    }
예제 #2
0
    /// <summary>
    /// Constructor.
    /// </summary>
    /// <param name="x">x coordinate.</param>
    /// <param name="y">y coordinate.</param>
    /// <param name="parent">Parent of the eraser game object.</param>
    public Eraser(int x, int y, GameObject parent)
    {
        // size pulser settings
        float   r     = UnityEngine.Random.Range(0.1f, 0.9f);
        Vector2 small = new Vector2(0.95f, 0.95f);
        Vector2 big   = new Vector2(1.05f, 1.05f);

        // create game object
        GameObject eraserObject = ResourceLoader.GetSpriteGameObject("Eraser", parent, (float)x, (float)y, "Tools", 0, "Sprites/Tools/Eraser");

        pulse = eraserObject.AddComponent <SizePulser>();
        pulse.SetParams(false, r, small, big);
    }
예제 #3
0
    /// <summary>
    /// Constructor.
    /// </summary>
    /// <param name="x">x coordinate.</param>
    /// <param name="y">y coordinate.</param>
    /// <param name="g">Grid that the line-shot is on.</param>
    /// <param name="col">Colour of the line-shot.</param>
    /// <param name="dir">List of directions the line-shot will shoot at.</param>
    /// <param name="parent">Game object parent of the line-shot.</param>
    public LineShot(int x, int y, Grid g, ColourPicker.Colour col, List <Grid.Direction> dir, GameObject parent)
    {
        location   = new IntVector.IntVector2(x, y);
        grid       = g;
        colour     = col;
        directions = dir;

        // size pulser settings
        float   r     = UnityEngine.Random.Range(0.1f, 0.9f);
        Vector2 small = new Vector2(0.95f, 0.95f);
        Vector2 big   = new Vector2(1.05f, 1.05f);

        // create the game objects
        GameObject mainObject = new GameObject();

        mainObject.name             = col + "LineShot";
        mainObject.transform.parent = parent.transform;
        Vector3 mainPos = mainObject.transform.localPosition;

        mainPos.x = (float)x;
        mainPos.y = (float)y;
        mainObject.transform.localPosition = mainPos;
        pulse = mainObject.AddComponent <SizePulser>();
        pulse.SetParams(true, r, small, big);

        // line-shot base
        ResourceLoader.GetSpriteGameObject("LineShotBase", mainObject, 0.0f, 0.0f, "Tools", 0, "Sprites/Tools/LineShot", col);

        // arrows
        foreach (Grid.Direction d in dir)
        {
            GameObject arrow = ResourceLoader.GetSpriteGameObject(d + "LineShotArrow", mainObject, 0.0f, 0.0f, "Tools", 0, "Sprites/Tools/LineShot-Arrow", col);

            if (d == Grid.Direction.Left)
            {
                arrow.transform.Rotate(Vector3.forward, 90.0f);
            }
            else if (d == Grid.Direction.Right)
            {
                arrow.transform.Rotate(Vector3.forward, -90.0f);
            }
            else if (d == Grid.Direction.Down)
            {
                arrow.transform.Rotate(Vector3.forward, 180.0f);
            }
        }
    }
예제 #4
0
    /// <summary>
    /// Constructor.
    /// </summary>
    /// <param name="x">x coordinate.</param>
    /// <param name="y">y coordinate.</param>
    /// <param name="parent">Parent game object.</param>
    /// <param name="o">Connected teleporter.</param>
    public Teleporter(int x, int y, Grid g, GameObject parent, Teleporter o = null)
    {
        location = new IntVector.IntVector2(x, y);
        grid     = g;
        other    = o;

        // size pulser settings
        float   r     = UnityEngine.Random.Range(0.1f, 0.9f);
        Vector2 small = new Vector2(1.0f, 0.95f);
        Vector2 big   = new Vector2(1.0f, 1.05f);

        // create the teleporter
        ColourPicker.Colour col        = (ColourPicker.Colour)((count / 2) % ColourPicker.ColourCount);
        GameObject          teleObject = ResourceLoader.GetSpriteGameObject(col + "Teleporter", parent, (float)x, (float)y, "Tools", 1, "Sprites/Tools/Teleporter", col);

        pulse = teleObject.AddComponent <SizePulser>();
        pulse.SetParams(true, r, small, big);

        // increment count
        count += 1;
    }