예제 #1
0
 public void Open()
 {
     image.Source          = Black;
     color                 = Valve.ValveColor.Black;
     image.RenderTransform = new RotateTransform(rotation);
     MainWindow.client.sendMessage(4);
     isOpen = true;
 }
예제 #2
0
 public void Close()
 {
     image.Source          = Black;
     color                 = Valve.ValveColor.Black;
     image.RenderTransform = new RotateTransform(rotation + 90);
     //send close command
     MainWindow.client.sendMessage(5);
     isOpen = false;
 }
예제 #3
0
        public void ChangeColor(ValveColor Color)
        {
            if (isOpen)
            {
                switch (Color)
                {
                case ValveColor.Red:
                    color        = ValveColor.Red;
                    image.Source = Red;
                    break;

                case ValveColor.Yellow:
                    image.Source = Yellow;
                    color        = ValveColor.Yellow;
                    break;

                case ValveColor.Green:
                    image.Source = Green;
                    color        = ValveColor.Green;
                    break;

                case ValveColor.Black:
                    image.Source = Black;
                    color        = ValveColor.Black;
                    break;
                }
            }
            else
            {
                switch (Color)
                {
                case ValveColor.Red:
                    image.Source = Red;
                    color        = ValveColor.Red;
                    break;

                case ValveColor.Yellow:
                    image.Source = Yellow;
                    color        = ValveColor.Yellow;
                    break;

                case ValveColor.Blue:
                    image.Source = Blue;
                    color        = ValveColor.Blue;
                    break;

                case ValveColor.Black:
                    image.Source = Black;
                    color        = ValveColor.Black;
                    break;
                }
            }
        }
예제 #4
0
 public void Toggle()
 {
     image.Source = Black;
     color        = Valve.ValveColor.Black;
     if (isOpen)
     {
         image.RenderTransform = new RotateTransform(rotation + 90);
         isOpen = false;
     }
     else
     {
         image.RenderTransform = new RotateTransform(rotation);
         isOpen = true;
     }
 }
예제 #5
0
    public static PotionColor MixPotion(PotionColor potionColor, ValveColor valveColor)
    {
        if (potionColor == PotionColor.Empty)
        {
            // ValveColor has same 1, 2 and 3 indexes as PotionColor (+1 because 0 is Empty)
            return((PotionColor)valveColor + 1);
        }

        if (valveColor == ValveColor.Red)
        {
            // If potion already contain Red, do not change its color
            if (potionColor == PotionColor.Red || potionColor == PotionColor.Orange ||
                potionColor == PotionColor.Purple || potionColor == PotionColor.Brown)
            {
                return(potionColor);
            }
            else if (potionColor == PotionColor.Blue)
            {
                return(PotionColor.Purple);
            }
            else if (potionColor == PotionColor.Yellow)
            {
                return(PotionColor.Orange);
            }
            else if (potionColor == PotionColor.Green)
            {
                return(PotionColor.Brown);
            }
        }

        if (valveColor == ValveColor.Blue)
        {
            // If potion already contain Blue, do not change its color
            if (potionColor == PotionColor.Blue || potionColor == PotionColor.Green ||
                potionColor == PotionColor.Purple || potionColor == PotionColor.Brown)
            {
                return(potionColor);
            }
            else if (potionColor == PotionColor.Red)
            {
                return(PotionColor.Purple);
            }
            else if (potionColor == PotionColor.Yellow)
            {
                return(PotionColor.Green);
            }
            else if (potionColor == PotionColor.Orange)
            {
                return(PotionColor.Brown);
            }
        }

        if (valveColor == ValveColor.Yellow)
        {
            // If potion already contain Yellow, do not change its color
            if (potionColor == PotionColor.Yellow || potionColor == PotionColor.Green ||
                potionColor == PotionColor.Orange || potionColor == PotionColor.Brown)
            {
                return(potionColor);
            }
            else if (potionColor == PotionColor.Red)
            {
                return(PotionColor.Orange);
            }
            else if (potionColor == PotionColor.Blue)
            {
                return(PotionColor.Green);
            }
            else if (potionColor == PotionColor.Purple)
            {
                return(PotionColor.Brown);
            }
        }

        // If nothing matches, do not change potion's color
        return(potionColor);
    }