Example #1
0
 public void PlayerEnter(ColorComponent.pColor color)
 {
     if (tileObject != null)
     {
         tileObject.SteppedOn(color);
     }
 }
Example #2
0
 public void StepOn(ColorComponent.pColor otherColor)
 {
     //Switch color with the colliding player's color
     ColorComponent.pColor t_color = color.currentColor;
     color.currentColor = otherColor;
     //player.GetComponentInChildren<ColorComponent>().currentColor = t_color
 }
Example #3
0
    public void SteppedOn(ColorComponent.pColor color)
    {
        switch (type)
        {
        case Type.BUTTON:
            ColorComponent.pColor buttonColor = gameObject.GetComponent <GameButton>().GetColor();
            if (buttonColor == color || buttonColor == ColorComponent.pColor.grey)
            {
                gameObject.GetComponent <GameButton>().StepOn();
            }
            break;

        case Type.TELEPORTER:
            ColorComponent.pColor teleporterColor = gameObject.GetComponent <Teleporter>().GetColor();
            if (teleporterColor == color)
            {
                gameObject.GetComponent <Teleporter>().StepOn();
            }
            break;

        case Type.NONE:
            break;

        default:
            break;
        }
    }
Example #4
0
    public static void TeleporterOff(ColorComponent.pColor color)
    {
        if (color == ColorComponent.pColor.red)
        {
            redTeleportOn = false;
        }
        else if (color == ColorComponent.pColor.blue)
        {
            blueTeleportOn = false;
        }
//		print (color.ToString () + " off!");
    }
Example #5
0
    public void ChangeColor(ColorComponent.pColor color)
    {
        Renderer[] renderers = GetComponentsInChildren <Renderer> ();

        foreach (Renderer rend in renderers)
        {
            if (color == ColorComponent.pColor.blue)
            {
                rend.material.color = new Color(54f / 255f, 64f / 255f, 244f / 255f);
            }
            else if (color == ColorComponent.pColor.red)
            {
                rend.material.color = new Color(201f / 255f, 65f / 255f, 65f / 255f);
            }
            else if (color == ColorComponent.pColor.grey)
            {
                Debug.Log("No gray teleporters", this);
            }
        }
    }
Example #6
0
    public void ChangeColor(ColorComponent.pColor color)
    {
        Renderer[] renderers = GetComponentsInChildren <Renderer> ();

        foreach (Renderer rend in renderers)
        {
            if (color == ColorComponent.pColor.blue)
            {
                rend.material.color = new Color(0f, 0f, 1f, .7f);
            }
            else if (color == ColorComponent.pColor.red)
            {
                rend.material.color = new Color(1f, 0f, 0f, .7f);
            }
            else if (color == ColorComponent.pColor.grey)
            {
                Debug.Log("No gray force fields", this);
            }
        }
    }
Example #7
0
    public static void TeleporterOn(ColorComponent.pColor color)
    {
        if (color == ColorComponent.pColor.red)
        {
            redTeleportOn = true;
        }
        else if (color == ColorComponent.pColor.blue)
        {
            blueTeleportOn = true;
        }

        if (redTeleportOn && blueTeleportOn)
        {
            NextLevel();
            redTeleportOn  = false;
            blueTeleportOn = false;
        }

//		print (color.ToString () + " on!");
    }
Example #8
0
    // Use this for initialization
    void Start()
    {
        controller = GetComponent <CharacterController>();

        controllerName = " Stick " + controllerIndex;

        GameObject tileHolders = GameObject.Find("Tile Holders");

        if (tileHolders != null)
        {
            tileManager = tileHolders.GetComponent <TileManager>();
        }

        currentDirection = Direction.UP;
        isGrabbing       = false;

        color = gameObject.GetComponent <ColorComponent>().currentColor;

        if (currentTile == null)
        {
            // Find nearest x increment in .5s and y increment in 1s
            Vector3 pos = transform.position;

            float x = Mathf.Floor(pos.x * 2f + 0.5f) / 2f;
            if (x % 1 != 0.5f)
            {
                //x = ( x < pos.x ) ? x + .5f : x - .5f;
            }
            float z = Mathf.Round(pos.z);

            currentTile = tileManager.GetTileAtPosition(new Vector3(x, 0.5f, z));

            if (currentTile != null)
            {
                currentTile.ReserveNode(true, true);
                transform.position = currentTile.GetNodePos();
            }
        }
        grabParticle.SetActive(false);
    }
Example #9
0
    public void ChangeColor(ColorComponent.pColor color)
    {
        Renderer[] renderers = GetComponentsInChildren <Renderer> ();

        foreach (Renderer rend in renderers)
        {
            if (color == ColorComponent.pColor.blue)
            {
                rend.material.SetColor("_MainColor", Color.blue);
                rend.material.SetColor("_EmitColor", Color.red);
            }
            else if (color == ColorComponent.pColor.red)
            {
                rend.material.SetColor("_MainColor", Color.red);
                rend.material.SetColor("_EmitColor", Color.blue);
            }
            else if (color == ColorComponent.pColor.grey)
            {
                Debug.Log("No gray teleporters", this);
            }
        }
    }
Example #10
0
    public void ChangeColor(ColorComponent.pColor color)
    {
        Color mainColor = Color.white;
        Color emitColor = Color.white;

        if (color == ColorComponent.pColor.blue)
        {
            mainColor = new Color(54f / 255f, 64f / 255f, 244f / 255f);
            emitColor = Color.blue;
        }
        else if (color == ColorComponent.pColor.red)
        {
            mainColor = new Color(201f / 255f, 65f / 255f, 65f / 255f);
            emitColor = Color.red;
        }
        else if (color == ColorComponent.pColor.grey)
        {
            mainColor = Color.white;
            emitColor = Color.grey;
        }

        transform.FindChild("button_main").renderer.material.color = mainColor;
        transform.FindChild("buttonBase").renderer.material.SetColor("_EmitColor", emitColor);
    }
Example #11
0
    /// <summary>
    /// Returns tile if empty and reserves it. Returns null if not empty or doesnt exist. Does NOT unreserve current. Fix if you want
    /// </summary>
    /// <returns>The to tile.</returns>
    /// <param name="tile">Tile.</param>
    /// <param name="direction">Direction.</param>
    public Tile MoveToTile(Tile tile, Direction direction, ColorComponent.pColor color)
    {
        int index       = GetIndex(tile);
        int targetIndex = 0;

        switch (direction)
        {
        case Direction.UP:
            targetIndex = index - width;

            if (targetIndex > -1)
            {
                if (!tiles[targetIndex].IsReserved())
                {
                    tiles[targetIndex].ReserveNode(true, true);
                    tiles[targetIndex].PlayerEnter(color);
                    return(tiles[targetIndex]);
                }
            }
            break;

        case Direction.DOWN:
            targetIndex = index + width;

            if (targetIndex < (width * height))
            {
                if (!tiles[targetIndex].IsReserved())
                {
                    tiles[targetIndex].ReserveNode(true, true);
                    tiles[targetIndex].PlayerEnter(color);
                    return(tiles[targetIndex]);
                }
            }
            break;

        case Direction.LEFT:
            targetIndex = (index % width) - 1;

            if (targetIndex > -1)
            {
                if (!tiles[index - 1].IsReserved())
                {
                    tiles[index - 1].ReserveNode(true, true);
                    tiles[index - 1].PlayerEnter(color);
                    return(tiles[index - 1]);
                }
            }
            break;

        case Direction.RIGHT:
            targetIndex = (index % width) + 1;

            if (targetIndex < width)
            {
                if (!tiles[index + 1].IsReserved())
                {
                    tiles[index + 1].ReserveNode(true, true);
                    tiles[index + 1].PlayerEnter(color);
                    return(tiles[index + 1]);
                }
            }
            break;

        default:
            return(null);
        }
        return(null);
    }