/// <summary> /// Performs the command on the given block. /// </summary> /// <param name="context"></param> /// <param name="block">The block to perform the action on.</param> /// <param name="project">The project that contains the current state.</param> protected override void Do( BlockCommandContext context, Block block) { // Save the previous text so we can undo it. previousText = block.Text; // Figure out what the new text string would be. int textIndex = new CharacterPosition(TextIndex).GetCharacterIndex( block.Text); string newText = block.Text.Insert(textIndex, Text); // Set the new text into the block. This will fire various events to // trigger the immediate and background processing. block.SetText(newText); // After we insert text, we need to give the immediate editor plugins a // chance to made any alterations to the output. block.Project.Plugins.ProcessImmediateEdits( context, block, textIndex + Text.Length); // Set the new position in the buffer. if (UpdateTextPosition.HasFlag(DoTypes.Do)) { context.Position = new BlockPosition(BlockKey, textIndex + Text.Length); } }
public DeleteTextCommand( BlockPosition begin, CharacterPosition end) : base(begin) { End = end; }
public GhostCharacter(GameBoard Board, Point CurrentLocation, int Width, int Height, Color CharacterColor) : base(Board, CurrentLocation, Width, Height) { _ghostColor = CharacterColor; _currentCharacterPosition = CharacterPosition.LegsOut; _currentInvincibility = CharacterInvincibility.Invincible; _rnd = new Random(CharacterColor.R + CharacterColor.G + CharacterColor.B); _board = Board; }
public void EndNormalize() { // Arrange const string input = "one one one one"; CharacterPosition position = CharacterPosition.End; // Act int results = position.GetCharacterIndex(input); // Assert Assert.AreEqual(input.Length, results); }
public void BeginningNormalize() { // Arrange const string input = "one one one one"; var position = new CharacterPosition(0); // Act int results = position.GetCharacterIndex(input); // Assert Assert.AreEqual(0, results); }
public void NumericEndNormalize() { // Arrange const string input = "one one one one"; var position = new CharacterPosition(input.Length); // Act int results = position.GetCharacterIndex(input); // Assert Assert.AreEqual(input.Length, results); }
public InsertTextFromBlock( BlockPosition destinationPosition, BlockKey sourceBlockKey, CharacterPosition characterBegin, CharacterPosition characterEnd) : base(destinationPosition.BlockKey) { DestinationPosition = destinationPosition; SourceBlockKey = sourceBlockKey; CharacterBegin = characterBegin; CharacterEnd = characterEnd; }
public void LeftWordNormalizeInBegin() { // Arrange const string input = "one one one one"; CharacterPosition position = CharacterPosition.Word; CharacterPosition.DefaultWordTokenizer = new OffsetWordTokenizer(); // Act Assert.Throws <IndexOutOfRangeException>( () => position.GetCharacterIndex(input, 0, WordSearchDirection.Left)); }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } CmdUpdateAction(playerController.getCurrentAction()); CmdUpdatePosition(playerController.getCurrentPosition()); characterAction = playerController.getCurrentAction(); characterPosition = playerController.getCurrentPosition(); print(playerController.getCurrentAction()); }
public void LeftWordNormalizeInNearBegin() { // Arrange const string input = "one one one one"; CharacterPosition position = CharacterPosition.Word; CharacterPosition.DefaultWordTokenizer = new OffsetWordTokenizer(); // Act int results = position.GetCharacterIndex(input, 3, WordSearchDirection.Left); // Assert Assert.AreEqual(0, results); }
public void RightWordNormalizeInMiddle() { // Arrange const string input = "one one one one"; CharacterPosition position = CharacterPosition.Word; CharacterPosition.DefaultWordTokenizer = new OffsetWordTokenizer(); // Act int results = position.GetCharacterIndex( input, 10, WordSearchDirection.Right); // Assert Assert.AreEqual(15, results); }
void MovementPlay() { if (_replay.Count == 0) { Logger.Info($"Movement is 0"); Replay = false; return; } position = _replay[0].CharacterPosition; if (_replay.Count >= 2) { targetPosition = _replay[1].CharacterPosition; } update = 0f; transform.position = new Vector3(2f, 0f, 2.5f); _replay.RemoveAt(0); }
public void CharacterAtPostion_should_ReturnValidResults() { CharacterPosition.GetCharacter(0).ShouldEqual('0'); CharacterPosition.GetCharacter(11).ShouldEqual('0'); CharacterPosition.GetCharacter(1).ShouldEqual('1'); CharacterPosition.GetCharacter(24).ShouldEqual('1'); CharacterPosition.GetCharacter(33).ShouldEqual('1'); CharacterPosition.GetCharacter(23).ShouldEqual('6'); CharacterPosition.GetCharacter(9999).ShouldEqual('7'); }
void setImage(Texture image, CharacterPosition p) { switch (p) { case CharacterPosition.Left: Left.content.image = image; break; case CharacterPosition.Right: Right.content.image = image; break; default: break; } }
void Update() { update += Time.deltaTime * UPDATE_INTERVAL; if (update > 1.0f) { update = 1f; } interpPosition = new CharacterPosition { position_head = Vector3.Lerp(position.position_head, targetPosition.position_head, update), position_leftHand = Vector3.Lerp(position.position_leftHand, targetPosition.position_leftHand, update), position_rightHand = Vector3.Lerp(position.position_rightHand, targetPosition.position_rightHand, update), rotation_head = Quaternion.Lerp(position.rotation_head, targetPosition.rotation_head, update), rotation_leftHand = Quaternion.Lerp(position.rotation_leftHand, targetPosition.rotation_leftHand, update), rotation_rightHand = Quaternion.Lerp(position.rotation_rightHand, targetPosition.rotation_rightHand, update), }; }
private static bool TryGetLastSystemFromFile(string curFile, out CharacterPosition lastSystem) { var lines = File.ReadLines(curFile) .Reverse(); foreach (var curLine in lines) { CharacterPosition system; if (TryGetPositionFromLine(curLine, out system)) { lastSystem = system; return(true); } } lastSystem = null; return(false); }
public MyCharacterController(CharacterType _type) { if (_type == CharacterType.Priest) { character = Object.Instantiate(Resources.Load("Perfabs/Priest", typeof(GameObject)), Vector3.zero, Quaternion.identity, null) as GameObject; character.name = "priest"; type = _type; } else { character = Object.Instantiate(Resources.Load("Perfabs/Devil", typeof(GameObject)), Vector3.zero, Quaternion.identity, null) as GameObject; character.name = "devil"; type = _type; } clickGui = character.AddComponent(typeof(ClickGui)) as ClickGui; clickGui.setController(this); pos = CharacterPosition.From; }
public void ShowCharacter(CharacterName name, CharacterPosition position, CharacterMood mood) { var character = _characters.FirstOrDefault(x => x.Name == name); if (character == null) { var characterObject = Instantiate(_characterPrefab, gameObject.transform, false); character = characterObject.GetComponent <Character>(); _characters.Add(character); } else if (character.IsShowing) { Debug.LogWarning($"Failed to show character {name}. Character already showing"); return; } character.Init(name, position, mood, GetMoodSetForCharacter(name)); }
public static void RightWord(EditorViewController controller) { // Pull out some useful variables. IDisplayContext displayContext = controller.DisplayContext; LineBuffer buffer = displayContext.LineBuffer; LineBuffer lineBuffer = displayContext.LineBuffer; // Pull out the line and chracter positions from where we're starting. TextPosition position = displayContext.Caret.Position; LinePosition linePosition = position.LinePosition; int lineIndex = linePosition.GetLineIndex(buffer); string lineText = buffer.GetLineText(lineIndex); CharacterPosition wordPosition = CharacterPosition.Word; CharacterPosition characterPosition = position.CharacterPosition; int characterIndex = characterPosition.GetCharacterIndex(lineText); // If we are at the beginning of the line, we need to move to the // previous line. if (characterIndex == lineText.Length) { // If we are at the last line, we don't do anything. if (lineIndex == lineBuffer.LineCount - 1) { return; } // Move to the end of the previous line. linePosition = new LinePosition(lineIndex + 1); characterPosition = CharacterPosition.Begin; } else { // Move to the previous left word. int rightCharacterIndex = wordPosition.GetCharacterIndex( lineText, characterPosition, WordSearchDirection.Right); characterPosition = new CharacterPosition(rightCharacterIndex); } // Cause the text editor to redraw itself. var caretPosition = new TextPosition(linePosition, characterPosition); displayContext.ScrollToCaret(caretPosition); }
public override void Do(OperationContext state) { // Figure out the indexes in the source line we'll be using to // pull out a substring. string sourceLine = state.LineBuffer.GetLineText( SourceRange.LinePosition, LineContexts.Unformatted); int sourceBegin = SourceRange.BeginCharacterPosition.GetCharacterIndex( sourceLine, SourceRange.EndCharacterPosition, WordSearchDirection.Left); int sourceEnd = SourceRange.EndCharacterPosition.GetCharacterIndex( sourceLine, SourceRange.BeginCharacterPosition, WordSearchDirection.Right); // Grab the text from the source line. If the source begin is at the // end of the string, then our source will always be a blank line. // Otherwise, it will be a portion of that source line. sourceLength = sourceEnd - sourceBegin; string sourceText = sourceLine.Substring(sourceBegin, sourceLength); // Insert the text from the source line into the destination. string destinationLine = state.LineBuffer.GetLineText( DestinationPosition.LinePosition, LineContexts.Unformatted); var buffer = new StringBuilder(destinationLine); int characterIndex = DestinationPosition.CharacterPosition.GetCharacterIndex(destinationLine); buffer.Insert(characterIndex, sourceText); // Save the source text length so we can delete it. originalCharacterIndex = characterIndex; originalPosition = state.Position; // Set the line in the buffer. var characterPosition = new CharacterPosition(characterIndex); var bufferPosition = new TextPosition( DestinationPosition.LinePosition, characterPosition); destinationLine = buffer.ToString(); state.LineBuffer.SetText(DestinationPosition.LinePosition, destinationLine); state.Results = new LineBufferOperationResults(bufferPosition); }
public override sealed void Move() { try { // Increment frame _frame ++; if (_frame > 4) { _frame = 1; if (_currentCharacterPosition == CharacterPosition.LegsOut) _currentCharacterPosition = CharacterPosition.LegsIn; else _currentCharacterPosition = CharacterPosition.LegsOut; } // Tunnel if (_currentLocation.X == 448) _currentLocation.X = 0; else if (_currentLocation.X == 0) _currentLocation.X = 448; ArrayList pts = GetNextPossibleCoordinates(_direction, _currentLocation); int iSelected = _rnd.Next(1, pts.Count +1); Point SelectedPoint = (Point) pts[iSelected -1]; if (_currentLocation.Y < SelectedPoint.Y) _direction = CharacterDirection.Down; else if (_currentLocation.X < SelectedPoint.X) _direction = CharacterDirection.Right; else if (_currentLocation.X > SelectedPoint.X) _direction = CharacterDirection.Left; else if (_currentLocation.Y > SelectedPoint.Y) _direction = CharacterDirection.Up; MoveToEndPoint(_direction, GetDestinationCoordinate(_direction, _currentLocation)); } catch (Exception expMove) { System.Diagnostics.Debug.WriteLine(expMove.Message); } }
public async Task <ActionResult <Map> > AddToMap(int mapId, int characterId) { var map = await db.Maps.Where(p => p.Id == mapId).Include(p => p.CharacterPositions).ThenInclude(p => p.Character).SingleOrDefaultAsync(); if (map != null) { if (map.CharacterPositions.Any(p2 => p2.Character.Id == characterId)) { return(Ok(map)); } var cp = new CharacterPosition { Map = map, Character = await db.Characters.FindAsync(characterId) }; db.Entry(cp).State = EntityState.Added; await db.SaveChangesAsync(); return(await Refresh(mapId)); } return(NotFound()); }
public override void Do(OperationContext state) { // Grab the line from the line buffer. int lineIndex = TextRange.LinePosition.GetLineIndex(state.LineBuffer.LineCount); string lineText = state.LineBuffer.GetLineText( lineIndex, LineContexts.Unformatted); var buffer = new StringBuilder(lineText); // Normalize the character ranges. int firstCharacterIndex; int lastCharacterIndex; TextRange.GetFirstAndLastCharacterIndices( lineText, out firstCharacterIndex, out lastCharacterIndex); beginCharacterIndex = firstCharacterIndex; int length = lastCharacterIndex - firstCharacterIndex; // Remove the text from the string, but save it so we can restore it. originalText = lineText.Substring(firstCharacterIndex, length); buffer.Remove(firstCharacterIndex, length); // Set the line in the buffer. lineText = buffer.ToString(); state.LineBuffer.SetText(lineIndex, lineText); // If we are updating the position, we need to do it here. if (UpdateTextPosition.HasFlag(DoTypes.Do)) { var firstCharacterPosition = new CharacterPosition(firstCharacterIndex); var firstTextPosition = new TextPosition( TextRange.LinePosition, firstCharacterPosition); originalPosition = state.Position; state.Results = new LineBufferOperationResults(firstTextPosition); } }
public void CmdUpdatePosition(CharacterPosition position) { characterPosition = position; print(netId + " in " + position); }
public XF(Stream input) { using (var br = new BinaryReaderX(input, true)) { // Load archive _xpck = new XPCK.XPCK(input); // Get image _xi = new IMGC.IMGC(_xpck.Files[0].FileData); // Decompress fnt.bin XfCharSizeInfo[] tempCharSizeInfo; XfCharMap[] largeChars; XfCharMap[] smallChars; using (var fntR = new BinaryReaderX(_xpck.Files[1].FileData, true)) { Header = fntR.ReadType <XfHeader>(); fntR.BaseStream.Position = Header.table0Offset << 2; _t0Comp = (CompressionMethod)(fntR.ReadInt32() & 0x7); fntR.BaseStream.Position -= 4; var compBr = new BinaryReaderX(new MemoryStream(Compressor.Decompress(fntR.BaseStream))); tempCharSizeInfo = compBr.ReadMultiple <XfCharSizeInfo>(Header.table0EntryCount).ToArray(); fntR.BaseStream.Position = Header.table1Offset << 2; _t1Comp = (CompressionMethod)(fntR.ReadInt32() & 0x7); fntR.BaseStream.Position -= 4; compBr = new BinaryReaderX(new MemoryStream(Compressor.Decompress(fntR.BaseStream))); largeChars = compBr.ReadMultiple <XfCharMap>(Header.table1EntryCount).ToArray(); fntR.BaseStream.Position = Header.table2Offset << 2; _t2Comp = (CompressionMethod)(fntR.ReadInt32() & 0x7); fntR.BaseStream.Position -= 4; compBr = new BinaryReaderX(new MemoryStream(Compressor.Decompress(fntR.BaseStream))); smallChars = compBr.ReadMultiple <XfCharMap>(Header.table2EntryCount).ToArray(); } // Set Characters Characters = new List <FontCharacter2>(largeChars.Length); foreach (var charMap in largeChars) { var glyph = GetGlyphBitmap(charMap, tempCharSizeInfo[charMap.charInformation.charSizeInfoIndex]); var characterPosition = new CharacterPosition( tempCharSizeInfo[charMap.charInformation.charSizeInfoIndex].offsetY, tempCharSizeInfo[charMap.charInformation.charSizeInfoIndex].offsetX); var characterInfo = new CharacterInfo(charMap.charInformation.charWidth, characterPosition); Characters.Add(new FontCharacter2(charMap.codePoint, glyph, characterInfo)); } /*foreach (var charMap in smallChars) * Characters.Add(new XfCharacter * { * Character = charMap.code_point, * TextureID = (int)charMap.ColorChannel, * GlyphX = (int)charMap.ImageOffsetX, * GlyphY = (int)charMap.ImageOffsetY, * GlyphWidth = tempCharSizeInfo[(int)charMap.CharSizeInfoIndex].glyph_width, * GlyphHeight = tempCharSizeInfo[(int)charMap.CharSizeInfoIndex].glyph_height, * CharacterWidth = (int)charMap.CharWidth, * OffsetX = tempCharSizeInfo[(int)charMap.CharSizeInfoIndex].offset_x, * OffsetY = tempCharSizeInfo[(int)charMap.CharSizeInfoIndex].offset_y, * });*/ } }
public BlockPosition( Block block, CharacterPosition textIndex) : this(block.BlockKey, textIndex) { }
public void getOnBoat(GameObject boat, Vector3 _pos) { character.transform.parent = boat.transform; move.setDest(_pos); pos = CharacterPosition.Boat; }
public static bool ContainsLine( this TextRange textRange, LineBuffer lineBuffer, int lineIndex, out CharacterPosition beginCharacterPosition, out CharacterPosition endCharacterPosition) { // If this is a single line, short cut the processing. TextPosition firstTextPosition = textRange.FirstTextPosition; TextPosition lastTextPosition = textRange.LastTextPosition; int firstLineIndex = firstTextPosition.LinePosition.GetLineIndex(lineBuffer); if (textRange.IsSameLine) { if (firstLineIndex == lineIndex) { beginCharacterPosition = firstTextPosition.CharacterPosition; endCharacterPosition = lastTextPosition.CharacterPosition; return(true); } beginCharacterPosition = CharacterPosition.Begin; endCharacterPosition = CharacterPosition.End; return(false); } // Figure out the line range index and see if the given line is with // the range. int lastLineIndex = lastTextPosition.LinePosition.GetLineIndex(lineBuffer); if (lineIndex < firstLineIndex || lineIndex > lastLineIndex) { beginCharacterPosition = CharacterPosition.Begin; endCharacterPosition = CharacterPosition.Begin; return(false); } // If the line is the same, we just use the same line. if (firstLineIndex == lastLineIndex) { beginCharacterPosition = firstTextPosition.CharacterPosition; endCharacterPosition = lastTextPosition.CharacterPosition; return(true); } // We have at least one additional line. If we are on the first, // then it is everything to the right of the starting. if (firstLineIndex == lineIndex) { beginCharacterPosition = firstTextPosition.CharacterPosition; endCharacterPosition = CharacterPosition.End; return(true); } // If we are on the last line, then it is everything before the index. if (lastLineIndex == lineIndex) { beginCharacterPosition = CharacterPosition.Begin; endCharacterPosition = lastTextPosition.CharacterPosition; return(true); } // In all other cases, it is the entire line. beginCharacterPosition = CharacterPosition.Begin; endCharacterPosition = CharacterPosition.End; return(true); }
public DeleteTextCommand(SingleLineTextRange range) : base(new TextPosition(range.LinePosition, range.BeginCharacterPosition)) { // DREM ToTextPosition End = range.EndCharacterPosition; }
public PacmanCharacter(GameBoard Board, Point CurrentLocation, int Width, int Height) : base(Board, CurrentLocation, Width, Height) { _currentCharacterPosition = CharacterPosition.Closed; }
public override void Draw() { GUILayout.BeginArea(myRect, Title, Style); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Space(SpacePixel); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.Space(SpacePixel); //get all character var list = ObjectInfoHelper.GetCharacterNames(); //set character index if initialize request if (Initialize) { //find origin object var origin = AssetDatabase.LoadAssetAtPath(Path, typeof(GameObject)) as GameObject; if (origin != null) { //set index Index = list.IndexOf(list.Where(c => c == origin.name).FirstOrDefault()); } Initialize = false; } //choose character GUILayout.BeginHorizontal(); GUILayout.Label("Character", WhiteTxtStyle, GUILayout.Width(LabelWidth)); Index = EditorGUILayout.Popup(Index, list.ToArray()); GUILayout.EndHorizontal(); //find selected character string path = ValueManager.CharaPath + list[Index] + ".prefab"; var selected = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject; if (selected != null) { //set character path Path = path; //get all sprites name var spriteList = selected.GetComponentsInChildren <CharaSpriteSetting>().Select(s => s.name).ToArray(); //character sprite GUILayout.BeginHorizontal(); GUILayout.Label("Sprite", WhiteTxtStyle, GUILayout.Width(LabelWidth)); SpriteIndex = EditorGUILayout.Popup(SpriteIndex, spriteList); GUILayout.EndHorizontal(); //select character face if existe var faceList = selected.transform.GetChild(SpriteIndex).GetComponentInChildren <CharaFaceSetting>(). GetComponentsInChildren <Image>().Select(f => f.name).ToArray(); if (faceList.Length > 0) { //set face index to 0 if has face if (FaceIndex < 0) { FaceIndex = 0; } GUILayout.BeginHorizontal(); GUILayout.Label("Face", WhiteTxtStyle, GUILayout.Width(LabelWidth)); FaceIndex = EditorGUILayout.Popup(FaceIndex, faceList); GUILayout.EndHorizontal(); } else { //no face selected FaceIndex = -1; } } //character postion var charaPosList = Enum.GetValues(typeof(CharacterPosition)) .Cast <int>() .Select(x => Enum.GetName(typeof(CharacterPosition), x)) .ToArray(); GUILayout.BeginHorizontal(); GUILayout.Label("Position", WhiteTxtStyle, GUILayout.Width(LabelWidth)); CharaPos = (CharacterPosition)EditorGUILayout.Popup((int)CharaPos, charaPosList); GUILayout.EndHorizontal(); //custom position if (CharaPos == CharacterPosition.Custom) { if (myRect.height == DefaultRectHeight) { myRect.height = DefaultRectHeight + 20; } CustomPos = EditorGUILayout.Vector2Field("", CustomPos); } else { if (myRect.height != DefaultRectHeight) { myRect.height = DefaultRectHeight; } } //is wait for character appear GUILayout.BeginHorizontal(); GUILayout.Label("Is wait", WhiteTxtStyle, GUILayout.Width(LabelWidth)); IsWait = EditorGUILayout.Toggle(IsWait); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(SpacePixel); GUILayout.EndHorizontal(); GUILayout.EndArea(); InPoint.Draw(); OutPoint.Draw(); base.Draw(); }
public bool SelectCharacter(CharacterPosition position) { bool ok = false; try { Log("SelectCharacter", "ClickCharacter"); ClickCharacter(position); Log("SelectCharacter", "EnterGame"); EnterGame(); ok = true; } catch(Exception ex) { Log("SelectCharacter", ex.ToString()); CleanUp(); } Log("SelectCharacter", "Complete"); return ok; }
private void ClickCharacter(CharacterPosition position) { // POINT: left character Coordinate left = new Coordinate( new StretchedPoint() { X = 0.0970873786407767, Y = 0.650693568726356 }); // POINT: right character Coordinate right = new Coordinate( new StretchedPoint() { X = 0.239805825242718, Y = 0.650693568726356 }); switch(position) { case CharacterPosition.Left: { pEveWindow.LeftClick(left); pEveWindow.Wait(pStandardWaitTime); break; } case CharacterPosition.Right: { pEveWindow.LeftClick(right); pEveWindow.Wait(pStandardWaitTime); break; } } }
public override sealed void Move() { base.Move(); if (_currentCharacterState == CharacterState.Moving) _currentCharacterPosition = GetNextCharacterPosition(); }
public void getOnCoast(GameObject coast, Vector3 _pos, CharacterPosition cpos) { character.transform.parent = coast.transform; move.setDest(_pos); pos = cpos; }