Exemple #1
0
 public void ChangeExistingPainterButtonColor(PainterButton painterButton, Color color)
 {
     grid.GetComponent <TileTypeLib>().RecolorTileType(painterButton, color);
     PainterButtons.Remove(PainterButtons.Find(x => x.name.Contains(painterButton.name)));
     painterButton.buttonColor = color;
     PainterButtons.Add(painterButton);
 }
Exemple #2
0
    public void RecolorTileType(PainterButton painterButton, Color color)
    {
        TileType tileType = GetByName(painterButton.name);

        tileTypes.Remove(tileTypes.Find(x => x.name.Contains(tileType.name)));
        tileType.color = color;
        tileTypes.Add(tileType);
    }
Exemple #3
0
    public void RenameTileType(PainterButton painterButton, string name)
    {
        TileType tileType = GetByName(painterButton.name);

        tileTypes.Remove(tileTypes.Find(x => x.name.Contains(tileType.name)));
        tileType.name = name;
        tileTypes.Add(tileType);
    }
Exemple #4
0
 public void ChangeExistingPainterButtonName(PainterButton painterButton, string name)
 {
     grid.GetComponent <TileTypeLib>().RenameTileType(painterButton, name);
     PainterButtons.Remove(PainterButtons.Find(x => x.name.Contains(painterButton.name)));
     painterButton.name        = name;
     painterButton.displayText = name;
     PainterButtons.Add(painterButton);
 }
Exemple #5
0
    public void CreateNewButton()
    {
        PainterButton newButton = new PainterButton("New Painter Button", "New", Color.white);

        PainterButtons.Add(newButton);
        grid.GetComponent <TileTypeLib>().tileTypes.Add(new TileType("New Painter Button", Color.white));
        SpawnPainterButton(newButton);
    }
Exemple #6
0
    private void SpawnPainterButton(PainterButton painterButton)
    {
        GameObject button     = Instantiate(new GameObject(), parent, true);
        GameObject textObject = Instantiate(new GameObject(), button.transform, true);

        button.AddComponent <Button>();
        button.AddComponent <Image>();
        button.AddComponent <Painter>();
        button.GetComponent <Image>().color = painterButton.buttonColor;
        button.name = painterButton.name;
        textObject.AddComponent <Text>();
        textObject.GetComponent <Text>().font                 = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
        textObject.GetComponent <Text>().text                 = painterButton.displayText;
        textObject.GetComponent <Text>().alignment            = TextAnchor.MiddleCenter;
        textObject.GetComponent <Text>().resizeTextForBestFit = true;
        textObject.GetComponent <Text>().color                = Color.black;
    }
Exemple #7
0
 void Awake()
 {
     defaultButton = new PainterButton("Default", "Default", Color.white);
     if (PlayerPrefs.HasKey(buttonsKey))
     {
         jsonArray      = JsonHelper.FromJson <PainterButton>(PlayerPrefs.GetString(buttonsKey));
         PainterButtons = jsonArray.ToList();
     }
     else
     {
         PainterButtons.Add(new PainterButton("Grass", "Grass", Color.green));
         PainterButtons.Add(new PainterButton("Water", "Water", Color.blue));
     }
     foreach (PainterButton painterButton in PainterButtons)
     {
         if (painterButton != null)
         {
             SpawnPainterButton(painterButton);
         }
     }
 }