Пример #1
0
    // Start is called before the first frame update
    void Awake()
    {
        instance = this;

        randomColor = new Color(
            Random.Range(0.2f, 1f), //Red
            Random.Range(0.2f, 1f), //Green
            Random.Range(0.2f, 1f)  //Blue
            );
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        ColorSwitcher colorSwitcher = (ColorSwitcher)target;

        GUILayout.Space(25);
        if (GUILayout.Button("Set light color"))
        {
            colorSwitcher.SetColorTo(LightDarkColor.ColorType.Light);
        }
        if (GUILayout.Button("Set dark color"))
        {
            colorSwitcher.SetColorTo(LightDarkColor.ColorType.Dark);
        }
    }
Пример #3
0
        //private void ClearGrid()
        //{
        //    //foreach (Line line in grid)
        //    //{
        //    //    LayoutRoot.Children.Remove(line);
        //    //}
        //    foreach (Rectangle rect in rects)
        //    {
        //        rect.Fill = background;
        //    }
        //    rects.Clear();
        //    grid.Clear();
        //}
        private void InitSection()
        {
            ColorSwitcher cs = new ColorSwitcher();


            for (int i = 0; i < numberOfCells; i++)
            {
                ListBoxItem itm = new ListBoxItem();
                itm.Content            = "Section" + i.ToString();
                itm.Tag                = i;
                colors[i]              = cs.NextColor();
                itm.Background         = new SolidColorBrush(colors[i]);
                itm.MouseLeftButtonUp += new MouseButtonEventHandler(itm_MouseLeftButtonUp);
                Sections.Items.Add(itm);
            }
            Sections.SelectedIndex = 0;
        }
Пример #4
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player" || other.gameObject.tag == "Projectile")
        {
            // switch all affected colors
            foreach (GameObject affectedColor in affectedColors)
            {
                if (affectedColor != null)
                {
                    ColorSwitcher colorSwitch = affectedColor.GetComponent <ColorSwitcher>();
                    colorSwitch.isActive = !colorSwitch.isActive;
                }
            }
        }

        // delete the projectile after first contact with platform
        if (other.gameObject.tag == "Projectile")
        {
            Destroy(other.gameObject);
        }
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        bool isLocked = false;

        // determine, if door is still locked
        foreach (Transform childTransform in transform.transform)
        {
            ColorSwitcher colorSwitch = childTransform.gameObject.GetComponent <ColorSwitcher>();
            if (colorSwitch != null)
            {
                if (colorSwitch.isActive == true)                       // door is locked, if there is a least a single active color
                {
                    isLocked = true;
                    break;
                }
            }
        }

        // remove the door, if it is unlocked
        if (isLocked == false)
        {
            DestroyImmediate(gameObject);
        }
    }
Пример #6
0
 public void Awake()
 {
     targetSwitcher    = (ColorSwitcher)target;
     instancedMaterial = new Material(targetSwitcher.GetComponent <SpriteRenderer>().sharedMaterial);
     targetSwitcher.GetComponent <SpriteRenderer>().sharedMaterial = instancedMaterial;
 }
Пример #7
0
 private void Start()
 {
     imageComponent = GetComponent <Image>();
     colorSwitcher  = GetComponent <ColorSwitcher>();
 }