private void RenderCarts() { var info = new CharInfo() { Attributes = Color.ForegroundGreen | Color.BackgroundDarkRed }; int x, y; #region Carts foreach (var cart in game.Level.Carts) { if (cart?.Current == null) continue; x = OffsetX + (cart.Current.X * 2); y = OffsetY + cart.Current.Y; info.Char.AsciiChar = cart.Char(); buffer.Write(x, y, 2, info); } #endregion }
public ExtensionChar(CharInfo top, CharInfo middle, CharInfo bottom, CharInfo repeat) { this.Top = top; this.Middle = middle; this.Repeat = repeat; this.Bottom = bottom; }
public override bool DispatchPacket(Packet packet, System.Net.IPEndPoint endPoint) { switch ((LobbyPacketID)packet.PacketID) { case LobbyPacketID.ReqConnectInfo: { ReliableUDP.Connection connection = GameNetwork.instance.Connect(endPoint); Debug.Log(endPoint.Address.ToString() + " : " + endPoint.Port); m_lobby.AddLobbyUser(connection); } break; case LobbyPacketID.ReqUserInfo: { ReqUserInfo info = new ReqUserInfo(); info.ReadPacket(packet); ReliableUDP.Connection connection = GameNetwork.instance.Connect(endPoint); LobbyUser user = m_lobby.AddLobbyUser(connection); user.UserName = info.UserName; user.InitializePlayer(); } break; case LobbyPacketID.CharInfo: { CharInfo info = new CharInfo(); info.ReadPacket(packet); LobbyUser user = m_lobby.GetUser(endPoint); user.Player.SetChar(info); } break; default: return false; } return true; }
public void Initialize(GraphicsDevice graphicsDevice) { CharOffsetTable.Initialize(); string[] splitted = Application.ExecutablePath.Split('\\'); string loc2 = ""; for (int i = 0; i < splitted.Length - 1; i++) { loc2 += splitted[i] + '\\'; } string loc = loc2 + @"\Graphics\-Fonts\"; int fontIndex = 0; foreach (DirectoryInfo dir in new DirectoryInfo(loc).GetDirectories()) { Font font = new Font("simple"); //dir.Name.Split('&')[1]); int cCount = 0; int mCount = dir.GetFiles().Length; for (int i = 0; i < mCount; i++) { string floc = dir.FullName + @"\" + i + ".png"; Texture2D texture = Texture2D.FromStream(graphicsDevice, File.OpenRead(floc)); if (texture != null) { char c = FONT_TABLE[cCount]; CharInfo Character = new CharInfo(fontIndex, c, texture); font.Characters.Add(Character); } cCount++; } Fonts.Add(font); fontIndex++; } //CreateFromExisting(graphicsDevice, loc + @"1\", 0, new List<Tuple<int, int>>(new Tuple<int, int>[] {new Tuple<int, int>(0x101821, 0x52525A), new Tuple<int, int>(0xA5A5A5, 0xA5A5AD)})); //CreateFromExisting(graphicsDevice, loc + @"1\", 0, new Color(0x10, 0x18, 0x21), new Color(0x52, 0x52, 0x5A), new Color(0xA5, 0xA5, 0xA5), new Color(0xA5, 0xA5, 0xAD)); }
public CharBox(TexEnvironment environment, CharInfo charInfo) : base(environment) { this.Character = charInfo; this.Width = charInfo.Metrics.Width; this.Height = charInfo.Metrics.Height; this.Depth = charInfo.Metrics.Depth; }
public void SetChar(CharInfo info) { if (m_lastInfoNumber >= info.InfoNumber) return; m_destPosition = info.Position; m_destRotation = info.Rotation; m_lastInfoNumber = info.InfoNumber; }
public Font(string face, int size, int lineHeight, Texture2D page, CharInfo[] chars) { this.Face = face; this.Size = size; this.LineHeight = lineHeight; this.Page = page; this.chars = chars; this.UnkownChar = chars['\u00A5']; }
private void RenderShips() { var info = new CharInfo(); #region Water info.Char.AsciiChar = 177; info.Attributes = Color.ForegroundDarkCyan | Color.BackgroundDarkBlue; int maxWidth = game.Level.Port.Size, height = 2, x, y = 6; for(int i = 0; i < maxWidth; i++) { x = OffsetX + (i * 2); for (int j = 0; j < height; j++) buffer.Write(x, y + j, 2, info); } #endregion #region Ships info.Char.AsciiChar = 176; info.Attributes = Color.ForegroundYellow | Color.BackgroundDarkYellow; int width = BaseShip.Width, start, end; y = 7; foreach(var ship in game.Level.Port.Ships) { start = ship.Index; end = ship.Index + width; for(int i = start; i < end; i++) { if (i < 0 || i >= maxWidth) continue; x = OffsetX + (i * 2); buffer.Write(x, y, 2, info); } } #endregion }
void SendNetwork() { m_sendFrameCount++; if (m_sendFrameCount > SEND_FRAME_RATE) { m_sendFrameCount = 0; CharInfo info = new CharInfo(); info.InfoNumber = ++m_sendInfoNumber; info.Position = transform.localPosition; info.Rotation = transform.localRotation; LobbyManager.instance.SendPacketToAllUser(info.Packet); } }
public static CharInfo Parse(LineDescription lineDesc) { CharInfo result = new CharInfo(); result.ID = lineDesc.Args["id"].Value; result.X = lineDesc.Args["x"].Value; result.Y = lineDesc.Args["y"].Value; result.Width = lineDesc.Args["width"].Value; result.Height = lineDesc.Args["height"].Value; result.XOffset = lineDesc.Args["xoffset"].Value; result.YOffset = lineDesc.Args["yoffset"].Value; result.XAdvance = lineDesc.Args["xadvance"].Value; return result; }
public static CharInfo[] ReadOutput(Point startPoint, Size sizeOf) { if (IsAttached == true && m_consoleOutputHandle != IntPtr.Zero) { CharInfo[] buffer = new CharInfo[sizeOf.Width * sizeOf.Height]; Coord bufferSize = new Coord((short)sizeOf.Width, (short)sizeOf.Height); Coord bufferCoord = new Coord((short)startPoint.X, (short)startPoint.Y); SmallRect readReg = new SmallRect((short)startPoint.X, (short)startPoint.Y, (short)(startPoint.X + sizeOf.Width), (short)(startPoint.Y + sizeOf.Height)); Win32.ReadConsoleOutput(m_consoleOutputHandle, buffer, bufferSize, bufferCoord, ref readReg); return buffer; } throw new Exception("Error: No console attached to that process"); }
public unsafe char* SeekToOtherType(char* begin, char* end, CharInfo c, CharInfo* fail, int* cLen) { char* p = begin; *cLen = 0; *fail = this.GetCharInfo(*p); while (p != end && c.IsKindOf(*fail)) { p++; (*cLen)++; c = *fail; *fail = this.GetCharInfo(*p); } return p; }
// Use this for initialization void Start() { skill.CreateAct(); skill.CreatePas(); TES = new Material[TESe.Length]; for (int k = 0; k < TESe.Length; k++) { TES[k] = TESe[k]; } randomite = new System.Random(500); RNGcoordx = randomite.Next(0,100)/100f; RNGcoordy = randomite.Next(0,100)/100f; loachunks = false; clstamp = Time.time - 5; Raw.buildlib(); ftex.CreateDatum(); socket.LibConstruct(); Recipe.Craft(); Environment.GenEnvironment(); maininfo = new CharInfo(null, "", null); playerbase = new List<Transform>(); characcess = new List<Stats>(); socket.LibConstruct(); //Texture2D prev = AssetPreview.GetAssetPreview((GameObject)Resources.Load("prefab/" + "sm01compressor")); //byte[] bytes = prev.EncodeToPNG(); //File.WriteAllBytes(ftex.dirsession+"/m01compressor.png", bytes); /* prev = AssetPreview.GetAssetPreview((GameObject)Resources.Load("prefab/" + "sm01treaddiv")); bytes = prev.EncodeToPNG(); File.WriteAllBytes(ftex.dirsession + "/m01treaddiv.png", bytes);*/ }
static extern bool WriteConsoleOutput( IntPtr hConsoleOutput, CharInfo[] lpBuffer, Coord dwBufferSize, Coord dwBufferCoord, ref SmallRect lpWriteRegion);
public GameServer(string _gsIP, int _gsPort, string _lip) { IPAddress localip = IPAddress.Parse(_lip); // Console.WriteLine(localip.ToString()); gsListen = new TcpListener(System.Net.IPAddress.Any, 7777); gsIP = _gsIP; gsPort = _gsPort; //initialize members clanlist = new Dictionary<uint, Clans>(); enemyclans = new Dictionary<uint, Clans>(); allplayerinfo = new Dictionary<uint, CharInfo>(); playerlist = new Dictionary<uint, CharInfo>(); attacklist = new Dictionary<uint, CharInfo>(); enemylist = new Dictionary<uint, CharInfo>(); deadlist = new Dictionary<uint, CharInfo>(); deletedenemies = new List<uint>(); enemynames = new List<string>(); distanceupdates = true; targetselection = new Thread(this.selectTarget); target = null; shotlist = new List<shots>(); { StreamReader sReader = new StreamReader(new FileStream("shotid.txt", FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8); while (true) { string line = sReader.ReadLine(); if (line == null) break; char[] sep = new char[4]; sep[0] = '='; sep[1] = '['; sep[2] = ']'; sep[3] = '\t'; string[] split = line.Split(sep, StringSplitOptions.RemoveEmptyEntries); //id = 2, name = 4 shots _s = new shots(); _s.id = Convert.ToUInt32(split[2]); _s.name = split[4]; shotlist.Add(_s); } } robeids = new List<uint>(); { StreamReader sReader = new StreamReader(new FileStream("robeid.txt", FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8); while (true) { string line = sReader.ReadLine(); if (line == null) break; char[] sep = new char[4]; sep[0] = '='; sep[1] = '['; sep[2] = ']'; sep[3] = '\t'; string[] split = line.Split(sep, StringSplitOptions.RemoveEmptyEntries); //id = 2, name = 4 uint id = Convert.ToUInt32(split[2]); robeids.Add(id); } } lightarmor = new List<uint>(); { StreamReader sReader = new StreamReader(new FileStream("lightamor.txt", FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8); while (true) { string line = sReader.ReadLine(); if (line == null) break; char[] sep = new char[4]; sep[0] = '='; sep[1] = '['; sep[2] = ']'; sep[3] = '\t'; string[] split = line.Split(sep, StringSplitOptions.RemoveEmptyEntries); //id = 2, name = 4 uint id = Convert.ToUInt32(split[2]); lightarmor.Add(id); } } skills = new Dictionary<uint, string>(); { StreamReader lReader = new StreamReader(new FileStream("uniquelist.txt", FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8); while (true) { string line = lReader.ReadLine(); if (line == null) break; char[] sep = new char[3]; char[] sep1 = new char[2]; sep[0] = ' '; sep[1] = '\t'; sep[2] = '='; sep1[0] = '['; sep1[1] = ']'; string[] splits = line.Split(sep, 6, StringSplitOptions.RemoveEmptyEntries); string[] split2 = splits[5].Split(sep1, 3, StringSplitOptions.RemoveEmptyEntries); skills.Add(Convert.ToUInt32(splits[2]), split2[1]); } System.Console.WriteLine("loaded skills"); } clist = new List<Client>(); leader = null; //start UI thread bwindow = new BotView(this); bwindow.Show(); }
protected abstract ResultCode ConvertCharInfoToCoreData(CharInfo charInfo, out CoreData coreData);
public bool ReadUnicodeData() { FileStream dataFile = null; StreamReader inputStream = null; string strCurLine; string[] strLineFields; CharInfo curCharInfo; try { dataFile = new FileStream(DATA_FILENAME, FileMode.Open, FileAccess.Read); inputStream = new StreamReader(dataFile, Encoding.ASCII); } catch (Exception exc) { Console.WriteLine("TestCase blocked", UNABLE_TO_OPEN_FILE + " '" + DATA_FILENAME + "'.", exc); if (inputStream != null) { inputStream.Close(); } if (dataFile != null) { dataFile.Close(); } return(false); } try { m_uCharsRead = 0; while ((strCurLine = inputStream.ReadLine()) != null) { strLineFields = strCurLine.Split(FIELD_SEP); curCharInfo = new CharInfo(); if (strLineFields[0].Length > 4) { continue; } else { curCharInfo.chChar = Convert.ToChar(Convert.ToInt32(strLineFields[0], 16)); } curCharInfo.eCategory = TranslateUnicodeCategory(strLineFields[2]); if (strLineFields[8].Length > 0) { curCharInfo.dNumericValue = ConvertToDouble(strLineFields[8]); } m_CharData.Add(curCharInfo.chChar, curCharInfo); m_uCharsRead++; } } catch (Exception exc) { Console.WriteLine("Testcase blocked", BAD_DATA_FILE + " '" + DATA_FILENAME + "', Line " + (m_uCharsRead + 1) + ".", exc); if (inputStream != null) { inputStream.Close(); } if (dataFile != null) { dataFile.Close(); } return(false); } inputStream.Close(); dataFile.Close(); return(true); }
/// <summary> /// Save a char as unread /// </summary> /// <param name="c"></param> public void Unread(CharInfo c) { _UnreadBuffer.Push(c); }
protected abstract ResultCode Convert(Ver3StoreData ver3StoreData, out CharInfo charInfo);
public override void Init() { base.Init(); buffer = ConsoleRenderer.ActiveBuffer; textBox = new TextBox(controlManager) { Width = 34, Height = 13, Text = "Hello there", Attributes = CharAttribute.ForegroundWhite | CharAttribute.BackgroundDarkRed, WordBreak = WordBreak.Hard, TextAlign = TextAlign.Left }; textBox.Text = lorem; textBox.MousePressed += TextBox_MousePressed; textBox.Visible = false; //textBox.MouseReleased += TextBox_MouseReleased; dataBox = new TextBox(controlManager) { Width = 20, Height = 2, Name = "hello", Text = textBox.Rectangle.Size.ToString(), Attributes = CharAttribute.ForegroundGreen }; dataBox.Width = dataBox.Text.Length; dataBox.Visible = false; vs = new VerticalScrollbar(controlManager) { Height = 5, Left = 20, Top = 4 }; hs = new HorizontalScrollbar(controlManager) { Width = 10, Left = 3, Top = Height - 1 }; new ScrollableTextBox(controlManager) { Width = 20, Height = 5 }; colorfulString = new ColorfulString { Value = new string(Enumerable.Repeat('A', Enum.GetValues(typeof(CharAttribute)).Length - 0).ToArray()), ColorThing = ColorSelectMode.Repeat, Attributes = (CharAttribute[])Enum.GetValues(typeof(CharAttribute)) }; strings = new string[] { "Haha", "Console", "Go", "Brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" }.NormalizeLengths() .PadAround(2); int ratioX = 2; int ratioY = 1; int scale = 2; int spacingX = ratioX * scale; int spacingY = ratioY * scale; int pieceWidth = 2; int pieceHeight = 1; int tileWidth = pieceWidth + spacingX * 2; int tileHeight = pieceHeight + spacingY * 2; square = new CharInfo[8 * tileHeight, 8 * tileWidth]; for (int y = 0; y < square.GetLength(0); y++) { for (int x = 0; x < square.GetLength(1); x++) { square[y, x].Attributes |= ((x / tileWidth + y / tileHeight) % 2 == 0 ? CharAttribute.BackgroundGrey | CharAttribute.ForegroundBlack : CharAttribute.BackgroundBlack | CharAttribute.ForegroundWhite); } } for (int y = 0; y < square.GetLength(0); y++) { for (int x = 0; x < square.GetLength(1); x++) { if (x % tileWidth == 0 && y % tileHeight == 0) { int px = x + spacingX; int py = y + spacingY; square[py, px].UnicodeChar = '♕'; square[py, px].Attributes |= CharAttribute.LeadingByte; var yellow = CharAttribute.BackgroundYellow | CharAttribute.ForegroundBlack; var marker = new CharInfo { UnicodeChar = ShadingCharacter.Light, Attributes = yellow }; } } } backface = new BufferArea(square.GetLength(1) + 4, square.GetLength(0) + 2); CharInfo backChar = new CharInfo { UnicodeChar = ShadingCharacter.Dark, Attributes = CharAttribute.BackgroundDarkGrey }; backface.Fill(backChar); //Draw(); ConsoleInput.KeyPressed += ConsoleInput_KeyPressed; ConsoleInput.KeyHeld += ConsoleInput_KeyPressed; ConsoleInput.MouseReleased += TextBox_MouseReleased; ConsoleInput.MouseDragged += ConsoleInput_MouseDragged; ConsoleInput.Resized += ConsoleInput_Resized; //ConsoleInput.Resized += delegate //{ // Draw(); //}; Draw(); }
public void Open(MeCabParam param) { this.dic = new MeCabDictionary[param.UserDic.Length + 1]; string prefix = param.DicDir; this.property.Open(prefix); this.unkDic.Open(Path.Combine(prefix, UnkDicFile)); if (this.unkDic.Type != DictionaryType.Unk) throw new MeCabInvalidFileException("not a unk dictionary", this.unkDic.FileName); MeCabDictionary sysDic = new MeCabDictionary(); sysDic.Open(Path.Combine(prefix, SysDicFile)); if (sysDic.Type != DictionaryType.Sys) throw new MeCabInvalidFileException("not a system dictionary", sysDic.FileName); this.dic[0] = sysDic; for (int i = 0; i < param.UserDic.Length; i++) { MeCabDictionary d = new MeCabDictionary(); d.Open(Path.Combine(prefix, param.UserDic[i])); if (d.Type != DictionaryType.Usr) throw new MeCabInvalidFileException("not a user dictionary", d.FileName); if (!sysDic.IsCompatible(d)) throw new MeCabInvalidFileException("incompatible dictionary", d.FileName); this.dic[i + 1] = d; } this.unkTokens = new Token[this.property.Size][]; for (int i = 0; i < this.unkTokens.Length; i++) { string key = this.property.Name(i); DoubleArray.ResultPair n = this.unkDic.ExactMatchSearch(key); if (n.Value == -1) throw new MeCabInvalidFileException("cannot find UNK category: " + key, this.unkDic.FileName); this.unkTokens[i] = this.unkDic.GetToken(n); } this.space = this.property.GetCharInfo(' '); this.bosFeature = param.BosFeature; this.unkFeature = param.UnkFeature; this.maxGroupingSize = param.MaxGroupingSize; if (this.maxGroupingSize <= 0) this.maxGroupingSize = DefaltMaxGroupingSize; }
public void AddChar(char c, CharInfo info) { charMap[c] = info; }
public abstract void OnPowerUpCaught(CharInfo characterInfo);
/// <summary> /// Parse in tag /// </summary> protected ParsedToken ParseInTag() { _CurrentRead = null; // Whitespaces CharInfo c; while ((c = ReadChar(false)) != CharInfo.EOF && Char.IsWhiteSpace(c.AsChar)) { ; } var cpos = c.Position; // EOF ? if (c == CharInfo.EOF) { _CurrentToken = null; _State = ParseState.Content; ResetTagBuffer(); throw new ParseError("Unexpected end of file. Tag not closed.", ReadPosition); } // End of auto closed tag ? else if (c == '/' && _State == ParseState.Tag) { CharInfo saveSlash = c; bool spaces = false; while ((c = ReadChar(false)) != CharInfo.EOF && Char.IsWhiteSpace(c.AsChar)) { spaces = true; } if (c != '>') { // Prepare a correct next tag SaveChar(new CharInfo('>', (c == CharInfo.EOF) ? saveSlash.Position : c.Position)); SaveChar(saveSlash); throw new ParseError("Invalid char after '/'. End of auto closed tag expected.", cpos); } if (spaces) { // Prepare a correct next tag SaveChar(c); SaveChar(saveSlash); // Raise the error throw new ParseError("Invalid auto closed tag, '/' need to be follow by '>'.", cpos); } // Returns autoclosed var result = ParsedTag.AutoClosedTag(((ParsedTag)_CurrentToken).TagName); result.Position = cpos; _CurrentToken = null; _CurrentRead = null; _State = ParseState.Content; ResetTagBuffer(); return(result); } // End of process instruction else if (c == '?' && _State == ParseState.ProcessInstruction) { c = ReadChar(false); if (c != '>') { throw new ParseError("Invalid char after '?'. End of process instruction expected.", cpos); } // Returns processinstruction var result = ParsedTag.CloseProcessInstruction(((ParsedTag)_CurrentToken).TagName); result.Position = cpos; _CurrentToken = null; _CurrentRead = null; _State = ParseState.Content; ResetTagBuffer(); return(result); } else if (c == '>') { // Check tag if (_State == ParseState.ProcessInstruction) { throw new ParseError("A process instruction need to be closed with '?>'.", cpos); } // Returns close var result = ParsedTag.CloseTag(((ParsedTag)_CurrentToken).TagName); result.Position = cpos; _CurrentToken = null; _CurrentRead = null; _State = ParseState.Content; ResetTagBuffer(); return(result); } // Get the attribute name if (!IsAttributeNameChar(c.AsChar)) { throw new ParseError("Unexpected character.", cpos); } AddToCurrentRead(c); while ((c = ReadChar(false)) != CharInfo.EOF && IsAttributeNameChar(c.AsChar)) { AddToCurrentRead(c); } if (c != CharInfo.EOF) { SaveChar(c); } String attrName = GetCurrentRead(true); ParsePosition attrPos = cpos; // Whitespaces while ((c = ReadChar(false)) != CharInfo.EOF && Char.IsWhiteSpace(c.AsChar)) { ; } // Attribute whithout value if (c != '=') { SaveChar(c); // Attribute whithout content return(new ParsedAttribute() { Position = attrPos, Name = attrName, Value = null, Quote = '\0' }); } // Whitespaces while ((c = ReadChar(false)) != CharInfo.EOF && Char.IsWhiteSpace(c.AsChar)) { ; } // Search the value if (c == 0 || c == '/' || c == '?' || c == '>') { _CurrentAttr = new ParsedAttribute() { Position = attrPos, Name = attrName, Value = null, Quote = '\0' }; if (c != CharInfo.EOF) { SaveChar(c); } throw new ParseError("Attribute value expected.", ReadPosition); } // Quoted value ? _CurrentRead = null; char quote = '\0'; if (c == '"' || c == '\'') { quote = c.AsChar; while ((c = ReadChar(false)) != CharInfo.EOF && c != quote) { AddToCurrentRead(c); } _CurrentAttr = new ParsedAttribute() { Position = attrPos, Name = attrName, Value = HEntity.HtmlDecode(GetCurrentRead(true), RemoveUnknownOrInvalidEntities), Quote = quote }; if (c == CharInfo.EOF) { throw new ParseError("Unexpected end of file. Attribute is not closed.", ReadPosition); } var result = _CurrentAttr; _CurrentAttr = null; return(result); } // Unquoted value AddToCurrentRead(c); while ((c = ReadChar(false)) != CharInfo.EOF && !Char.IsWhiteSpace(c.AsChar) && c != '"' && c != '\'' && c != '=' && c != '<' && c != '>' && c != '`') { AddToCurrentRead(c); } SaveChar(c); return(new ParsedAttribute() { Position = attrPos, Name = attrName, Value = HEntity.HtmlDecode(GetCurrentRead(true), RemoveUnknownOrInvalidEntities), Quote = quote }); }
/// <summary> /// Parse a start tag /// </summary> protected ParsedToken ParseStartTag() { _StartTagPosition = _CurrentPosition; _TagBuffer = SourceReader.OpenBuffer(); CharInfo c = ReadChar(); // Comments ? if (c == '!') { // Expect '--' or 'DOCTYPE' c = ReadChar(); if (Char.IsLetter(c.AsChar)) { SaveChar(c); return(ParseDoctype()); } else if (c == '-') { if (ReadChar() != '-') { throw new ParseError("Comments need to start with '<!--'.", ReadPosition); } return(ParseComment()); } throw new ParseError("Comment or DOCTYPE expected.", ReadPosition); } // Process instruction ? if (c == '?') { _State = ParseState.ProcessInstruction; c = ReadChar(false); // Pass whitespace while (c != CharInfo.EOF && Char.IsWhiteSpace(c.AsChar)) { c = ReadChar(false); } } else if (c == '/') { _State = ParseState.EndTag; c = ReadChar(false); if (c == CharInfo.EOF || !Char.IsLetterOrDigit(c.AsChar)) { SaveChar(c); throw new ParseError("Invalid tag name. Need to start with an alphanumeric", ReadPosition); } } else { _State = ParseState.Tag; } // Tagname if (c == CharInfo.EOF || !Char.IsLetterOrDigit(c.AsChar)) { throw new ParseError("Invalid tag name. Need to start with an alphanumeric", ReadPosition); } // Loop tag name _CurrentRead = null; AddToCurrentRead(c); while ((c = ReadChar(false)) != CharInfo.EOF && (Char.IsLetterOrDigit(c.AsChar) || c == '.' || c == ':' || c == '-')) { AddToCurrentRead(c); } // If EndTag if (_State == ParseState.EndTag) { _CurrentToken = ParsedTag.EndTag(GetCurrentRead(true)); _CurrentToken.Position = _StartTagPosition; // Pass whitespace while (c != CharInfo.EOF && Char.IsWhiteSpace(c.AsChar)) { c = ReadChar(false); } try { if (c == CharInfo.EOF) { throw new ParseError("Unexpected end of stream.", ReadPosition); } if (IsAttributeNameChar(c.AsChar)) { throw new ParseError("End tag can't contains attribute.", ReadPosition); } if (c != '>') { throw new ParseError("Unexpected char. End tag not closed.", ReadPosition); } } catch { // Reset steam while (c != CharInfo.EOF && c != '<' && c != '>') { c = ReadChar(false); } if (c == '<') { SaveChar(c); } throw; } _State = ParseState.Content; ResetTagBuffer(); var result = _CurrentToken; _CurrentToken = null; return(result); } // Create the tag if (c != CharInfo.EOF) { SaveChar(c); } _CurrentToken = _State == ParseState.Tag ? ParsedTag.OpenTag(GetCurrentRead(true)) : ParsedTag.OpenProcessInstruction(GetCurrentRead(true)); _CurrentToken.Position = _StartTagPosition; return(_CurrentToken); }
/// <summary> /// Save a char in the buffer /// </summary> protected void SaveChar(CharInfo c) { SourceReader.Unread(c); }
public void UpdateTarget(CharInfo cinfo) { if (target == null) return; if (cinfo.ID == target.ID) { target = cinfo; } }
private void doOneHeadword(string simp, string trad) { for (int i = 0; i != simp.Length; ++i) { char s = simp[i]; char t = trad[i]; // They are the same if (s == t) { int val = (int)s; CharInfo ci = infos[val]; // Not seen before if (ci == null) { ci = new CharInfo { Role = STRole.Both, AttCount = 1 }; infos[val] = ci; } // Seen before else { ci.Role = STRole.Both; ++ci.AttCount; } } // They are different else { int sVal = (int)s; int tVal = (int)t; CharInfo sci = infos[sVal]; // Simplified character not seen before if (sci == null) { sci = new CharInfo { Role = STRole.Simp, AttCount = 1 }; if (!sci.TradForms.Contains(t)) { sci.TradForms += t; } infos[sVal] = sci; } // Simplified character seen before else { if (sci.Role == STRole.Trad) { sci.Role = STRole.Both; } ++sci.AttCount; if (!sci.TradForms.Contains(t)) { sci.TradForms += t; } } CharInfo tci = infos[tVal]; // Traditional character not seen before if (tci == null) { tci = new CharInfo { Role = STRole.Trad, AttCount = 1 }; infos[tVal] = tci; } // Traditional character seen before else { if (tci.Role == STRole.Simp) { tci.Role = STRole.Both; } ++tci.AttCount; } } } }
public void defendfunction() { ByteBuffer actionmsg = new ByteBuffer(18); actionmsg.WriteByte(0x1f); int actionindex = actionmsg.GetIndex(); ByteBuffer cancelpacket = new ByteBuffer(3); cancelpacket.WriteByte(0x48); cancelpacket.WriteInt16(1); ByteBuffer useskillmsg = new ByteBuffer(10); useskillmsg.WriteByte(0x39); int skillindex = useskillmsg.GetIndex(); useskillmsg.WriteUInt32(0); useskillmsg.WriteUInt32(1); int shiftindex = useskillmsg.GetIndex(); useskillmsg.WriteByte(0x00); ByteBuffer validateposition = new ByteBuffer(21); validateposition.WriteByte(0x59); int valposindex = validateposition.GetIndex(); bool doskill;// = false; while (true) { Thread.Sleep(1000); if (defense == false || gs.battack == false) continue; int count = gs.enemylist.Values.Count; CharInfo[] attackers = new CharInfo[count + 10]; gs.enemylist.Values.CopyTo(attackers, 0); foreach (CharInfo mytarget in attackers) { Thread.Sleep(100); if (mytarget != null) { if (mytarget.peace == 1 || ((mytarget.AbnormalEffects & gs.medusastate) != 0) || mytarget.isAlikeDead == 1) { mytarget.peace = 0; continue; } actionmsg.SetIndex(actionindex); actionmsg.WriteUInt32(mytarget.ID); actionmsg.WriteInt32(pinfo.X); actionmsg.WriteInt32(pinfo.Y); actionmsg.WriteInt32(pinfo.Z); actionmsg.WriteByte(1); NewMessage(actionmsg); if (mytarget.peace == 1 || ((mytarget.AbnormalEffects & gs.medusastate) != 0) || mytarget.isAlikeDead == 1) { mytarget.peace = 0; continue; } lock (dslock) { foreach (DefenseSkills a in dskills) { doskill = false; switch (a.condition) { case 0: //always doskill = true; break; case 1: //HP switch (a.comparison) { case 0: //== if (mytarget.Cur_HP == a.value) doskill = true; break; case 1: //> if (mytarget.Cur_HP > a.value) doskill = true; break; case 2: //< if (mytarget.Cur_HP < a.value) doskill = true; break; } break; case 2: //distance double distance = System.Math.Sqrt(Math.Pow((pinfo.X - mytarget.X), 2) + Math.Pow((pinfo.Y - mytarget.Y), 2) + Math.Pow(pinfo.Z - mytarget.Z, 2)); switch (a.comparison) { case 0: //== if (distance == a.value) doskill = true; break; case 1: //> if (distance > a.value) doskill = true; break; case 2: //< if (distance < a.value) doskill = true; break; } break; } if (doskill == true && (mytarget.AbnormalEffects & a.effect) == 0 && pinfo.Cur_MP >= a.MP) { useShotFunc(); actionmsg.SetIndex(actionindex); actionmsg.WriteUInt32(mytarget.ID); actionmsg.WriteInt32(pinfo.X); actionmsg.WriteInt32(pinfo.Y); actionmsg.WriteInt32(pinfo.Z); actionmsg.WriteByte(1); useskillmsg.SetIndex(shiftindex); if (shiftattack) useskillmsg.WriteByte(1); else useskillmsg.WriteByte(0); useskillmsg.SetIndex(skillindex); useskillmsg.WriteUInt32(a.useskill.id); NewMessage(actionmsg); NewMessage(useskillmsg); validateposition.SetIndex(valposindex); validateposition.WriteInt32(pinfo.X); validateposition.WriteInt32(pinfo.Y); validateposition.WriteInt32(pinfo.Z); validateposition.WriteInt32(pinfo.Airship); validateposition.WriteInt32(0); NewMessage(validateposition); } Thread.Sleep(250); } } } } } }
public void Write(int x, int y, ConsoleColor backColor) { var info = this[x, y]; this[x, y] = new CharInfo(info.Char.UnicodeChar, info.CharColor, backColor); }
private CharInfo buildCharData(CharInfo glyph) { // pad to the left by 1 pixel if (glyph.x > 0) { glyph.width += 1; glyph.xoffset -= 1; glyph.x -= 1; } // width must be divisible by 3: if (glyph.width % 3 != 0) { glyph.width += 3 - glyph.width % 3; int imageW = imageHandler.CurrentBitmap.Width; while (glyph.x + glyph.width > imageW) { glyph.x--; glyph.xoffset -= 1; } } // height must be divisible by 3: if (glyph.height % 3 != 0) { glyph.yoffset -= 3 - glyph.height % 3; glyph.height += 3 - glyph.height % 3; } int srcBottom = glyph.yoffset + glyph.height; Rectangle cropArea = new Rectangle(glyph.x, glyph.y, glyph.width, glyph.height); Bitmap subbitmap = imageHandler.CurrentBitmap.Clone(cropArea, imageHandler.CurrentBitmap.PixelFormat); subbitmap = imageHandler.SubPixel(subbitmap, false, false, true); // glyphs are packed 3:3:2 glyph.data = new List <byte>(); for (int y = 0; y < subbitmap.Height; y++) { for (int x = 0; x < subbitmap.Width; x++) { int packed = 0; Color c = subbitmap.GetPixel(x, y); packed = (c.R & 0xE0) | ((c.G & 0xE0) >> 3) | ((c.B & 0xC0) >> 6); glyph.data.Add((byte)packed); } } glyph.width = subbitmap.Width; glyph.height = subbitmap.Height; // trim empty rows from glyph // top row bool foundEmpty = true; while (foundEmpty && glyph.data.Count != 0) { for (int i = 0; i < glyph.width; i++) { if (glyph.data[i] != 0) { foundEmpty = false; break; } } if (foundEmpty) { glyph.data.RemoveRange(0, glyph.width); glyph.height--; glyph.yoffset += 3; } } // bottom row foundEmpty = true; while (foundEmpty && glyph.data.Count != 0) { for (int i = 0; i < glyph.width; i++) { if (glyph.data[glyph.data.Count - i - 1] != 0) { foundEmpty = false; break; } } if (foundEmpty) { glyph.data.RemoveRange(glyph.data.Count - glyph.width, glyph.width); glyph.height--; } } // left side foundEmpty = true; while (foundEmpty && glyph.data.Count != 0) { for (int i = 0; i < glyph.height; i++) { if (glyph.data[glyph.width * i] != 0) { foundEmpty = false; break; } } if (foundEmpty) { for (int i = 0; i < glyph.height; i++) { glyph.data.RemoveAt(i * (glyph.width - 1)); } glyph.width--; glyph.xoffset += 3; } } // right side foundEmpty = true; while (foundEmpty && glyph.data.Count != 0) { for (int i = 1; i <= glyph.height; i++) { if (glyph.data[glyph.width * i - 1] != 0) { foundEmpty = false; break; } } if (foundEmpty) { for (int i = 0; i < glyph.height; i++) { glyph.data.RemoveAt(i * (glyph.width - 1) + glyph.width - 1); } glyph.width--; } } return(glyph); }
public CharDelay(CharInfo charInfo, int delayInMilliseconds) { this.CharInfo = charInfo; this.DelayInMilliseconds = delayInMilliseconds; }
public bool IsKindOf(CharInfo c) { return(BitUtils.CompareAnd(this.bits, c.bits, 0, 18)); }
protected override ResultCode GetIndex(CharInfo charInfo, out int index) { return(_database.GetIndex(_metadata, charInfo, out index)); }
protected abstract ResultCode ConvertCoreDataToCharInfo(CoreData coreData, out CharInfo charInfo);
protected override ResultCode Convert(Ver3StoreData ver3StoreData, out CharInfo charInfo) { throw new NotImplementedException(); }
public void AppendColor(CharAttribute color) { CharInfo[] newPalette = new CharInfo[palette.Length + shadeSequence.Length - 1]; Array.Copy(palette, newPalette, palette.Length); palette = newPalette; }
protected override ResultCode ConvertCoreDataToCharInfo(CoreData coreData, out CharInfo charInfo) { return(_database.ConvertCoreDataToCharInfo(coreData, out charInfo)); }
/// <summary> /// 互換カテゴリ判定 /// </summary> /// <param name="c"></param> /// <returns></returns> public bool IsKindOf(CharInfo c) { return BitUtils.CompareAnd(this.bits, c.bits, 0, 18); }
protected override ResultCode ConvertCharInfoToCoreData(CharInfo charInfo, out CoreData coreData) { return(_database.ConvertCharInfoToCoreData(charInfo, out coreData)); }
public static void ChangeSize(int width, int height) { _dimensions.width = width; _dimensions.height = height; Console.WindowWidth = width; Console.BufferWidth = width; Console.WindowHeight = height; Console.BufferHeight = height; buffer = new CharInfo[Console.BufferHeight][]; for (int i = 0; i < buffer.Length; i++) { buffer[i] = new CharInfo[Console.BufferWidth]; } singleBuf = new CharInfo[buffer.Length * buffer[0].Length]; rect = new SmallRect() { Left = 0, Top = 0, Right = (short)buffer[0].Length, Bottom = (short)buffer.Length }; dwBufferSize = new Coord() { X = (short)Dimensions.width, Y = (short)Dimensions.height }; dwBufferCoord = new Coord(0, 0); }
protected override ResultCode UpdateLatest(CharInfo oldCharInfo, SourceFlag flag, out CharInfo newCharInfo) { newCharInfo = default; return(_database.UpdateLatest(_metadata, oldCharInfo, flag, newCharInfo)); }
public void selectTarget() { while (true) { try { if (battack == false) { Thread.Sleep(500); continue; } CharInfo[] elist = null; target = null; do { try { elist = new CharInfo[enemylist.Count]; enemylist.Values.CopyTo(elist, 0); } catch { continue; } } while (false); //FIRST PASS - ROBE ARMORS foreach (CharInfo temp in elist) { if (temp == null) continue; if (flagfight == true) if (temp.rpvpflag == 0 && (temp.relation & 0x00002) != 0 && ((temp.relation & 0x080000) != 0)) continue; if (deadlist.ContainsKey(temp.ID)) { if (temp.isAlikeDead == 0) { deadlist.Remove(temp.ID); } else continue; } if (temp != null && temp.isAlikeDead == 1) { if (!deadlist.ContainsKey(temp.ID)) { deadlist.Add(temp.ID, temp); } continue; } if (!robeids.Contains(temp.Chest)) { //is not a robe user continue; } if (temp != null && temp.distance < AttackDistance && ((temp.AbnormalEffects & medusastate) == 0) && temp.isAlikeDead != 1 && temp.peace != 1) { if (target == null) { target = temp; } if (temp.distance < target.distance) { target = temp; } } } //2nd pass - light armors if (target == null) { foreach (CharInfo temp in elist) { if (temp == null) continue; if (flagfight == true && temp != null) if (temp.rpvpflag == 0 && (temp.relation & 0x00002) != 0 && ((temp.relation & 0x080000) != 0)) continue; if (deadlist.ContainsKey(temp.ID)) { if (temp.isAlikeDead == 0) { deadlist.Remove(temp.ID); } else continue; } if (temp != null && temp.isAlikeDead == 1) { if (!deadlist.ContainsKey(temp.ID)) { deadlist.Add(temp.ID, temp); } continue; } if (temp != null && !lightarmor.Contains(temp.Chest)) { //is not a robe user continue; } if (temp != null && temp.distance < AttackDistance && ((temp.AbnormalEffects & medusastate) == 0) && temp.isAlikeDead != 1 && temp.peace != 1) { if (target == null) { target = temp; } if (temp.distance < target.distance) { target = temp; } } } } //3rd pass closest if (target == null) { foreach (CharInfo temp in elist) { if (temp == null) continue; if (flagfight == true && temp != null) if ((temp.rpvpflag == 0 && (temp.relation & 0x00002) != 0 && ((temp.relation & 0x080000) != 0)) || temp.relation == 0) continue; if (deadlist.ContainsKey(temp.ID)) { if (temp.isAlikeDead == 0) { deadlist.Remove(temp.ID); } else continue; } if (temp != null && temp.isAlikeDead == 1) { if (!deadlist.ContainsKey(temp.ID)) { deadlist.Add(temp.ID, temp); } continue; } if (temp != null && temp.distance < AttackDistance && ((temp.AbnormalEffects & medusastate) == 0) && temp.isAlikeDead != 1 && temp.peace != 1) { if (target == null) { target = temp; } if (temp.distance < target.distance) { target = temp; } } } } if (target != null) { if (!attacklist.ContainsKey(target.ID)) { attacklist.Add(target.ID, target); enemylist.Remove(target.ID); } else enemylist.Remove(target.ID); } if (target == null) { foreach (CharInfo temp in elist) { if (temp != null && temp.peace == 1) { temp.peace = 0; continue; } } } if (target == null || enemylist.Count < 1) { Array.Clear(elist, 0, elist.Length); elist = new CharInfo[attacklist.Values.Count]; attacklist.Values.CopyTo(elist, 0); foreach (CharInfo i in elist) { if (i != null) { if (i.peace == 1) i.peace = 0; enemylist.Add(i.ID, i); attacklist.Remove(i.ID); } } } //if (target != null) //{ // if (robeids.Contains(target.Chest)) // Console.WriteLine("{0} is a robe user", target.Name); // else if (lightarmor.Contains(target.Chest)) // Console.WriteLine("{0} is a light user", target.Name); // else // Console.WriteLine("{0} is a heavy or no armor user", target.Name); //} Thread.Sleep(1000); } catch { } } }
void addPartyMember(CharInfo c) { }
private void doBuff(ByteBuffer useskillmsg, int skillindex, PlayerBuffs p) { if (p.objid == 0 && p.self != true) { //we haven't found the player yet //search in allplayerinfo CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count]; gs.allplayerinfo.Values.CopyTo(cinfos, 0); foreach (CharInfo cinfo in cinfos) { if (p.player == cinfo.Name) { p.objid = cinfo.ID; } } } if (p.objid != 0) { //target the guy //execute the list of skills on him ByteBuffer action = new ByteBuffer(); action.WriteByte(0x1f); action.WriteUInt32(p.objid); action.WriteInt32(pinfo.X); action.WriteInt32(pinfo.Y); action.WriteInt32(pinfo.Z); action.WriteByte(0); NewMessage(action); p.lastuse = DateTime.Now; foreach (skill s in p.bufflist.Values) { if (s.lastuse.AddMilliseconds(s.reuseDelay) > DateTime.Now) { ReSkill r = new ReSkill(s, p.objid); lock (redolistlock) { redolist.Enqueue(r); } continue; } useskillmsg.SetIndex(skillindex); useskillmsg.WriteUInt32(s.id); NewMessage(useskillmsg); s.mre.WaitOne(10000); s.mre.Reset(); if (s.skillstate()) { System.Threading.Thread.Sleep((int)s.hitTime); } else { ReSkill r = new ReSkill(s, p.objid); lock (redolistlock) { redolist.Enqueue(r); } } //wait for response //s.lastuse = DateTime.Now; } } else if (p.self) { p.lastuse = DateTime.Now; foreach (skill s in p.bufflist.Values) { if (s.lastuse.AddMilliseconds(s.reuseDelay) > DateTime.Now) { ReSkill r = new ReSkill(s, p.objid); lock (redolistlock) { redolist.Enqueue(r); } continue; } useskillmsg.SetIndex(skillindex); useskillmsg.WriteUInt32(s.id); NewMessage(useskillmsg); s.mre.WaitOne(10000); s.mre.Reset(); if (s.skillstate()) { System.Threading.Thread.Sleep((int)s.hitTime); } else { ReSkill r = new ReSkill(s, p.objid); lock (redolistlock) { redolist.Enqueue(r); } } //wait for response //s.lastuse = DateTime.Now; } } }
private void button1_Click(object sender, EventArgs e) { PlayerBuffs buff = null; char[] sep = new char[1]; sep[0] = ';'; string[] names = value.Text.Split(sep); foreach (string name in names) { buff = new PlayerBuffs(); buff.bufflist = new Dictionary<uint, skill>(); buff.mre = new System.Threading.ManualResetEvent(false); buff.buffid = buffid; buffid++; buff.objid = 0; buff.player = name; CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count]; gs.allplayerinfo.Values.CopyTo(cinfos, 0); if (buff.player == c.pinfo.Name || buff.player == "Self" || buff.player == "self") { //self buffs buff.objid = c.pinfo.ObjID; } else if (buff.player == "") { buff.self = true; } else if (buff.player == gs.leader.pinfo.Name) { buff.objid = gs.leader.pinfo.ObjID; } else { foreach (CharInfo cinfo in cinfos) { if (buff.player == cinfo.Name) { buff.objid = cinfo.ID; break; } } } ListBox.ObjectCollection all = sklist.Items; string snames = ""; foreach (object o in all) { try { skill s = (skill)o; buff.bufflist.Add(s.id, s); if (snames == "") snames = s.name; else snames = snames + ";" + s.name; } catch (Exception ex) { Console.WriteLine("Exception in add {0}", ex.ToString()); } } c.fightbufflist.Add(buff); //update view box ListViewItem lvit = new ListViewItem(buff.player); lvit.SubItems.Add(snames); lvit.SubItems.Add("--"); lvit.Tag = buff; listView1.Items.Add(lvit); } //int sindex = allskills.SelectedIndex; //if (sindex != -1) //{ // string skillname = allskills.Items[allskills.SelectedIndex].ToString(); // skill s = (skill)(allskills.Items[allskills.SelectedIndex]); // buff.bufflist.Add(s.id, s); // //uint skillid = ((skill)sl.Items[sl.SelectedIndex]).id; // //buff.skillid.Add(skillid, skillname); // try // { // if (buff.objid == 0) // { // CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count]; // gs.allplayerinfo.Values.CopyTo(cinfos, 0); // foreach (CharInfo cinfo in cinfos) // { // if (buff.player == cinfo.Name) // { // buff.objid = cinfo.ID; // } // } // c.bufflist.Add(buff); // } // } // catch // { // } //} }
byte ParseCategory(Utf8String str) { return((byte)CharInfo.ParseCategory(str)); }
public static void Net_CharLevelUp(NewUIGroup relatedGroup, CharInfo charInfo, Action actionOnSuccess = null, Action actionOnFail = null) { relatedGroup.SetIsBusyInLogicForAMoment(); NetRequestPage netReqPage = NewUIGroup.CreateGroup(NewUIGroup.NAME__NETREQUESTPAGE, relatedGroup) as NetRequestPage; netReqPage.Init("upgrading"); DivineDebug.Log("Net: CharLevelUp request sent. Char: '" + charInfo.moniker.ToString() + "'."); NewNetworkManager.instance.CharLevelUp(charInfo, (data) => { DivineDebug.Log("Old MaxHP: " + charInfo.baseStats.maxHp); DivineDebug.Log("Next MaxHP: " + charInfo.nextUpgradeStats.health); DivineDebug.Log("Net: CharLevelUp was successful. Char: '" + charInfo.moniker.ToString() + "'."); netReqPage.SetSuccessHappened("done"); GameManager.instance.player.coin -= charInfo.nextUpgradeStats.card_cost; charInfo.curCardCount -= charInfo.nextUpgradeStats.card_count; GameAnalyticsSDK.GameAnalytics.NewDesignEvent("Level up character : " + charInfo.moniker.ToString()); charInfo.level++; charInfo.SetBaseStats(data.max_health, data.max_health, data.attack, data.max_shield, data.max_shield); charInfo.SetOtherStats(data.critical_ratio, data.critical_chance, data.dodge_chance); charInfo.nextUpgradeStats = CharInfoHelper.GetNextUpgradeStats(data.nextStats); if (data.chakraData != null) { HeroInfo heroInfo = (HeroInfo)charInfo; heroInfo.chakra.level++; heroInfo.chakra.SetBaseStats(data.chakraData.chakra_max_health, data.chakraData.chakra_max_health, data.chakraData.chakra_attack, data.chakraData.chakra_max_shield, data.chakraData.chakra_max_shield); heroInfo.chakra.SetOtherStats(data.chakraData.chakra_critical_ratio, data.chakraData.chakra_critical_chance, data.chakraData.chakra_dodge_chance); heroInfo.chakra.nextUpgradeStats = CharInfoHelper.GetNextUpgradeStats(data.chakraData.next_upgrade_stats); } if (actionOnSuccess != null) { actionOnSuccess(); } DivineDebug.Log("MaxHP: " + charInfo.baseStats.maxHp); DivineDebug.Log("MaxHP: " + charInfo.nextUpgradeStats.health); }, (errorMsg) => { DivineDebug.Log("Net: CharLevelUp failed. Char: '" + charInfo.moniker.ToString() + "'."); netReqPage.SetFailHappened("connectionError"); if (actionOnFail != null) { actionOnFail(); } }); }
private unsafe void AddUnknown(ref MeCabNode resultNode, CharInfo cInfo, char* begin, char* begin2, char* begin3) { Token[] token = this.unkTokens[cInfo.DefaultType]; for (int i = 0; i < token.Length; i++) { MeCabNode newNode = this.GetNewNode(); this.ReadNodeInfo(this.unkDic, token[i], newNode); newNode.CharType = cInfo.DefaultType; newNode.Surface = new string(begin2, 0, (int)(begin3 - begin2)); newNode.Length = (int)(begin3 - begin2); newNode.RLength = (int)(begin3 - begin); newNode.BNext = resultNode; newNode.Stat = MeCabNodeStat.Unk; if (this.unkFeature != null) newNode.Feature = this.unkFeature; resultNode = newNode; } }
public static extern bool WriteConsoleOutput( SafeConsoleHandle hConsoleOutput, CharInfo[] lpBuffer, Coord dwBufferSize, Coord dwBufferCoord, [In, Out] SmallRect lpWriteRegion);
private TextPosition GetAdjustedPosition(CharInfo charInfo, CaretMoveDirection moveDirection) { switch (moveDirection) { case CaretMoveDirection.LEFT: return charInfo.PrevCharPosition; case CaretMoveDirection.RIGHT: return charInfo.NextCharPosition; case CaretMoveDirection.BOTTOM: case CaretMoveDirection.TOP: return charInfo.PrevCharPosition; } throw new ArgumentException(nameof(moveDirection)); }
public void SaveChara(CharInfo chara, string path) { chara.chaFile.charaFileName = Path.GetFileNameWithoutExtension(path); CreatePng(ref chara.chaFile.charaFilePNG); if (chara.Sex == 0) { using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write)) { chara.chaFile.Save(fileStream); } } else { int length = Enum.GetValues(typeof(CharDefine.CoordinateType)).Length; int[] array = new int[length]; int[] array2 = new int[length]; int[] array3 = new int[length]; var charFileInfoCoordinateFemale = chara.chaFile.coordinateInfo as CharFileInfoCoordinateFemale; for (int i = 0; i < length; i++) { var charFileInfoClothesFemale = charFileInfoCoordinateFemale.GetInfo((CharDefine.CoordinateType)i) as CharFileInfoClothesFemale; int key = charFileInfoClothesFemale.clothesId[0]; array[i] = charFileInfoClothesFemale.clothesId[1]; array2[i] = charFileInfoClothesFemale.clothesId[2]; array3[i] = charFileInfoClothesFemale.clothesId[3]; var femaleFbxList = chara.ListInfo.GetFemaleFbxList(CharaListInfo.TypeFemaleFbx.cf_f_top, true); if (femaleFbxList.TryGetValue(key, out ListTypeFbx listTypeFbx)) { if (byte.Parse(listTypeFbx.Etc[1]) == 2) { charFileInfoClothesFemale.clothesId[1] = 0; } if (byte.Parse(listTypeFbx.Etc[2]) != 0) { charFileInfoClothesFemale.clothesId[2] = 0; } } femaleFbxList = chara.ListInfo.GetFemaleFbxList(CharaListInfo.TypeFemaleFbx.cf_f_bot, true); listTypeFbx = null; if (femaleFbxList.TryGetValue(array[i], out listTypeFbx)) { if (byte.Parse(listTypeFbx.Etc[3]) != 0) { charFileInfoClothesFemale.clothesId[3] = 0; } } } using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write)) { chara.chaFile.Save(fileStream); } for (int j = 0; j < length; j++) { var charFileInfoClothesFemale2 = charFileInfoCoordinateFemale.GetInfo((CharDefine.CoordinateType)j) as CharFileInfoClothesFemale; charFileInfoClothesFemale2.clothesId[2] = array2[j]; charFileInfoClothesFemale2.clothesId[3] = array3[j]; charFileInfoClothesFemale2.clothesId[1] = array[j]; } } }
public void loadConfig(string fname) { StreamReader readfile; try { readfile = new StreamReader(new FileStream(fname, FileMode.Open), Encoding.UTF8); if (readfile == null) return; } catch { MessageBox.Show("couldn't open file {0} for reading", fname); return; } string line; int count; line = readfile.ReadLine(); try { count = Convert.ToInt32(line); } catch { count = 0; } listView1.Items.Clear(); c.fightbufflist.Clear(); buffid = 0; char[] sep = new char[2]; sep[0] = ','; sep[1] = ' '; for (int i = 0; i < count; i++) { try { line = readfile.ReadLine(); string snames = ""; string[] firstsplit = line.Split(':'); PlayerBuffs b = new PlayerBuffs(); b.player = firstsplit[0]; b.buffid = buffid; buffid++; b.mre = new System.Threading.ManualResetEvent(false); b.objid = 0; b.bufflist = new Dictionary<uint, skill>(); CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count]; gs.allplayerinfo.Values.CopyTo(cinfos, 0); if (b.player == c.pinfo.Name || b.player == "Self" || b.player == "self") { //self buffs b.objid = c.pinfo.ObjID; } else if (b.player == "") { b.self = true; } else if (b.player == gs.leader.pinfo.Name) { b.objid = gs.leader.pinfo.ObjID; } else { foreach (CharInfo cinfo in cinfos) { if (b.player == cinfo.Name) { b.objid = cinfo.ID; break; } } } string[] secondsplit = firstsplit[1].Split(sep, StringSplitOptions.RemoveEmptyEntries); foreach (string s in secondsplit) { try { uint skillid = Convert.ToUInt32(s); string skillname = gs.skills[skillid].name; foreach (skill loadskill in allskills.Items) { if (loadskill.id == skillid) { //found a match b.bufflist.Add(skillid, loadskill); if (snames == "") snames = loadskill.name; else snames = snames + ";" + loadskill.name; break; } } } catch { } } c.fightbufflist.Add(b); //update view box ListViewItem lvit = new ListViewItem(b.player); lvit.SubItems.Add(snames); lvit.SubItems.Add("--"); lvit.Tag = b; listView1.Items.Add(lvit); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } readfile.Close(); }
protected abstract ResultCode BuildRandom(Age age, Gender gender, Race race, out CharInfo charInfo);
protected abstract ResultCode BuildDefault(uint index, out CharInfo charInfo);
protected abstract ResultCode GetIndex(CharInfo charInfo, out int index);
public bool ReadUnicodeData() { FileStream dataFile = null; StreamReader inputStream = null; string strCurLine; string[] strLineFields; CharInfo curCharInfo; try { dataFile = new FileStream(DATA_FILENAME,FileMode.Open,FileAccess.Read); inputStream = new StreamReader(dataFile,Encoding.ASCII); } catch(Exception exc) { Console.WriteLine("TestCase blocked", UNABLE_TO_OPEN_FILE + " '" + DATA_FILENAME + "'.",exc); if (inputStream != null) inputStream.Close(); if (dataFile != null) dataFile.Close(); return false; } try { m_uCharsRead = 0; while ( (strCurLine = inputStream.ReadLine()) != null ) { strLineFields = strCurLine.Split(FIELD_SEP); curCharInfo = new CharInfo(); if (strLineFields[0].Length > 4) continue; else curCharInfo.chChar = Convert.ToChar(Convert.ToInt32(strLineFields[0],16)); curCharInfo.eCategory = TranslateUnicodeCategory(strLineFields[2]); if (strLineFields[8].Length > 0) { curCharInfo.dNumericValue = ConvertToDouble(strLineFields[8]); } m_CharData.Add(curCharInfo.chChar,curCharInfo); m_uCharsRead++; } } catch(Exception exc) { Console.WriteLine("Testcase blocked", BAD_DATA_FILE + " '" + DATA_FILENAME + "', Line " + (m_uCharsRead + 1) + ".", exc); if (inputStream != null) inputStream.Close(); if (dataFile != null) dataFile.Close(); return false; } inputStream.Close(); dataFile.Close(); return true; }
private void menuItemFont_Click(object sender, EventArgs e) { if (DialogResult.OK == fontDlg.ShowDialog()) { string fontFile = fontDlg.FileName; Trace.WriteLine("Opened " + fontFile); string line; string dir = System.IO.Path.GetDirectoryName(fontFile); string fileBase = System.IO.Path.GetFileNameWithoutExtension(fontFile); char[] delims = { ' ', '\t', '=' }; // main font characteristics int lineHeight = 0; int lineBase = 0; int spaceWidth = 0; bool[] usedChars = new bool[256]; for (int i = 0; i < 256; i++) { usedChars[i] = false; } List <CharInfo> chars = new List <CharInfo>(); System.IO.StreamReader file = new System.IO.StreamReader(fontFile); while ((line = file.ReadLine()) != null) { Trace.WriteLine("Processing " + line); if (line.StartsWith("info") || line.StartsWith("chars")) { // just information, we ignore it } else if (line.StartsWith("common")) { // common info for the font string[] args = line.Substring(7).Split(delims); for (int i = 0; i < args.Length; i++) { if (args[i] == "lineHeight") { lineHeight = Convert.ToInt32(args[i + 1]); } else if (args[i] == "base") { lineBase = Convert.ToInt32(args[i + 1]); } else if (args[i] == "pages") { int numPages = Convert.ToInt32(args[i + 1]); if (numPages != 1) { MessageBox.Show("Invalid number of pages (" + args[i + 1] + "). Only 1 page supported."); return; } } } } else if (line.StartsWith("page")) { // page info for the font (only supporting one page at the moment) string[] args = line.Substring(5).Split(delims); for (int i = 0; i < args.Length; i++) { if (args[i] == "file") { string pageFile = args[i + 1].Trim('\"'); string imagePath = dir + "\\" + pageFile; // load page as current bitmap imageHandler.CurrentBitmap = (Bitmap)Bitmap.FromFile(imagePath); imageHandler.BitmapPath = imagePath; this.AutoScroll = true; this.AutoScrollMinSize = new Size(Convert.ToInt32(imageHandler.CurrentBitmap.Width * zoomFactor), Convert.ToInt32(imageHandler.CurrentBitmap.Height * zoomFactor)); this.Invalidate(); } } } else if (line.StartsWith("char")) { // character info, the real meat of it CharInfo info = new CharInfo(); string[] args = line.Substring(5).Split(delims); for (int i = 0; i < args.Length; i++) { if (args[i] == "id") { info.id = Convert.ToInt32(args[i + 1]); } else if (args[i] == "x") { info.x = Convert.ToInt32(args[i + 1]); } else if (args[i] == "y") { info.y = Convert.ToInt32(args[i + 1]); } else if (args[i] == "width") { info.width = Convert.ToInt32(args[i + 1]); } else if (args[i] == "height") { info.height = Convert.ToInt32(args[i + 1]); } else if (args[i] == "xoffset") { info.xoffset = Convert.ToInt32(args[i + 1]); } else if (args[i] == "yoffset") { info.yoffset = Convert.ToInt32(args[i + 1]); } else if (args[i] == "xadvance") { info.xadvance = Convert.ToInt32(args[i + 1]); } } // special case for space if (info.id == 32) { spaceWidth = info.xadvance; continue; } // ignore chars outside of 0-255 if (info.id >= 0 && info.id <= 255 && !usedChars[info.id]) { // enable bit usedChars[info.id] = true; chars.Add(buildCharData(info)); } } } file.Close(); if (chars.Count > 0) { // check to see if the font is monospaced (all characters will have same xadvance) int checkAdvance = chars[0].xadvance; bool isMonospaced = true; for (int i = 1; i < chars.Count; i++) { if (chars[i].xadvance != checkAdvance) { isMonospaced = false; } } // if the font is monospaced, all xadvance values should be on the pixel barrier if (isMonospaced && checkAdvance % 3 != 0) { int toSub = checkAdvance % 3; for (int i = 0; i < chars.Count; i++) { CharInfo c = chars[i]; c.xadvance -= toSub; chars[i] = c; } spaceWidth -= toSub; } // create our output .c/.h files containing the pertinent data string cFile = fontDlg.FileName.Substring(0, fontFile.Length - 3) + "c"; string hFile = fontDlg.FileName.Substring(0, fontFile.Length - 3) + "h"; string headerComment = "/* Generated font file for CalcType (Prizm) */"; System.IO.StreamWriter hWriter = new System.IO.StreamWriter(hFile); hWriter.WriteLine(headerComment); hWriter.WriteLine("#pragma once"); hWriter.WriteLine(""); hWriter.WriteLine("#include \"../../calctype.h\""); hWriter.WriteLine(""); hWriter.WriteLine("extern const CalcTypeFont " + fileBase + ";"); hWriter.WriteLine(""); hWriter.Close(); System.IO.StreamWriter cWriter = new System.IO.StreamWriter(cFile); cWriter.WriteLine(headerComment); cWriter.WriteLine("#include \"" + fileBase + ".h\""); cWriter.WriteLine(""); cWriter.WriteLine("const unsigned char __charData_" + fileBase + "[] = {"); // build line for each character data int[] offsets = new int[256]; int curOffset = 0; for (int i = 33; i < 256; i++) { if (usedChars[i]) { offsets[i] = curOffset; int index = -1; for (int j = 0; j < chars.Count; j++) { if (chars[j].id == i) { index = j; break; } } string charLine = "\t"; if (chars[index].xoffset < 0) { charLine += (256 + chars[index].xoffset) + ","; } else { charLine += chars[index].xoffset + ","; } if (chars[index].yoffset < -2) { charLine += (256 + chars[index].yoffset / 3) + ","; } else { charLine += (chars[index].yoffset / 3) + ","; } charLine += chars[index].xadvance + ","; charLine += chars[index].width + ","; charLine += chars[index].height + ","; for (int j = 0; j < chars[index].data.Count; j++) { charLine += chars[index].data[j] + ","; } charLine += " // " + i; cWriter.WriteLine(charLine); curOffset += 5 + chars[index].data.Count; } else { offsets[i] = 0xFFFF; } } cWriter.WriteLine("};"); cWriter.WriteLine(""); cWriter.WriteLine("const CalcTypeFont " + fileBase + " = {"); cWriter.WriteLine("\t" + ((lineHeight + 1) / 3) + ", // height"); cWriter.WriteLine("\t" + ((lineBase + 1) / 3) + ", // base"); cWriter.WriteLine("\t" + spaceWidth + ", // space"); cWriter.WriteLine("\t__charData_" + fileBase + ", // char data"); // each character offset cWriter.WriteLine("\t{"); for (int i = 32; i < 256; i++) { cWriter.WriteLine("\t\t" + offsets[i] + ","); } cWriter.WriteLine("\t}"); cWriter.WriteLine("};"); cWriter.Close(); } else { MessageBox.Show("Could not find any chars to add"); } } }
void remPartyMember(CharInfo c) { }
protected abstract ResultCode UpdateLatest(CharInfo oldCharInfo, SourceFlag flag, out CharInfo newCharInfo);