private void OnDayStateChanged(EDayTime obj)
    {
        _prevValue = _goalValue;
        _prevHUE   = _goalHUE;
        _prevSat   = _goalSat;
        switch (obj)
        {
        case EDayTime.Morning:
            _goalHUE   = Convert.ToInt32(DayValues[0]);
            _goalSat   = DayValues[1];
            _goalValue = DayValues[2];
            break;

        case EDayTime.Day:
            _goalHUE   = Convert.ToInt32(EveningValues[0]);
            _goalSat   = EveningValues[1];
            _goalValue = EveningValues[2];
            break;

        case EDayTime.Evening:
            _goalHUE   = Convert.ToInt32(NightValues[0]);
            _goalSat   = NightValues[1];
            _goalValue = NightValues[2];
            break;

        case EDayTime.Night:
            _goalHUE   = Convert.ToInt32(MorningValues[0]);
            _goalSat   = MorningValues[1];
            _goalValue = MorningValues[2];
            break;

        default:
            throw new ArgumentOutOfRangeException("obj", obj, null);
        }
    }
        private void DayTimeRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = (RadioButton)sender;

            //Update the control variable with correct day time
            switch (radioButton.Content.ToString())
            {
            case "Morning":
                _eDayTime = EDayTime.eMorning;
                break;

            case "Day":
                _eDayTime = EDayTime.eDay;
                break;

            case "Dusk":
                _eDayTime = EDayTime.eDusk;
                break;

            case "Night":
                _eDayTime = EDayTime.eNight;
                break;
            }
            //Refresh the GUI to show reflect the change
            ChangeGUIType();
        }
Exemple #3
0
        private void DayNight_DayStateChanged(EDayTime obj)
        {
            _prevValue = _selfLight.intensity;
            _prevColor = _selfLight.color;
            switch (obj)
            {
            case EDayTime.Morning:
                _colourToLerp = DayColor;
                _valueToLerp  = DayIntensity;
                break;

            case EDayTime.Day:
                _colourToLerp = EveningColor;
                _valueToLerp  = EveningIntensity;
                break;

            case EDayTime.Evening:
                _colourToLerp = NightColor;
                _valueToLerp  = NightIntensity;
                break;

            case EDayTime.Night:
                _colourToLerp = MorningColor;
                _valueToLerp  = MorningIntensity;
                break;

            default:
                throw new ArgumentOutOfRangeException("obj", obj, null);
            }
        }
Exemple #4
0
 public void Block(bool val)
 {
     if (_blocked != val && val)
     {
         State          = EDayTime.Evening;
         StaticTimeLeft = 0.1f;
         TimeLeft       = 0.1f;
         ChangeDayState();
     }
     _blocked = val;
 }
Exemple #5
0
        private void ChangeDayState()
        {
            switch (State)
            {
            case EDayTime.Morning:
            {
                _time = DayLenght;
                State = EDayTime.Day;
                break;
            }

            case EDayTime.Day:
            {
                _time = EveningLength;
                State = EDayTime.Evening;
                break;
            }

            case EDayTime.Evening:
            {
                _time = NightLength;
                State = EDayTime.Night;
                break;
            }

            case EDayTime.Night:
            {
                _time = MorningLength;
                State = EDayTime.Morning;
                break;
            }
            }
            _currentDuration = _time;
            if (DayStateChanged != null)
            {
                DayStateChanged(State);
            }
        }
Exemple #6
0
        // Update is called once per frame
        void Update()
        {
            switch (State)
            {
            case EDayTime.Day:
            {
                _time += TimeRate;

                if (_time >= 1.0f)
                {
                    State = EDayTime.Night;
                }
                break;
            }

            case EDayTime.Night:
            {
                _time -= TimeRate;

                if (_time <= 0.0f)
                {
                    State = EDayTime.Day;
                }
                break;
            }
            }

            for (int i = 0; i < _renderers.Length; i++)
            {
                var value = Mathf.Clamp(_time, 0.3f, 1f);
                _renderers[i].color = new Color(value, value, value);
            }

            Moon.color = new Color(1f, 1f, 1f, 1f - _time);
            Sun.color  = new Color(1f, 1f, 1f, _time);
        }
        private static DrawingImage GetMapImageWithDrawnImageAtPoint(bool big_gui, object[] array_db_values, EDayTime day_time, bool is_highlighted, BitmapSource image_to_draw, Point?where_to_draw)
        {
            string[] strMapRows = array_db_values[(int)EDBMapsTableColumns.eStrDef].ToString().Split('\n');

            SizeTile sizeTile = big_gui ? HexTypes.HexTypes.SizeBigTile : HexTypes.HexTypes.SizeSmallTile;

            // Calculation by trial and error of the formula to draw the tiles on map
            double nStartYMultiplier = sizeTile.Height * 0.25;
            double nStartXOddOffset  = sizeTile.Width * 0.8;
            double nStartXMultiplier = 2 * nStartXOddOffset;

            DrawingVisual visual = new DrawingVisual();

            using (DrawingContext drawingContext = visual.RenderOpen())
            {
                for (int nRows = 0; nRows < strMapRows.Length; nRows++)
                {
                    // Calculation by trial and error of the formula to draw the tiles on map
                    double nStartY = nRows * nStartYMultiplier;

                    string[] strMapColumns = strMapRows[nRows].Split(',');
                    bool     bIsRowOdd     = nRows % 2 != 0;
                    for (int nColumn = 0; nColumn < strMapColumns.Length; nColumn++)
                    {
                        int          nHextype = Convert.ToInt32(strMapColumns[nColumn]);
                        BitmapSource tile     = HexTypes.HexTypes.GetCorrectTileForDrawing(nHextype, big_gui, day_time, is_highlighted);

                        // Calculation by trial and error of the formula to draw the tiles on map
                        double nStartX = (nColumn * nStartXMultiplier);
                        if (bIsRowOdd)
                        {
                            nStartX += nStartXOddOffset;
                        }

                        drawingContext.DrawImage(tile, new Rect(nStartX, nStartY, tile.PixelWidth, tile.PixelHeight));
                    }
                }
                // As a final step let's see if there's an image to draw
                if (image_to_draw != null)
                {
                    drawingContext.DrawImage(image_to_draw, new Rect(where_to_draw.Value.X, where_to_draw.Value.Y, image_to_draw.PixelWidth, image_to_draw.PixelHeight));
                }


                // Below code might be useful to save things to a file, and since it took me a long time to find it, I will maintain this here for now in case I will need it later

                //drawingContext.DrawImage(tile, new Rect(0, 0, tile.PixelWidth, tile.PixelHeight));
                ////Brush brush = new Brush()
                //SolidColorBrush semiTransBrush = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0));
                //drawingContext.DrawRoundedRectangle(semiTransBrush, null, new Rect(10, 34, 80, 22), 5, 5);
                //FormattedText text = new FormattedText("Random", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Segoe UI"), 20.0, Brushes.Red);
                //drawingContext.DrawText(text, new Point(14, 30));
            }
            //RenderTargetBitmap mergedImage = new RenderTargetBitmap(nTotalWidth, nTotalHeight, 96, 96, PixelFormats.Pbgra32);
            //mergedImage.Render(visual);
            //BitmapSource final = App.ConvertImageDpi(mergedImage, App.I.DpiX, App.I.DpiY);

            //PngBitmapEncoder encoder = new PngBitmapEncoder();
            //encoder.Frames.Add(BitmapFrame.Create(mergedImage));

            //using (FileStream file = File.OpenWrite("c:\\teste\\cenas.png"))
            //{
            //    encoder.Save(file);
            //}

            DrawingImage finalMap = new DrawingImage(visual.Drawing);

            finalMap.Freeze();

            return(finalMap);
        }
        public static DrawingImage GetGameMapImageWithDrawnImageAtPoint(bool big_gui, EDayTime day_time, bool is_highlighted, BitmapSource image_to_draw, Point?where_to_draw)
        {
            // Since this method is only used to fetch the game map we can have this hard-coded
            object [] arrayDBValues = App.DB.GetAllDataOfAnItemFromMemory("2", DBTableAttributtesFetcher.GetPrimaryKeyName(EDBTable.eMaps), "0_maps");

            return(GetMapImageWithDrawnImageAtPoint(big_gui, arrayDBValues, day_time, is_highlighted, image_to_draw, where_to_draw));
        }
 private static DrawingImage GetMapImage(bool big_gui, object[] array_db_values, EDayTime day_time, bool is_highlighted)
 {
     return(GetMapImageWithDrawnImageAtPoint(big_gui, array_db_values, day_time, is_highlighted, null, null));
 }
        public static BitmapSource GetCorrectTileForDrawing(int hextypes_index, bool big_gui, EDayTime day_time, bool is_highlighted)
        {
            Dictionary <int, HexTypesImages> dictImages = big_gui ? _dictHexTypesBigImages : _dictHexTypesSmallImages;

            // Check if we already have this hextype images created and if not create them
            if (dictImages.ContainsKey(hextypes_index) == false)
            {
                HexTypesImages hexImage = new HexTypesImages(hextypes_index + 1, big_gui);
                // Recheck just in case (once crashed here saying that the same key was already there,
                // must be a concurrency problem, this might suffice and if not use a mutex
                if (dictImages.ContainsKey(hextypes_index) == false)
                {
                    dictImages.Add(hextypes_index, hexImage);
                }
            }

            BitmapSource sourceReturn = null;

            switch (day_time)
            {
            case EDayTime.eMorning:
                if (is_highlighted)
                {
                    sourceReturn = dictImages[hextypes_index].SummerMorningHighlighted;
                }
                else
                {
                    sourceReturn = dictImages[hextypes_index].SummerMorning;
                }
                break;

            case EDayTime.eDay:
                if (is_highlighted)
                {
                    sourceReturn = dictImages[hextypes_index].SummerDayHighlighted;
                }
                else
                {
                    sourceReturn = dictImages[hextypes_index].SummerDay;
                }
                break;

            case EDayTime.eDusk:
                if (is_highlighted)
                {
                    sourceReturn = dictImages[hextypes_index].SummerDuskHighlighted;
                }
                else
                {
                    sourceReturn = dictImages[hextypes_index].SummerDusk;
                }
                break;

            case EDayTime.eNight:
                if (is_highlighted)
                {
                    sourceReturn = dictImages[hextypes_index].SummerNightHighlighted;
                }
                else
                {
                    sourceReturn = dictImages[hextypes_index].SummerNight;
                }
                break;
            }

            return(sourceReturn);
        }