public void Replace(MapSegment segment) { if (SegmentGameObject != null) GameObject.Destroy (SegmentGameObject); this.SegmentGameObject = segment.SegmentGameObject; this.State = segment.State; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ internal void Build(ArcState pArcState, SegmentState pSegState, float pArcAngle, ICustomSegment pCustom) { vArcState = pArcState; vSegState = pSegState; ArcAngle = pArcAngle; vSegState.SetCursorDistanceFunction(CalcCursorDistance); vCursorBaseTx = gameObject.transform.parent.parent.parent.parent; //HovercastSetup const float pi = (float)Math.PI; const float slideBufferAngle = pi / 80f; vSlideDegrees = (pArcAngle - slideBufferAngle * 2) / (float)Math.PI * 180; vSlideDir0 = MeshUtil.GetRingPoint(1, -pArcAngle / 2f + slideBufferAngle); //// Type rendType = pCustom.GetSegmentRenderer(vSegState.NavItem); SegmentSettings sett = pCustom.GetSegmentSettings(vSegState.NavItem); var rendObj = new GameObject("Renderer"); rendObj.transform.SetParent(gameObject.transform, false); vRenderer = (IUiSegmentRenderer)rendObj.AddComponent(rendType); vRenderer.Build(vArcState, vSegState, pArcAngle, sett); }
void SetState(SegmentState newState) { currentState = newState; switch (currentState) { case SegmentState.ATTACHED: InitAttached(); stateUpdate = AttachedUpdate; break; case SegmentState.DETACHED: InitDetached(); stateUpdate = DetachedUpdate; stateUpdate += RotateTowardNeighbor; break; case SegmentState.GRABBED: InitGrabbed(); stateUpdate = GrabbedUpdate; // stateUpdate += RotateTowardNeighbor; stateUpdate += RotateTowardsMouse; break; case SegmentState.FIXED: stateUpdate = null; break; } }
public int Serialize(ref byte[] targetBytes, int offset) { if (targetBytes == null) { throw new ArgumentNullException("targetBytes"); } if (!CanDirectCopy()) { var formatter = Formatter <TTypeResolver, T> .Default; if (formatter.NoUseDirtyTracker) { byte[] newBytes = null; var length = formatter.Serialize(ref newBytes, 0, Value); serializedBytes = new ArraySegment <byte>(newBytes, 0, newBytes.Length); state = SegmentState.Cached; } else { // direct direct write. return(formatter.Serialize(ref targetBytes, offset, Value)); } } BinaryUtil.EnsureCapacity(ref targetBytes, offset, serializedBytes.Count); Buffer.BlockCopy(serializedBytes.Array, serializedBytes.Offset, targetBytes, offset, serializedBytes.Count); return(serializedBytes.Count); }
public void Destroy(bool resetState) { if (SegmentGameObject != null) { GameObject.Destroy(SegmentGameObject); if(resetState) State = SegmentState.Destroyed; } }
public void Initialize(PathAvatar parentPath, int segmentNumber) { ParentPath = parentPath; mSegmentNumber = segmentNumber; State = new SegmentState(); State.Difficulty = PathDifficulty.None; //State.PassesOverSolidTerrainMesh = StartLocation.State.PlacedOnSolidTerrainMesh || EndLocation.State.PlacedOnSolidTerrainMesh; }
public AdjacentMovementCalculation(byte id, Direction movingOrFiringDirection, Direction currentDirectionOnSourceCell, SegmentState segmentStateInMovementDirection) { Id = id; MovingOrFiringDirection = movingOrFiringDirection; CurrentDirectionOnSourceCell = currentDirectionOnSourceCell; SegmentStateInMovementDirection = segmentStateInMovementDirection; }
public static QuerySegment GetDistinct(bool distinct, Type type, SegmentState state, LambdaExpression expression) { return(new QuerySegment() { Distinct = distinct, Type = type, State = state, Expression = expression }); }
public static QuerySegment GetLike(string likeText, Type type, SegmentState state, LambdaExpression expression) { return(new QuerySegment() { LikeText = likeText, Type = type, State = state, Expression = expression }); }
public static QuerySegment GetCount(int count, Type type, SegmentState state, LambdaExpression expression) { return(new QuerySegment() { Count = count, Type = type, State = state, Expression = expression }); }
public static QuerySegment GetTempTable(string tableName, Type type, SegmentState state, LambdaExpression expression) { return(new QuerySegment { TempTableName = tableName, Type = type, State = state, Expression = expression }); }
public CacheSegment(DirtyTracker tracker, ArraySegment <byte> originalBytes) { this.tracker = tracker.CreateChild(); this.state = SegmentState.Original; this.serializedBytes = originalBytes; this.cached = default(T); if (originalBytes.Array == null) { this.state = SegmentState.Dirty; } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public override void Build(ArcState pArcState, SegmentState pSegState, float pArcAngle, SegmentSettings pSettings) { base.Build(pArcState, pSegState, pArcAngle, pSettings); vIcon = GameObject.CreatePrimitive(PrimitiveType.Quad); vIcon.name = "Icon"; vIcon.transform.SetParent(gameObject.transform, false); vIcon.renderer.sharedMaterial = new Material(Shader.Find("Unlit/AlphaSelfIllum")); vIcon.renderer.sharedMaterial.color = Color.clear; vIcon.renderer.sharedMaterial.mainTexture = GetIconTexture(); vIcon.transform.localRotation = vLabel.CanvasLocalRotation; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { SegmentState state = (SegmentState)value; switch (state) { case Models.SegmentState.FailureA: return(new SolidColorBrush(Colors.Orange)); case Models.SegmentState.FailureB: return(new SolidColorBrush(Colors.Red)); default: return(new SolidColorBrush(Colors.Green)); } }
public static void CalculateSegmentStatesOnRandomPointsUsingCache(Tuple <Core.Point[], CellMatrixBasedSegmentStateCalculator> tuple) { Core.Point[] randomPoints = tuple.Item1; CellMatrixBasedSegmentStateCalculator calculator = tuple.Item2; foreach (Axis axis in BoardHelper.AllRealAxes) { foreach (Core.Point randomPoint in randomPoints) { SegmentState segState = calculator.GetSegmentState(axis, randomPoint); } } }
public void Reset() { allargs.Clear(); sbpack.Clear(); waitLf = false; state = SegmentState.Start; argsCount = 0; arglength = 0; currentline = 0; argcontentLeft = 0; waitValue = false; incompleteCommand = false; }
// called at the end of turn private void onTurnEnd(object sender, EventArgs a) { int ms = 0; for ( ; queue > 0; queue--, ms += intervalTime) { SegmentState st = Core.soundEffectManager.play(segment, ms); if (st != null) { states.Add(st); } } }
/*--------------------------------------------------------------------------------------------*/ public void Update() { SegmentState nearSeg = vArcState.NearestSegment; float highProg = (nearSeg == null ? 0 : nearSeg.HighlightProgress); bool high = (highProg >= 1); float thick = Mathf.Lerp(vSettings.ThickNorm, vSettings.ThickHigh, highProg); float scale = Mathf.Lerp(vSettings.RadiusNorm, vSettings.RadiusHigh, highProg); Color col = (high ? vSettings.ColorHigh : vSettings.ColorNorm); col.a *= UiSelectRenderer.GetArcAlpha(vArcState); BuildMesh(thick); vRingObj.transform.localScale = Vector3.one * scale; vRingObj.renderer.sharedMaterial.color = col; }
private static void CalculateSegmentStatesUsingCellCacheBasedCalculator(Tuple <Core.Point, CellMatrixBasedSegmentStateCalculator> tuple) { AndrewTweddle.BattleCity.Core.Point bottomRight = tuple.Item1; CellMatrixBasedSegmentStateCalculator calculator = tuple.Item2; foreach (Axis axis in BoardHelper.AllRealAxes) { for (int x = 0; x < bottomRight.X; x++) { for (int y = 0; y < bottomRight.Y; y++) { SegmentState segState = calculator.GetSegmentState(axis, x, y); } } } }
/// <summary> /// Very slow compared to caching. /// </summary> /// <param name="axisOfMovement"></param> /// <param name="point"></param> /// <returns></returns> public SegmentState GetSegmentStateUsingOffsets(Axis axisOfMovement, Point point) { Point[] offsets; SegmentState segmentState = SegmentState.Clear; switch (axisOfMovement) { case Axis.Horizontal: offsets = new Point[] { new Point(0, -2), new Point(0, -1), new Point(0, 0), new Point(0, 1), new Point(0, 2) }; break; case Axis.Vertical: offsets = new Point[] { new Point(-2, 0), new Point(-1, 0), new Point(0, 0), new Point(1, 0), new Point(2, 0) }; break; default: // case Axis.None: throw new ArgumentException( "Segment state can't be determined due to axis of movement being null", "axisOfMovement" ); offsets = new Point[0]; // To stop compiler complaining } Point[] segmentPoints = point.GetRelativePoints(offsets); foreach (Point relativePoint in segmentPoints) { if (!Board.IsOnBoard(relativePoint)) { return(SegmentState.OutOfBounds); } else { if (Board[relativePoint]) { segmentState = SegmentState.UnshootablePartialWall; } } } if (segmentState == SegmentState.UnshootablePartialWall) { if (Board[point]) { return(SegmentState.ShootableWall); } } return(segmentState); }
public static void CalculateSegmentStatesUsingOnTheFlyBoolBoolBasedCalculator( Tuple <Core.Point, OnTheFlyBoolMatrixBasedSegmentStateCalculator> tuple) { Core.Point bottomRight = tuple.Item1; OnTheFlyBoolMatrixBasedSegmentStateCalculator calculator = tuple.Item2; foreach (Axis axis in BoardHelper.AllRealAxes) { for (int x = 0; x < bottomRight.X; x++) { for (int y = 0; y < bottomRight.Y; y++) { SegmentState segState = calculator.GetSegmentState(axis, x, y); } } } }
private static string GetStateName(SegmentState state) { switch (state) { case SegmentState.Max: return("MAX"); case SegmentState.Min: return("Min"); case SegmentState.InnerJoin: case SegmentState.InnerJoinTempTable: return("INNER JOIN"); case SegmentState.LeftJoin: return("LEFT JOIN"); case SegmentState.RightJoin: return("RIGHT JOIN"); case SegmentState.Where: case SegmentState.WhereActive: return("WHERE"); case SegmentState.OrWhere: return("OR"); case SegmentState.AndWhere: case SegmentState.AndActive: return("AND"); case SegmentState.OrderBy: case SegmentState.OrderByDescending: return("ORDER BY"); case SegmentState.GroupBy: return("GROUP BY"); default: return(string.Empty); } }
public void setState(SegmentState newState) { state = newState; Color newColor; if (state == SegmentState.Allocated) { newColor = allocatedColor; } else if (state == SegmentState.Overhead) { newColor = overheadColor; } else { newColor = freeColor; } graphics.color = newColor; }
public int Serialize(ref byte[] targetBytes, int offset) { if (targetBytes == null) { throw new ArgumentNullException("targetBytes"); } if (state == SegmentState.Dirty) // dirty { var formatter = Formatter <T> .Default; byte[] newBytes = null; var length = formatter.Serialize(ref newBytes, 0, cached); serializedBytes = new ArraySegment <byte>(newBytes, 0, newBytes.Length); state = SegmentState.Cached; } BinaryUtil.EnsureCapacity(ref targetBytes, offset, serializedBytes.Count); Buffer.BlockCopy(serializedBytes.Array, serializedBytes.Offset, targetBytes, offset, serializedBytes.Count); return(serializedBytes.Count); }
/// <summary> /// Derive appearance of the line from the business data received from queue /// if we already received data for the segment. /// </summary> /// <param name="fromQ">our knowledge about the segment state</param> public SegmentViewModel(SegmentState fromQ) { var sb = new StringBuilder(); sb.Append("Seg "); sb.Append(fromQ.Number); if (fromQ.IsInMemory) sb.Append(", in memory"); if (fromQ.IsOnDisk) sb.Append(", on disk"); if (!fromQ.IsComplete) sb.Append(", INCOMPLETE!!!"); ToolTip = sb.ToString(); Color col; if (!fromQ.IsComplete) col = Colors.Magenta; else if (fromQ.IsInMemory) col = fromQ.IsOnDisk ? Colors.Black : Colors.Green; else col = fromQ.IsOnDisk ? Colors.RoyalBlue : Colors.Brown; Stroke = new SolidColorBrush(col); YTop = fromQ.EndOfFile ? YTopEof : YTopIntermediate; }
public override InstanceState SaveToState(bool integrate = true) { ushort segment = id.NetSegment; SegmentState state = new SegmentState { instance = this, Info = Info, position = GetControlPoint(), startNodeId = segmentBuffer[segment].m_startNode, endNodeId = segmentBuffer[segment].m_endNode, startDirection = segmentBuffer[segment].m_startDirection, endDirection = segmentBuffer[segment].m_endDirection, NS_Modifiers = MoveItTool.NS.GetSegmentModifiers(segment), LaneIDs = GetLaneIds(segment), isCustomContent = Info.Prefab.m_isCustomContent }; state.startPosition = nodeBuffer[state.startNodeId].m_position; state.endPosition = nodeBuffer[state.endNodeId].m_position; state.smoothStart = ((nodeBuffer[state.startNodeId].m_flags & NetNode.Flags.Middle) != NetNode.Flags.None); state.smoothEnd = ((nodeBuffer[state.endNodeId].m_flags & NetNode.Flags.Middle) != NetNode.Flags.None); state.invert = ((segmentBuffer[segment].m_flags & NetSegment.Flags.Invert) == NetSegment.Flags.Invert); state.treeInfo = treeInfo; state.SaveIntegrations(integrate); return(state); }
public bool Accept(string value) { if (string.IsNullOrEmpty(value)) { if (UriState == SegmentState.Inside || BufferState == SegmentState.Inside) { // We can't write an 'empty' part inside a segment return(false); } else { _hasEmptySegment = true; return(true); } } else if (_hasEmptySegment) { // We're trying to write text after an empty segment - this is not allowed. return(false); } _uri.Append(_buffer); _buffer.Clear(); if (UriState == SegmentState.Beginning && BufferState == SegmentState.Beginning) { if (_uri.Length != 0) { _uri.Append("/"); } } BufferState = SegmentState.Inside; UriState = SegmentState.Inside; _uri.Append(value); return(true); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public virtual void Build(ArcState pArcState, SegmentState pSegState, float pArcAngle, SegmentSettings pSettings) { vArcState = pArcState; vSegState = pSegState; vSettings = pSettings; //// vSlice = new UiSlice(gameObject); vSlice.Resize(pArcAngle); //// var labelObj = new GameObject("Label"); labelObj.transform.SetParent(gameObject.transform, false); labelObj.transform.localPosition = new Vector3(0, 0, 1); labelObj.transform.localScale = new Vector3(1, 1, (vArcState.IsLeft ? 1 : -1)); vLabel = labelObj.AddComponent <UiLabel>(); vLabel.IsLeft = vArcState.IsLeft; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ internal void Build(ArcState pArcState, ICustomSegment pCustom) { vArcState = pArcState; vSegmentObjList = new List <GameObject>(); gameObject.transform.localPosition = PushFromHand; SegmentState[] segStates = vArcState.GetSegments(); int segCount = segStates.Length; float degree = 170 + DegreeFull / 2f; float sizeSum = 0; for (int i = 0; i < segCount; i++) { sizeSum += segStates[i].NavItem.RelativeSize; } for (int i = 0; i < segCount; i++) { SegmentState segState = segStates[i]; float segPerc = segState.NavItem.RelativeSize / sizeSum; float segAngle = AngleFull * segPerc; float segDegHalf = segAngle * ToDegrees / 2f; var segObj = new GameObject("Segment" + vSegmentObjList.Count); segObj.transform.SetParent(gameObject.transform, false); vSegmentObjList.Add(segObj); UiSegment uiSeg = segObj.AddComponent <UiSegment>(); uiSeg.Build(vArcState, segState, segAngle, pCustom); degree -= segDegHalf; segObj.transform.localRotation = Quaternion.AngleAxis(degree, Vector3.up); degree -= segDegHalf; } }
internal void EndSegment() { BufferState = SegmentState.Beginning; UriState = SegmentState.Beginning; }
/// <summary> /// Sets the error. /// </summary> /// <param name="exception">The exception.</param> public override void SetError(Exception exception) { m_LastException = exception; m_LastExceptionTime = DateTime.Now; m_SegmentState = SegmentState.Error; }
public void Reset() { this.SegmentGameObject = null; this.State = SegmentState.Destroyed; }
/// <summary> /// /// </summary> /// <param name="c"></param> /// <returns>is finished?</returns> public bool AppendChar(char c) { if (waitValue) { if (state == SegmentState.ArgContent && waitValue && argcontentLeft > 0) { sbpack.Append(c); argcontentLeft--; } if (argcontentLeft == 0) { waitValue = false; if (incompleteCommand) { allargs.Add(sbpack.ToString()); return(true); } } } else { #region switch switch (c) { case '*': { if (argcontentLeft == 0) { sbpack.Clear(); //readingLine = true; //waitCr = false; state = SegmentState.ArgCount; } break; } case '\r': { waitLf = true; break; } case '\n': #region LF { waitLf = false; //waitCr = false; switch (state) { case SegmentState.Start: #if ENABLE1_0 //说明没有*头,属于1.0协议 allargs.AddRange(sbpack.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); sbpack.Clear(); state = SegmentState.End; return(true); #endif break; case SegmentState.ProtocolHeader: break; case SegmentState.ArgCount: argsCount = int.Parse(sbpack.ToString()); //throw to outer function state = SegmentState.LineHeader; currentline = 0; sbpack.Clear(); break; case SegmentState.LineHeader: break; case SegmentState.ArgLength: arglength = int.Parse(sbpack.ToString()); argcontentLeft = arglength; sbpack.Clear(); state = SegmentState.ArgContent; waitValue = true; break; case SegmentState.ArgContent: allargs.Add(sbpack.ToString()); sbpack.Clear(); currentline++; if (currentline == argsCount) { //read all! state = SegmentState.End; return(true); } else { state = SegmentState.LineHeader; } break; case SegmentState.End: break; default: break; } break; } #endregion case '$': #region $ { if (state == SegmentState.LineHeader) { sbpack.Clear(); state = SegmentState.ArgLength; //waitCr = true; } else if (state == SegmentState.Start) { //比如Info命令,默认只有一行,就是以$开头而不是*开头 sbpack.Clear(); state = SegmentState.ArgLength; incompleteCommand = true; } else { throw new Exception("-expect Line Header"); } break; } #endregion default: if (waitLf && c != '\n') { throw new Exception("-expect LF"); } else if (state == SegmentState.LineHeader && c != '$') { throw new Exception("-expect Line Header"); } else if (state == SegmentState.ArgContent) { sbpack.Append(c); argcontentLeft--; //if (argcontentLeft == 0) //{ // waitCr = true; //} } else { //count length etc. sbpack.Append(c); } break; } #endregion } return(false); }
private static void GetRegions(Bitmap bitmap, out List <Region> regions, out int width_x) { Logging.Info("Getting regions"); width_x = bitmap.Width * 10 / 4 / 210; int mid_x = bitmap.Width / 2; int[] y_counts = new int[bitmap.Height]; // Tally up the number of off-white pixels down the centre of the page // In fact, at the moment, just scan till one non-white is found - so count will be 0 or 1. for (int y = 0; y < bitmap.Height; ++y) { for (int x = mid_x - width_x / 2; x < mid_x + width_x / 2; ++x) { Color color = bitmap.GetPixel(x, y); if (IsBelowWhitenessThreshold(color)) { ++y_counts[y]; continue; } } } regions = new List <Region>(); regions.Add(new Region { y = 0, state = SegmentState.TOP }); // Now break them into segments SegmentState state = SegmentState.TOP; for (int y = 0; y < bitmap.Height; ++y) { if (0 == y_counts[y] && SegmentState.BLANKS != state) { state = SegmentState.BLANKS; regions.Add(new Region { y = y, state = state }); continue; } if (0 != y_counts[y] && SegmentState.PIXELS != state) { state = SegmentState.PIXELS; regions.Add(new Region { y = y, state = state }); continue; } } // Add the bottom region regions.Add(new Region { y = bitmap.Height, state = SegmentState.BOTTOM }); // Get rid of any blank segments that are too small if (true) { const int TOO_SMALL_BLANKS_ROW_GAP = 50; for (int i = 0; i < regions.Count - 1; ++i) { if (regions[i].state == SegmentState.BLANKS && (regions[i + 1].y - regions[i].y) < TOO_SMALL_BLANKS_ROW_GAP) { regions[i].state = SegmentState.PIXELS; } } for (int i = 0; i < regions.Count - 1; ++i) { while (i + 1 < regions.Count && regions[i].state == regions[i + 1].state) { regions.RemoveAt(i + 1); } } } // Now pad out the text ones to give them some space to work if (true) { for (int i = 2; i < regions.Count; ++i) { if (regions[i].state == SegmentState.PIXELS) { regions[i].y = ScanTillCompletelyBlankRow(bitmap, -1, regions[i].y); } if (regions[i].state == SegmentState.BLANKS) { regions[i].y = ScanTillCompletelyBlankRow(bitmap, +1, regions[i].y); } } } // If there are too many regions, treat the whole page as a single entity by deleting all detected regions if (regions.Count > 30) { regions.Clear(); regions.Add(new Region { y = 0, state = SegmentState.TOP }); regions.Add(new Region { y = 0, state = SegmentState.PIXELS }); regions.Add(new Region { y = bitmap.Height, state = SegmentState.BOTTOM }); } Logging.Info("Got {0} regions", regions.Count); }
public bool Accept(string value) { if (string.IsNullOrEmpty(value)) { if (UriState == SegmentState.Inside || BufferState == SegmentState.Inside) { // We can't write an 'empty' part inside a segment return false; } else { _hasEmptySegment = true; return true; } } else if (_hasEmptySegment) { // We're trying to write text after an empty segment - this is not allowed. return false; } _uri.Append(_buffer); _buffer.Clear(); if (UriState == SegmentState.Beginning && BufferState == SegmentState.Beginning) { if (_uri.Length != 0) { _uri.Append("/"); } } BufferState = SegmentState.Inside; UriState = SegmentState.Inside; _uri.Append(value); return true; }