Пример #1
0
 void UpdateActiveColorPicker()
 {
     if (Input.GetKeyDown(KeyCode.I))
     {
         ColorPicker script = colorPicker.GetComponent <ColorPicker>();
         if (ToggleColorState.GetActive() == null)
         {
             GameObject go = PoolingSystem.Spawn(mc.buttonPrefab, new Vector3(35f, 584.5f, 0f), Quaternion.identity);
             go.transform.SetParent(mc.buttonToggleParent.transform, true);
             mc.buttonToggles.Add(go);
             go.transform.GetChild(0).GetComponent <ToggleColorState>().SetActive();
             go.transform.GetChild(0).GetComponent <ToggleColorState>().SetConnectedObj(null);
         }
         if (script.menuOn == false)
         {
             colorPicker.SetActive(true);
             script.menuOn = true;
         }
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         ColorPicker script = colorPicker.GetComponent <ColorPicker>();
         if (script.menuOn == true)
         {
             script.menuOn = false;
             script.isOn   = !script.isOn;
             colorPicker.SetActive(false);
         }
     }
 }
Пример #2
0
    /// <summary>
    /// called whenever a change occurs to a tile's TileType and updates SpriteRenderer
    /// </summary>
    /// <param name="tile_data">Tile Data, which holds the info needed to be applied</param>
    void OnTileChanged(Tile t)
    {
        if (tileGameObjMap.ContainsKey(t) == false)
        {
            Debug.Log("OnTileChanged - Doesn't contain tile_data.");
            return;
        }
        GameObject tile_go = tileGameObjMap[t];

        if (tile_go == null)
        {
            Debug.Log("OnTileChanged - tileGameObjectMap returned GameObject is null");
            return;
        }
        if (WorldController.Instance.World.tileTypeSpriteMap.ContainsKey(t.Type) == false)
        {
            Debug.LogError("Update: Missing Key in tileTypeSpriteMap!");
            return;
        }
        Sprite         tileSprite = WorldController.Instance.World.tileTypeSpriteMap[t.Type];
        SpriteRenderer tile_sr    = tile_go.GetComponent <SpriteRenderer>();

        tile_sr.sprite = tileSprite;
        if (tile_sr.color != Color.white)
        {
            ToggleColorState active = ToggleColorState.GetActive();
            if (active != null && active.GetConnectedObj() == tile_go)
            {
                active.ChangeColor(Color.white);
                if (t.Type != TileType.Empty && t.Type != TileType.Grid)
                {
                    active.SetConnectedObj(tile_go);
                }
                else
                {
                    active.SetConnectedObj(null);
                }
            }
            else
            {
                tile_sr.GetComponent <SpriteRenderer>().color = Color.white;
            }
        }
        Quaternion rot = Quaternion.identity;

        rot.eulerAngles            = new Vector3(90f, 90f * t.RotLevel, 0f);
        tile_go.transform.rotation = rot;
        Debug.Log(t.x + "_" + t.y + "_" + t.Type.ToString() + "_" + t.world.GetRoomID(t.room));
    }
Пример #3
0
 void Update()
 {
     if (toggle.isOn == true)
     {
         if (isOn == false || prevCurrSelectedObj != mc.currSelectedObj || prevCurrSelectedTileGameObj != mc.currSelectedTileGameObj || activeObject.gameObject != ToggleColorState.GetActive().gameObject || ToggleColorState.GetActive().changed == true)
         {
             activeObject = ToggleColorState.GetActive();
             if (activeObject != null)
             {
                 Vector3 hsv = RGBToHSV(activeObject.gameObject.GetComponent <Image>().color.r, activeObject.gameObject.GetComponent <Image>().color.g, activeObject.gameObject.GetComponent <Image>().color.b);
                 hSlide.GetComponent <Slider> ().value = (hsv.x / 360);
                 sSlide.GetComponent <Slider> ().value = hsv.y;
                 vSlide.GetComponent <Slider> ().value = hsv.z;
             }
             else
             {
                 hSlide.GetComponent <Slider> ().value = 0f;
                 sSlide.GetComponent <Slider> ().value = 0f;
                 vSlide.GetComponent <Slider> ().value = 0.5f;
             }
             isOn = true;
             prevCurrSelectedObj         = mc.currSelectedObj;
             prevCurrSelectedTileGameObj = mc.currSelectedTileGameObj;
         }
         toggle.transform.GetChild(2).GetComponent <Text> ().color = new Color(0.46666667f, 0.46666667f, 0.46666667f, 255);
         toggle.transform.GetChild(1).GetComponent <Text> ().color = new Color(0.8f, 0.8f, 0.8f, 255);
         rSlide.gameObject.SetActive(false);
         gSlide.gameObject.SetActive(false);
         bSlide.gameObject.SetActive(false);
         hSlide.gameObject.SetActive(true);
         sSlide.gameObject.SetActive(true);
         vSlide.gameObject.SetActive(true);
         hVal = hSlide.GetComponent <Slider> ().value * 360;
         sVal = sSlide.GetComponent <Slider> ().value;
         vVal = vSlide.GetComponent <Slider> ().value;
         Vector3 rgb = HSVToRGB(hVal, sVal, vVal);
         colorFinal = new Color((rgb.x + M), (rgb.y + M), (rgb.z + M));
         sSlide.GetComponentInChildren <Image> ().color = colorFinal;
         vSlide.GetComponentInChildren <Image> ().color = colorFinal;
     }
     else
     {
         if (isOn == true || prevCurrSelectedObj != mc.currSelectedObj || activeObject.gameObject != ToggleColorState.GetActive().gameObject || ToggleColorState.GetActive().changed == true)
         {
             activeObject = ToggleColorState.GetActive();
             if (activeObject != null)
             {
                 rSlide.GetComponent <Slider> ().value = activeObject.gameObject.GetComponent <Image>().color.r;
                 gSlide.GetComponent <Slider> ().value = activeObject.gameObject.GetComponent <Image>().color.g;
                 bSlide.GetComponent <Slider> ().value = activeObject.gameObject.GetComponent <Image>().color.b;
             }
             else
             {
                 rSlide.GetComponent <Slider> ().value = 0.5f;
                 gSlide.GetComponent <Slider> ().value = 0.5f;
                 bSlide.GetComponent <Slider> ().value = 0.5f;
             }
             isOn = false;
             prevCurrSelectedObj = mc.currSelectedObj;
             activeObject        = ToggleColorState.GetActive();
         }
         toggle.transform.GetChild(1).GetComponent <Text> ().color = new Color(0.46666667f, 0.46666667f, 0.46666667f, 255);
         toggle.transform.GetChild(2).GetComponent <Text> ().color = new Color(0.8f, 0.8f, 0.8f, 255);
         hSlide.gameObject.SetActive(false);
         sSlide.gameObject.SetActive(false);
         vSlide.gameObject.SetActive(false);
         rSlide.gameObject.SetActive(true);
         gSlide.gameObject.SetActive(true);
         bSlide.gameObject.SetActive(true);
         rVal       = rSlide.GetComponent <Slider> ().value;
         gVal       = gSlide.GetComponent <Slider> ().value;
         bVal       = bSlide.GetComponent <Slider> ().value;
         colorFinal = new Color(rVal, gVal, bVal);
     }
     activeObject.ChangeColor(colorFinal);
 }