Example #1
0
 public void WriteTo(System.IO.BinaryWriter writer)
 {
     writer.Write(MaxTickCount);
     writer.Write(TeamSize);
     writer.Write(TicksPerSecond);
     writer.Write(UpdatesPerTick);
     LootBoxSize.WriteTo(writer);
     UnitSize.WriteTo(writer);
     writer.Write(UnitMaxHorizontalSpeed);
     writer.Write(UnitFallSpeed);
     writer.Write(UnitJumpTime);
     writer.Write(UnitJumpSpeed);
     writer.Write(JumpPadJumpTime);
     writer.Write(JumpPadJumpSpeed);
     writer.Write(UnitMaxHealth);
     writer.Write(HealthPackHealth);
     writer.Write(WeaponParameters.Count);
     foreach (var WeaponParametersEntry in WeaponParameters)
     {
         var WeaponParametersKey   = WeaponParametersEntry.Key;
         var WeaponParametersValue = WeaponParametersEntry.Value;
         writer.Write((int)(WeaponParametersKey));
         WeaponParametersValue.WriteTo(writer);
     }
     MineSize.WriteTo(writer);
     MineExplosionParameters.WriteTo(writer);
     writer.Write(MinePrepareTime);
     writer.Write(MineTriggerTime);
     writer.Write(MineTriggerRadius);
     writer.Write(KillScore);
 }
Example #2
0
 /// <summary>
 /// Creates a new instance of <see cref="FindOptions"/>.
 /// </summary>
 /// <param name="inputManipulator">The manipulator of the input stream.</param>
 /// <param name="skipUnits">Gets the number of units to skipUnits after a match was found.</param>
 /// <param name="unitSize">Gets the size of a unit.</param>
 /// <param name="taskCount">Gets the number of tasks to use for parallel match finding.</param>
 public FindOptions(IInputManipulator inputManipulator, int skipUnits, UnitSize unitSize, int taskCount)
 {
     InputManipulator    = inputManipulator;
     SkipUnitsAfterMatch = skipUnits;
     UnitSize            = unitSize;
     TaskCount           = taskCount;
 }
Example #3
0
        public SplitView LeftIsSmaller(UnitSize leftSize)
        {
            LeftComponent.Width  = $"calc({leftSize.ToString()} - {SplitterComponent.Width})";
            RightComponent.Width = $"calc(100% - {leftSize.ToString()})";

            return(this);
        }
Example #4
0
        public SplitView RightIsSmaller(UnitSize rightSize)
        {
            RightComponent.Width = $"calc({rightSize.ToString()} - {SplitterComponent.Width})";
            LeftComponent.Width  = $"calc(100% - {rightSize.ToString()})";

            return(this);
        }
Example #5
0
        public void OnGet()
        {
            var data = Data.TestData.Data1DimWithLabels.ToDataTable(conf =>
            {
                conf.AddColumn(x => x.Item1);
                conf.AddColumn(x => x.Item2);
            });

            DataJson = data.ToJson();


            var options = new PieChartOptions
            {
                Height = 400,
                Width  = 500,
                SliceVisibilityThreshold = 0.05,
                ChartArea = new ChartArea {
                    BackgroundColor = Color.AliceBlue, Left = UnitSize.Percent(5), Width = UnitSize.Percent(90)
                },
                PieHole = 0.5,
                Legend  = new LegendOptions {
                    Position = LegendPosition.None
                }
            };

            OptionsJson = options.ToJson();
        }
 public SelectionModel(double minimumFileSize, double maximumFileSize, UnitSize unitSize)
 {
     AvoidPreviousCopied = true;
     _unitSize           = unitSize;
     MinimumFileSize     = minimumFileSize;
     MaximumFileSize     = maximumFileSize;
 }
Example #7
0
        public DetailsListColumn(string title, UnitSize width, bool isRowHeader = false, bool enableColumnSorting = false, string sortingKey = null, Action onColumnClick = null)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentException(nameof(title));
            }

            if (enableColumnSorting && string.IsNullOrWhiteSpace(sortingKey))
            {
                throw new ArgumentException(nameof(sortingKey));
            }

            Width               = width ?? throw new ArgumentNullException(nameof(width));
            SortingKey          = sortingKey ?? string.Empty;
            Title               = title;
            IsRowHeader         = isRowHeader;
            EnableColumnSorting = enableColumnSorting;

            if (onColumnClick != null)
            {
                _onColumnClick           = onColumnClick;
                EnableOnColumnClickEvent = true;
            }

            InnerElement = TextBlock(Title).Regular().SemiBold().Render();
        }
Example #8
0
 public void Init(UnitSize size, UnitShape shape, UnitColor color)
 {
     m_UnitGO = gameObject;
     m_Size   = size;
     m_Shape  = shape;
     m_Color  = color;
 }
        /// <summary>
        /// The ToString method returns a string representation of the USCookingVolumeMeasurement
        /// </summary>
        /// <returns>String representation of the USCookingVolumeMeasurement</returns>
        public override string ToString()
        {
            //add S to end of unit if more than 1
            string unitString = Amount.CompareTo(1) > 0 ? UnitSize.ToString().ToLower() + "s" : UnitSize.ToString().ToLower();

            return(Amount.ToString() + " " + unitString);
        }
 static byte[] Decompress(byte[] data, UnitSize unitSize)
 {
     fixed (byte* pointer = &data[0])
     {
         return Decompress(pointer, data.Length, unitSize);
     }
 }
Example #11
0
 private static void SetHtmlElementHeight(HTMLElement htmlElement, UnitSize height)
 {
     htmlElement.SetStyle(cssStyleDeclaration =>
     {
         cssStyleDeclaration.height = height.ToString();
     });
 }
Example #12
0
 /// <summary>
 /// Creates a new instance of <see cref="FindOptions"/>.
 /// </summary>
 /// <param name="searchBackwards">Indicates if a match is searched from end to beginning of the data.</param>
 /// <param name="preBufferSize">Gets the size of a buffer that must come before the first searched position.</param>
 /// <param name="skipUnits">Gets the number of units to skipUnits after a match was found.</param>
 /// <param name="unitSize">Gets the size of a unit.</param>
 /// <param name="taskCount">Gets the number of tasks to use for parallel match finding.</param>
 public FindOptions(bool searchBackwards, int preBufferSize, int skipUnits, UnitSize unitSize, int taskCount)
 {
     SearchBackwards     = searchBackwards;
     PreBufferSize       = preBufferSize;
     SkipUnitsAfterMatch = skipUnits;
     UnitSize            = unitSize;
     TaskCount           = taskCount;
 }
Example #13
0
        private FileSize(UnitSize unitSize, double units)
        {
            Guard.NotNull(nameof(unitSize), unitSize);
            Guard.GreaterThanOrEqual(nameof(units), units, 0);

            this._unitSize = unitSize;
            this._units    = units;
        }
Example #14
0
 public static T Margin <T>(this T component, UnitSize unitSize) where T : IComponent
 {
     Stack.SetMarginLeft(component, unitSize);
     Stack.SetMarginRight(component, unitSize);
     Stack.SetMarginTop(component, unitSize);
     Stack.SetMarginBottom(component, unitSize);
     return(component);
 }
Example #15
0
 public static T Padding <T>(this T component, UnitSize unitSize) where T : IComponent
 {
     Stack.SetPaddingLeft(component, unitSize);
     Stack.SetPaddingRight(component, unitSize);
     Stack.SetPaddingTop(component, unitSize);
     Stack.SetPaddingBottom(component, unitSize);
     return(component);
 }
Example #16
0
            internal void Map(UnitSize unitSize)
            {
                if (unitSize == null)
                {
                    return;
                }

                unitSize.Name = Name;
            }
Example #17
0
        public ItemsList(ObservableList <IComponent> items, params UnitSize[] columns)
        {
            Items = items ?? new ObservableList <IComponent>();

            if (columns.Length < 2)
            {
                _stack            = Stack().Horizontal().Wrap().WidthStretch().MaxHeight(100.percent()).Scroll();
                _maxStackItemSize = columns.FirstOrDefault() ?? 100.percent();
            }
            else
            {
                _grid = Grid(columns).WidthStretch().MaxHeight(100.percent()).Scroll();
            }
            _emptyListMessageGenerator = null;

            _defered = Defer(Items, observedItems =>
            {
                if (!observedItems.Any())
                {
                    if (_emptyListMessageGenerator is object)
                    {
                        if (_grid is object)
                        {
                            return(_grid.Children(_emptyListMessageGenerator().GridColumnStretch()).AsTask());
                        }
                        else
                        {
                            return(_stack.Children(_emptyListMessageGenerator().WidthStretch().HeightStretch()).AsTask());
                        }
                    }
                    else
                    {
                        if (_grid is object)
                        {
                            _grid.Clear();
                            return(_grid.AsTask());
                        }
                        else
                        {
                            _stack.Clear();
                            return(_stack.AsTask());
                        }
                    }
                }
                else
                {
                    if (_grid is object)
                    {
                        return(_grid.Children(Items.ToArray()).AsTask());
                    }
                    else
                    {
                        return(_stack.Children(Items.Select(i => i.Width(_maxStackItemSize)).ToArray()).AsTask());
                    }
                }
            });
        }
        public void OnGet()
        {
            var data = GetData()
                       .ToDataTable(conf =>
            {
                conf.AddColumn(x => x.Time);
                conf.AddColumn(x => x.Min);
                conf.AddColumn(x => x.Initial);
                conf.AddColumn(x => x.Final);
                conf.AddColumn(x => x.Max);
            });

            DataJson = data.ToJson();


            var options = new CandlestickChartOptions
            {
                Height         = 400,
                Width          = UnitSize.Percent(100),
                Title          = "My sin approximation",
                HorizontalAxis = new HorizontalAxis
                {
                    TextPosition = AxisTextPosition.Out,
                    Gridlines    = new AxisGridLines
                    {
                        Interval = new double[] { Math.PI / 4 }
                    },
                    Format = "#.##"
                },
                Bar = new ColumnChartBar {
                    GroupWidth = UnitSize.Percent(100)
                },
                Legend = new LegendOptions {
                    Position = LegendPosition.None
                },
                Candlestick = new CandlestickOptions
                {
                    HollowIsRising = true,
                    FallingColor   = Color.OrangeRed,
                    RisingColor    = Color.MediumVioletRed
                },
                ChartArea = new ChartArea
                {
                    BackgroundColor = Color.AliceBlue,
                    Left            = UnitSize.Percent(5),
                    Width           = UnitSize.Percent(95)
                },
                DataOpacity   = 0.8,
                TitlePosition = TitlePosition.In
            };

            OptionsJson = options.ToJson();
        }
Example #19
0
    public void DismissGenericUnit(UnitSlot unitSlot)
    {
        // get PartyUnit UI
        PartyUnitUI unitUI = unitSlot.GetComponentInChildren <PartyUnitUI>();
        // get PartyUnit
        PartyUnit partyUnit = unitUI.LPartyUnit;
        // Get Unit size, because unit is going to be destroyed
        UnitSize unitSize = partyUnit.UnitSize;
        // Get Party Unit HeroParty
        //HeroParty heroParty = partyUnit.GetComponentInParent<HeroParty>();
        // 1 get all required variables, before removing unit
        Transform  unitCell   = unitSlot.transform.parent;
        PartyPanel partyPanel = GetUnitsParentPartyPanel(unitCell);

        // 2 and put it to recycle bin, because otherwise PartyPanel.GetNumberOfPresentUnits() will return wrong number of units, because object is actually destroyed after Update()
        // unitUI.transform.SetParent(transform.root.GetComponentInChildren<RecycleBin>().transform);
        // 3 destory unit canvas, where it is linked to
        // Destroy(unitUI.gameObject);
        // 4 and put it to recycle bin, because otherwise city.GetNumberOfPresentUnits() will return wrong number of units, because object is actually destroyed after Update()
        // partyUnit.transform.SetParent(transform.root.GetComponentInChildren<RecycleBin>().transform);
        // 5 and destory party unit itself
        // Destroy(partyUnit.gameObject);
        RecycleBin.Recycle(unitUI.gameObject);
        RecycleBin.Recycle(partyUnit.gameObject);
        // Update party panel
        // act based on the unit size
        if (unitSize == UnitSize.Single)
        {
            partyPanel.OnChange(PartyPanel.ChangeType.DismissSingleUnit, unitCell);
        }
        else
        {
            partyPanel.OnChange(PartyPanel.ChangeType.DismissDoubleUnit, unitCell);
        }
        // if parent Party panel is in Garnizon state, then update focus panel
        if (PartyMode.Garnizon == partyPanel.PartyMode)
        {
            // Instruct focus panel linked to a city to update information
            // act based on the unit size
            if (unitSize == UnitSize.Single)
            {
                GetComponentInParent <UIManager>().GetFocusPanelByCity(LCity).OnChange(FocusPanel.ChangeType.DismissSingleUnit);
            }
            else
            {
                GetComponentInParent <UIManager>().GetFocusPanelByCity(LCity).OnChange(FocusPanel.ChangeType.DismissDoubleUnit);
            }
            // Activate hire unit buttons again
            SetHireUnitPnlButtonActive(true);
        }
    }
Example #20
0
            public double ConvertTo(UnitSize yours, double units)
            {
                if (yours.UnitValue > this.UnitValue)
                {
                    return(units / (yours.UnitValue / this.UnitValue));
                }

                if (yours.UnitValue < this.UnitValue)
                {
                    return(units * (this.UnitValue / yours.UnitValue));
                }

                return(units);
            }
Example #21
0
 public SplitView(UnitSize splitterSize = null)
 {
     LeftComponent           = Raw(Div(_()));
     SplitterComponent       = Raw(Div(_("tss-splitter")));
     RightComponent          = Raw(Div(_()));
     SplitterComponent.Width = (splitterSize is object && splitterSize.Unit != Unit.Auto && splitterSize.Unit != Unit.Inherit)
                                   ? splitterSize.ToString()
                                   : "8px";
     LeftComponent.Height     = "100%";
     SplitterComponent.Height = "100%";
     RightComponent.Height    = "100%";
     SplitInMiddle();
     InnerElement = Div(_("tss-splitview"), LeftComponent.Render(), SplitterComponent.Render(), RightComponent.Render());
 }
Example #22
0
        public static UnitSize ParseSize(string prop, string value, UnitSize prev)
        {
            var result = prev ?? new UnitSize();

            switch (prop)
            {
            case nameof(UnitSize.Name):
                result.Name = value;
                break;

            default: throw UnsupportedPropertyOf <UnitSize>(prop);
            }

            return(result);
        }
Example #23
0
        internal static IComponent CreateGradientOverlay(IComponent component, UnitSize maxContentHeight)
        {
            var container = component.Render();

            container.style.overflow  = "hidden";
            container.style.maxHeight = maxContentHeight.ToString();
            container.style.setProperty("isolation", "isolate");
            container.style.position = "relative"; //otherwise the position:absolute of the style bellow doesnt work

            var gradient = Div(_("card-gradient-overlay"));

            gradient.style.top = $"calc({maxContentHeight} - 40px)";
            container.appendChild(gradient);
            return(Raw(container));
        }
Example #24
0
        public void LoadRecipe(MapUnitRecipe recipe)
        {
            spriteRenderer.sprite = recipe.sprite;

            attackSound = recipe.attackSound;
            jumpSound   = recipe.jumpSound;
            runSound    = recipe.runSound;

            hp = new Capacitor(recipe.maxHp);
            ap = new Capacitor(recipe.maxAp);

            move = recipe.move;
            jump = recipe.jump;

            size = recipe.size;
        }
Example #25
0
        public void ResetForPool()
        {
            spriteRenderer.sprite = null;

            attackSound = null;
            jumpSound   = null;
            runSound    = null;

            hp = null;
            ap = null;

            move = 0;
            jump = 0;

            size = UnitSize.small;
        }
Example #26
0
        /// <inheritdoc/>
        public override string ModelSummary()
        {
            using (StringWriter htmlWriter = new StringWriter())
            {
                htmlWriter.Write("\r\n<div class=\"activityentry\"><span class=\"setvalue\">");
                // get amount
                htmlWriter.Write(LabourPerUnit.ToString() + "</span> days labour is required");
                if (UnitType != LabourUnitType.Fixed)
                {
                    if (UnitSize == 1)
                    {
                        htmlWriter.Write(" for each ");
                    }
                    else
                    {
                        htmlWriter.Write(" for every <span class=\"setvalue\">" + UnitSize.ToString("#,##0.##") + "</span>");
                    }

                    htmlWriter.Write("<span class=\"setvalue\">" + UnitType2HTML() + "</span>");
                    if (WholeUnitBlocks)
                    {
                        htmlWriter.Write(" and will be supplied in blocks");
                    }
                }
                htmlWriter.Write("</div>");

                if (MinimumPerPerson > 0)
                {
                    htmlWriter.Write("\r\n<div class=\"activityentry\">Labour will not be supplied if less than <span class=\"setvalue\">" + MinimumPerPerson.ToString() + "</span> day" + ((MinimumPerPerson == 1) ? "" : "s") + " is required</div>");
                }

                if (MaximumPerPerson > 0 && MaximumPerPerson < 30)
                {
                    htmlWriter.Write("\r\n<div class=\"activityentry\">No individual can provide more than <span class=\"setvalue\">" + MaximumPerPerson.ToString() + "</span> days</div>");
                }

                if (ApplyToAll)
                {
                    htmlWriter.Write("\r\n<div class=\"activityentry\">All people matching the below criteria (first level) will perform this task. (e.g. all children)</div>");
                }

                return(htmlWriter.ToString());
            }
        }
        private double GetSizeModifier(UnitSize size, int level)
        {
            double modifier = 0;

            if (level == 1 && size == UnitSize.Small)
            {
                modifier = this.costs.Level1SmallSizeCostModifier;
            }
            else if (level == 2 && size == UnitSize.Small)
            {
                modifier = this.costs.Level2SmallSizeCostModifier;
            }
            else if (level == 3 && size == UnitSize.Large)
            {
                modifier = this.costs.Level3LargeSizeCostModifier;
            }

            return modifier;
        }
Example #28
0
        public UnitSize GetUnitSize(string unitText)
        {
            if (unitText.IsEmpty())
            {
                return(UnitSize.Empty());
            }

            var productUnit = unitText.GetLastWord().ToLower();

            var shouldHandle = _validUnitIdentifiers.Contains(productUnit);

            if (!shouldHandle)
            {
                return(UnitSize.Empty());
            }

            var secondLastWord = unitText.GetSecondLastWord();

            return(new UnitSize("stuks", decimal.Parse(secondLastWord)));
        }
Example #29
0
        public DetailsListIconColumn(Icon icon, UnitSize width, bool enableColumnSorting = false, string sortingKey = null, Action onColumnClick = null)
        {
            if (enableColumnSorting && string.IsNullOrWhiteSpace(sortingKey))
            {
                throw new ArgumentException(nameof(sortingKey));
            }

            Icon                = icon;
            Width               = width ?? throw new ArgumentNullException(nameof(width));
            SortingKey          = sortingKey ?? string.Empty;
            EnableColumnSorting = enableColumnSorting;

            if (onColumnClick != null)
            {
                _onColumnClick           = onColumnClick;
                EnableOnColumnClickEvent = true;
            }

            InnerElement = Div(_()).appendChild(Icon.Render());
        }
Example #30
0
        public UnitSize GetUnitSize(string unitText)
        {
            if (unitText.IsEmpty())
            {
                return(UnitSize.Empty());
            }

            var productUnit  = unitText.GetLastWord().ToLower();
            var shouldHandle = _unitBuilder.ContainsKey(productUnit);

            if (!shouldHandle)
            {
                return(UnitSize.Empty());
            }

            var unit           = _unitBuilder[productUnit]();
            var secondLastWord = unitText.GetSecondLastWord();

            unit.SetSize(secondLastWord);

            return(new UnitSize(unit.DisplayValue, unit.Liters));
        }
Example #31
0
        // left top width height
        public static UnitPosition GetUnitPosition(Unit u, double cellSizeX, double cellSizeY)
        {
            UnitPosition position = new UnitPosition();

            UnitSize unitSize = u.UnitSize;

            double w = (int)unitSize * cellSizeX / 100;
            double h = (int)unitSize * cellSizeY / 100;


            double offsetX = 0;
            double offsetY = 0;

            offsetX = (cellSizeX - w) / 2;
            offsetY = (cellSizeY - h) / 2;


            position.Height  = h;
            position.Width   = w;
            position.OffsetX = offsetX;
            position.OffsetY = offsetY;
            return(position);
        }
        public void OnGet()
        {
            var data = Data.TestData.Data4DimRandom.ToDataTable(conf =>
            {
                int i = 1;
                conf.AddColumn(x => $"Bubble {i++}");
                conf.AddColumn(ColumnType.Number, "X axis", x => x.Item1);
                conf.AddColumn(ColumnType.Number, "Y axis", x => x.Item2);
                conf.AddColumn(ColumnType.String, "Odd or even", x => x.Item4 % 2 == 0 ? "Even" : "Odd");
                conf.AddColumn(ColumnType.Number, "Size", x => x.Item4);
                conf.WithOptions <ChartOptions>(opt =>
                {
                    opt.Height = 300;
                    opt.Width  = UnitSize.Percent(100);
                    //opt.Title = "My bubble chart";
                });
            });

            DataJson = data.ToJson();


            OptionsJson = data.Options.ToJson();
        }
        static byte[] Decompress(byte* data, int length, UnitSize unitSize)
        {
            byte[] result = new byte[(*(int*)data) >> 8];

            return result;
        }
 private int CalculateFinalCost(double baseCost, UnitSize size, int level)
 {
     return (int)(baseCost * (1 + GetSizeModifier(size, level) + this.costs.LevelCostModifiers[level - 1]));
 }