private string CmpToStr(FieldComponent cmp) { switch (cmp) { case FieldComponent.Unckown: throw new ArgumentOutOfRangeException(); case FieldComponent.Gic: throw new ArgumentOutOfRangeException(); case FieldComponent.Ex: return("EX"); case FieldComponent.Ey: return("EY"); case FieldComponent.Hx: return("X"); case FieldComponent.Hy: return("Y"); case FieldComponent.Hz: return("Z"); case FieldComponent.Dx: throw new ArgumentOutOfRangeException(); case FieldComponent.Dy: throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException(nameof(cmp), cmp, null); } }
internal FieldComponent(FieldComponent component) { this.fieldNum = component.fieldNum; this.accumulate = component.accumulate; this.bits = component.bits; this.scale = component.scale; this.offset = component.offset; this.accumulatedValue = component.accumulatedValue; this.lastValue = component.lastValue; }
public EditableFieldPanel() { DoubleBuffered = true; MidfieldLineXPosition = 25; //standard 25 MidfieldPointYPosition = 12; //standard 12 LeftGoalHeight = 5; //standard 5 LeftGoalYPosition = 10; //standard 10 RightGoalHeight = 5; //standard 5 RightGoalYPosition = 10; //standard 10 currentFieldComponent = FieldComponent.Nothing; }
public void Restart(FieldComponent field, CounterComponent counter) { for (var x = 0; x < field.Map.GetLength(0); x++) for (var y = 0; y < field.Map.GetLength(1); y++) { field.Map[x, y] = Random.NextInt(SharedData.ColorsCount); } counter.GameOver = false; for (int i = 0; i < counter.Players.Count; i++) { counter.Players[i].Size = 1; } }
private void GameOver(CounterComponent counter, FieldComponent field, bool isWin) { if (isWin) { counter.Players[0].Wins++; } counter.GamesPlayed++; counter.GameOver = true; Core.Instance.SwitchScene( new WindTransition { SceneLoadAction = () => { this.scene.Restart(field, counter); return(this.scene); } }); }
public static bool HasRipeness(FieldComponent field) { bool anyRipe = false; for (int x = 0; x < field.ripeness.XLength; x++) { for (int y = 0; y < field.ripeness.YLength; y++) { if (field.ripeness[x, y] >= 1) { anyRipe = true; break; } } if (anyRipe) { break; } } return(anyRipe); }
/// <summary> /// Returns which Cursor the program should show for the specific FieldComponent. /// </summary> /// <param name="component"></param> /// <returns></returns> private Cursor GetFittingCursor(FieldComponent component) { switch (component) { case FieldComponent.LeftGoalHeight: return Cursors.SizeNS; case FieldComponent.LeftGoalY: return Cursors.Hand; case FieldComponent.LeftGoalHeightAndY: return Cursors.SizeNS; case FieldComponent.MidlineX: return Cursors.SizeWE; case FieldComponent.Midpoint: return Cursors.SizeAll; case FieldComponent.RightGoalHeight: return Cursors.SizeNS; case FieldComponent.RightGoalY: return Cursors.Hand; case FieldComponent.RightGoalHeightAndY: return Cursors.SizeNS; default: return Cursors.Cross; } }
private Rectangle GetChangedRectangle(FieldComponent component) { int cellWidth = fieldCell[0, 0].Width; int cellHeight = fieldCell[0, 0].Height; Rectangle changedRectangle = new Rectangle(0, 0, 0, 0); switch (component) { case FieldComponent.MidlineX: case FieldComponent.Midpoint: Point location = fieldCell[MidfieldLineXPosition - 3, 0].Location; location.X -= 5; Size size = new Size(cellWidth * 17 + 10, (fieldCell.GetLength(1) + 2) * cellHeight); changedRectangle = new Rectangle(location, size); break; case FieldComponent.LeftGoalHeight: case FieldComponent.LeftGoalHeightAndY: case FieldComponent.LeftGoalY: Point lLocation = fieldCell[0, 0].Location; Size lSize = new Size(cellWidth * 17 + 10, (fieldCell.GetLength(1) + 2) * cellHeight); changedRectangle = new Rectangle(lLocation, lSize); break; case FieldComponent.RightGoalHeight: case FieldComponent.RightGoalHeightAndY: case FieldComponent.RightGoalY: Point rLocation = fieldCell[fieldCell.GetLength(0) - 8, 0].Location; Size rSize = new Size(cellWidth * 17 + 10, (fieldCell.GetLength(1) + 2) * cellHeight); changedRectangle = new Rectangle(rLocation, rSize); break; } return changedRectangle; }
void FieldGrid_MouseMove(object sender, MouseEventArgs e) { Point mousePoint = e.Location; Point gridLocation = SearchGridIndex(mousePoint); if (gridLocation.X >= 0 && gridLocation.X < fieldCell.GetLength(0) && gridLocation.Y >= 0 && gridLocation.Y < fieldCell.GetLength(1)) { Rectangle rectangle = fieldCell[gridLocation.X, gridLocation.Y]; if (rectangle.Contains(mousePoint) && !rectangle.Equals(currentMouseRectangle)) { if (IsBlocked) { FieldGrid.Cursor = Cursors.No; } else { if ((Control.MouseButtons & MouseButtons.Left) == MouseButtons.Left) { int horizontalDirection = gridLocation.X - oldGridLocation.X; int verticalDirection = gridLocation.Y - oldGridLocation.Y; MoveCurrentFieldComponent(horizontalDirection, verticalDirection); StadiumPanel.UpdateSettings(fieldCell, CurrentSettings, FieldGrid.Location); StadiumPanel.Invalidate(GetChangedRectangle(currentFieldComponent)); } else { Rectangle invalidateRectangle = new Rectangle(currentMouseRectangle.Location, new Size(currentMouseRectangle.Width + 1, currentMouseRectangle.Height + 1)); FieldGrid.Invalidate(invalidateRectangle); currentMouseRectangle = rectangle; invalidateRectangle = new Rectangle(rectangle.Location, new Size(rectangle.Width + 1, rectangle.Height + 1)); FieldGrid.Invalidate(invalidateRectangle); currentFieldComponent = GetFieldComponent(gridLocation); FieldGrid.Cursor = GetFittingCursor(currentFieldComponent); } currentMouseRectangle = rectangle; oldGridLocation = gridLocation; } } } }
public ChannelInfo(string name, FieldComponent cmp) { Name = name; Component = cmp; }
protected void WalkElements(CodeElement cein, AbstractComponent parent) { CodeElements ces; switch (cein.Kind) { // Handle namespaces case EnvDTE.vsCMElement.vsCMElementNamespace: { CodeNamespace cn = (CodeNamespace)cein; ces = cn.Members; foreach (CodeElement ce in ces) { WalkElements(ce, parent); } break; } // Handle classes case EnvDTE.vsCMElement.vsCMElementClass: { CodeClass cc = (CodeClass)cein; ClassComponent cls = new ClassComponent(cc.FullName, cc.Name); cls.CodeClass = cc; parent.Visit(cls); ces = cc.Members; foreach (CodeElement ce in ces) { WalkElements(ce, cls); } break; } // Handle interfaces case EnvDTE.vsCMElement.vsCMElementInterface: { CodeInterface ci = (CodeInterface)cein; // nothing for now. break; } // Handle methods (functions) case EnvDTE.vsCMElement.vsCMElementFunction: { CodeFunction cf = (CodeFunction)cein; MethodComponent mc = new MethodComponent(cf.FullName, cf.Name); parent.Visit(mc); mc.CreateRepresentation(GetFunctionText(cf)); mc.CodeFunction = cf; break; } // Handle properties case EnvDTE.vsCMElement.vsCMElementProperty: { CodeProperty cp = (CodeProperty)cein; PropertyComponent pc = new PropertyComponent(cp.FullName, cp.Name); parent.Visit(pc); break; } // Handle fields (variables) case EnvDTE.vsCMElement.vsCMElementVariable: { CodeVariable cv = (CodeVariable)cein; FieldComponent fc = new FieldComponent(cv.FullName, cv.Name); parent.Visit(fc); break; } } }
internal void AddComponent(FieldComponent newComponent) { components.Add(newComponent); }
void mainService_OnSetConfig(object sender, HDCPProtocol2.HDCP.HDCPParserArgs e) { try { var configPro = e.MessageData.Components.Where(p => p.Name == HDCPCommand.SET_CONFIG.ToString()).FirstOrDefault(); if (configPro != null) { FieldComponent component = new FieldComponent(); component.FromXml(configPro.Value); bool needRestart = false; #region Config var proDBStation = component.Components.Where(c => c.ID == configDBStationID).FirstOrDefault() as FieldOne; if (proDBStation != null && proDBStation.Value != null && proDBStation.Value.ToString() != config.DBStationConnectionString) { config.DBStationConnectionString = proDBStation.Value.ToString(); needRestart = true; } var proAsRunLogFolder = component.Components.Where(c => c.ID == configAsRunLogFolderID).FirstOrDefault() as FieldOne; if (proAsRunLogFolder != null) { config.AsRunLogFolder = proAsRunLogFolder.Value as string; } var proAdTypes = component.Components.Where(c => c.ID == configAdTypeID).FirstOrDefault() as FieldOne; if (proAdTypes != null) { config.AdTypes = proAdTypes.Value as string; } var proAdMaxDuration = component.Components.Where(c => c.ID == configAdMaxDurationID).FirstOrDefault() as FieldOne; if (proAdMaxDuration != null) { config.MaxAdDuration = (long)proAdMaxDuration.Value; } var proVODFolder = component.Components.Where(c => c.ID == configVODFolderID).FirstOrDefault() as FieldOne; if (proVODFolder != null) { config.VODFolder = proVODFolder.Value as string; } var proVODXmlFolder = component.Components.Where(c => c.ID == configVODXmlFolderID).FirstOrDefault() as FieldOne; if (proVODXmlFolder != null) { config.VODXmlFolder = proVODXmlFolder.Value as string; } var proSessionStr = component.Components.Where(c => c.ID == configSessionStrID).FirstOrDefault() as FieldOne; if (proSessionStr != null) { config.sessionStr = proSessionStr.Value as string; } var proImportTime = component.Components.Where(c => c.ID == configImportTimeID).FirstOrDefault() as FieldOne; if (proImportTime != null) { config.ImportTime = (int)proImportTime.Value; } var proExportTime = component.Components.Where(c => c.ID == configExportTimeID).FirstOrDefault() as FieldOne; if (proExportTime != null) { config.ExportTime = (int)proExportTime.Value; } var proLastExportDay = component.Components.Where(c => c.ID == configLastExportDay).FirstOrDefault() as FieldOne; if (proLastExportDay != null) { config.LastExportDay = (int)proLastExportDay.Value; } var proLastExportHour = component.Components.Where(c => c.ID == configLastExportHour).FirstOrDefault() as FieldOne; if (proLastExportHour != null) { config.LastExportHour = (int)proLastExportHour.Value; } var proEmail = component.Components.Where(c => c.ID == configEmailID).FirstOrDefault() as FieldOne; if (proEmail != null) { config.EmailSend = proEmail.Value as string; } config.SaveObject(configPath); #endregion if (needRestart) { mainService.Restart(); } SendLogToAll("Đặt cấu hình thành công"); } } catch (Exception ex) { SendLogToAll("Lỗi đặt cấu hình:" + ex.Message); } }
void mainService_OnGetConfig(object sender, HDCPProtocol2.HDCP.HDCPParserArgs e) { try { HDCPParserArgs Command = new HDCPParserArgs() { RemoteHostState = e.RemoteHostState, Command = HDCPCommand.CONFIG, MessageData = new MessageData() }; FieldComponent component = new FieldComponent(); #region Config component.AddComponent(new FieldOne() { ID = configDBStationID, DisplayText = "Chuỗi kết nối DB Station", Value = config.DBStationConnectionString }); component.AddComponent(new FieldOne() { ID = configAsRunLogFolderID, DisplayText = "As run log xml folder", Value = config.AsRunLogFolder }); component.AddComponent(new FieldOne() { ID = configAdTypeID, DisplayText = "Thể loại của quảng cáo(mỗi thể loại cách nhau bằng dấu ;)", Value = config.AdTypes }); component.AddComponent(new FieldOne() { ID = configAdMaxDurationID, DisplayText = "Thời lượng tối đa của quảng cáo(frame)", Type = FieldType.Long, EditMark = "n0", Value = config.MaxAdDuration }); component.AddComponent(new FieldOne() { ID = configVODFolderID, DisplayText = "VOD folder", Value = config.VODFolder }); component.AddComponent(new FieldOne() { ID = configVODXmlFolderID, DisplayText = "VOD XML Folder", Value = config.VODXmlFolder }); component.AddComponent(new FieldOne() { ID = configSessionStrID, DisplayText = "Session String", Value = config.sessionStr }); component.AddComponent(new FieldOne() { ID = configImportTimeID, DisplayText = "Thời gian quét As run log(giây)", Type = FieldType.Int, EditMark = "n0", MinValue = 10, MaxValue = 36000, Value = config.ImportTime }); component.AddComponent(new FieldOne() { ID = configExportTimeID, DisplayText = "Thời gian xuất VOD(giây)", Type = FieldType.Int, EditMark = "n0", MinValue = 10, MaxValue = 36000, Value = config.ExportTime }); component.AddComponent(new FieldOne() { ID = configLastExportDay, DisplayText = "Ngày cuối cùng xuất VOD", Type = FieldType.Int, EditMark = "f0", MinValue = -10, MaxValue = 0, Value = config.LastExportDay }); component.AddComponent(new FieldOne() { ID = configLastExportHour, DisplayText = "Giờ cuối cùng xuất VOD", Type = FieldType.Int, EditMark = "f0", MinValue = -23, MaxValue = 0, Value = config.LastExportHour }); component.AddComponent(new FieldOne() { ID = configEmailID, DisplayText = "Email", Value = config.EmailSend }); #endregion Command.MessageData.AddComponent(HDCPCommand.CONFIG.ToString(), component.ToXml()); SendTo(Command, e.RemoteHostState); } catch (Exception ex) { SendLogToAll("Lỗi gửi cấu hình:" + ex.Message); HDCPParserArgs Command = new HDCPParserArgs() { RemoteHostState = e.RemoteHostState, Command = HDCPCommand.CONFIG, MessageData = new MessageData() }; SendTo(Command, e.RemoteHostState); } }
private void CreateUI() { _Frame = new Skill.Editor.UI.EditorFrame("Frame", this); _Frame.Grid.RowDefinitions.Add(120, Skill.Framework.UI.GridUnitType.Pixel); // Panel _Frame.Grid.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star); // Empty _Frame.Grid.Padding = new Skill.Framework.UI.Thickness(2, 4); _Panel = new Skill.Framework.UI.Grid(); _Panel.RowDefinitions.Add(36, Skill.Framework.UI.GridUnitType.Pixel); // Axis step _Panel.RowDefinitions.Add(24, Skill.Framework.UI.GridUnitType.Pixel); // _BtnLocal _Panel.RowDefinitions.Add(22, Skill.Framework.UI.GridUnitType.Pixel); // Duplicate _Panel.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star); // MoveButton _Panel.ColumnDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star); _Panel.ColumnDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star); _Frame.Controls.Add(_Panel); var margin = new Skill.Framework.UI.Thickness(0, 4, 0, 0); var alignment = Skill.Framework.UI.VerticalAlignment.Top; Grid xyzStep = new Grid() { Row = 0, Column = 0, ColumnSpan = 2 }; xyzStep.ColumnDefinitions.Add(1, GridUnitType.Star); xyzStep.ColumnDefinitions.Add(1, GridUnitType.Star); xyzStep.ColumnDefinitions.Add(1, GridUnitType.Star); _Panel.Controls.Add(xyzStep); _XStep = new FieldComponent() { Column = 0, Value = _SerializedStep.x, Label = "X", Margin = new Thickness() }; xyzStep.Controls.Add(_XStep); _YStep = new FieldComponent() { Column = 1, Value = _SerializedStep.y, Label = "Y", Margin = new Thickness(4, 0, 0, 0) }; xyzStep.Controls.Add(_YStep); _ZStep = new FieldComponent() { Column = 2, Value = _SerializedStep.z, Label = "Z", Margin = new Thickness(4, 0, 0, 0) }; xyzStep.Controls.Add(_ZStep); _BtnLocal = new Framework.UI.Button() { Row = 1, Column = 0, ColumnSpan = 2, Margin = margin }; _BtnLocal.Content.text = _SerializedLocal ? "Local" : "Global"; _BtnLocal.Content.tooltip = "local or global space"; _Panel.Controls.Add(_BtnLocal); _TbDuplicate = new Skill.Editor.UI.ToggleButton() { Row = 2, Column = 0, Left = true, IsChecked = _SerializedDuplicate, Margin = margin, VerticalAlignment = alignment }; _TbDuplicate.Label.text = "Duplicate"; _TbDuplicate.Label.tooltip = "duplicate instance"; _Panel.Controls.Add(_TbDuplicate); _IntInstance = new Skill.Editor.UI.IntField() { Row = 2, Column = 1, Value = _SerializedInstances, IsEnabled = false, Margin = margin, VerticalAlignment = alignment, ChangeOnReturn = false }; _IntInstance.Label.tooltip = "duplicate instance"; _Panel.Controls.Add(_IntInstance); _BtnMove = new Skill.Framework.UI.Button() { Row = 3, Column = 0, ColumnSpan = 2 }; SetMoveText(); _Panel.Controls.Add(_BtnMove); _TbDuplicate.Changed += _TbDuplicate_Changed; _IntInstance.ValueChanged += _IntInstance_ValueChanged; _XStep.ValueChanged += _XYZStep_ValueChanged; _YStep.ValueChanged += _XYZStep_ValueChanged; _ZStep.ValueChanged += _XYZStep_ValueChanged; _BtnMove.Click += _BtnMove_Click; _BtnLocal.Click += _BtnLocal_Click; }
// i = x + width*y; // x = i % width; // y = i / width; protected override void OnUpdate() { var cb = createCommandBuffer(); EntityQuery eqCells = GetEntityQuery(ComponentType.ReadWrite <JewelCell>()); EntityQuery eqField = GetEntityQuery(ComponentType.ReadOnly <FieldComponent>()); FieldComponent fieldComponent = eqField.GetSingleton <FieldComponent>(); width = fieldComponent.width; height = fieldComponent.height; using (var cells = eqCells.ToEntityArray(Allocator.TempJob)) { NativeArray <Entity> cellsMatrix = new NativeArray <Entity>(fieldComponent.width * fieldComponent.height, Allocator.TempJob); //fill matrix foreach (var entity in cells) { JewelCell cell = EntityManager.GetComponentData <JewelCell>(entity); int index = GetIndex(cell.x, cell.y); cellsMatrix[index] = entity; } for (int x = 0; x < width; x++) { int emptyY = -1; for (int y = height - 1; y >= 0; y--) { int index = GetIndex(x, y); if (emptyY == -1 && cellsMatrix[index] == Entity.Null) { emptyY = y; } if (cellsMatrix[index] != Entity.Null && emptyY != -1) { Entity e = cellsMatrix[index]; JewelCell cell = EntityManager.GetComponentData <JewelCell>(e); cb.SetComponent(e, new JewelCell { x = cell.x, y = emptyY }); cb.AddComponent(e, new FallComponent { position = SpawnerMono.IndexToPosition(cell.x, emptyY), speed = 10 }); emptyY--; } } if (emptyY < height - 1 && emptyY != -1) { for (int sy = emptyY; sy >= 0; sy--) { Debug.Log($"SPAWN FOR: {x},{sy}"); var entity = cb.CreateEntity(); cb.AddComponent(entity, new SpawnNeedComponent { x = x, y = sy }); } } } cellsMatrix.Dispose(); } }