private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(this); } else { Destroy(gameObject); return; } LDConversionTable LDConversionTable = LDConversionTable.Load(); m_DeathInputFrame = new LDInputFrame { action = LDConversionTable.GameplayTagToLDID(TypeTag.DeathAction), cell = 0 }; m_ServerTimeLine = new Server().RequestTimeLine(); if (m_ServerTimeLine.timeLine == null || m_ServerTimeLine.timeLine.Length <= 0) { m_ServerTimeLine.timeLine = new LDBlock[0]; m_BranchingIndex = 0; m_CurrentBlock.mods = new LDAttribute[0]; m_CurrentBlock.branches = new int[0]; m_CurrentBlock.characters = new LDCharacter[3]; m_CurrentBlock.characters[0].role = (byte)CharacterRole.Assassin; m_CurrentBlock.characters[0].timeLine = new LDInputFrame[1]; m_CurrentBlock.characters[0].timeLine[0] = m_DeathInputFrame; m_CurrentBlock.characters[0].name = "Ezio"; m_CurrentBlock.characters[0].attributes = new LDAttribute[0]; m_CurrentBlock.characters[1].role = (byte)CharacterRole.Barbarian; m_CurrentBlock.characters[1].timeLine = new LDInputFrame[1]; m_CurrentBlock.characters[1].timeLine[0] = m_DeathInputFrame; m_CurrentBlock.characters[1].name = "Barb"; m_CurrentBlock.characters[1].attributes = new LDAttribute[0]; m_CurrentBlock.characters[2].role = (byte)CharacterRole.Necromancer; m_CurrentBlock.characters[2].timeLine = new LDInputFrame[1]; m_CurrentBlock.characters[2].timeLine[0] = m_DeathInputFrame; m_CurrentBlock.characters[2].name = "Bob"; m_CurrentBlock.characters[2].attributes = new LDAttribute[0]; } else { m_CurrentBlock = m_ServerTimeLine.timeLine[0]; } }
static WritableSystem() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); //Scan trough assembly and find all methods with a write or read attribute in the domain. AddAllWritableFieldTypes(assemblies); //Get all Writables and IMessage types in the current domain List <Type> WritableTypes = new List <Type>(); foreach (Assembly a in assemblies) { WritableTypes.AddRange(a.GetTypes().Where(x => TypeIsWritable(x))); } //Add each writable type as it's own writabletype! foreach (Type t in WritableTypes) { AddSuportedType(t, (s, o) => Write(s, o), (Func <Stream, object>)_readReadInternal.MakeGenericMethod(t).CreateDelegate(typeof(Func <Stream, object>))); } //Do calculations for field members foreach (Type t in WritableTypes) { AddWritable(t); } MemoryStream mem = new MemoryStream(); //Int int[] inttemp = new int[] { 0 }; WriteArray <int>(mem, inttemp); mem.Seek(0, SeekOrigin.Begin); ReadArray <int>(mem); mem.Seek(4, SeekOrigin.Begin); ReadInternal <int>(mem); //LDBLock LDBlock[] temp = new LDBlock[] { new LDBlock { level = 0, branches = new int[] { 1 }, characters = new LDCharacter[] {}, mods = new LDAttribute[] {} } }; mem.Seek(0, SeekOrigin.Begin); WriteArray <LDBlock>(mem, temp); mem.Seek(0, SeekOrigin.Begin); ReadArray <LDBlock>(mem); mem.Seek(4, SeekOrigin.Begin); ReadInternal <LDBlock>(mem); //LDAttribute LDAttribute[] temp1 = new LDAttribute[] { new LDAttribute { type = 0, value = 0 } }; mem.Seek(0, SeekOrigin.Begin); WriteArray <LDAttribute>(mem, temp1); mem.Seek(0, SeekOrigin.Begin); ReadArray <LDAttribute>(mem); mem.Seek(4, SeekOrigin.Begin); ReadInternal <LDAttribute>(mem); //LDInputFrame LDInputFrame[] temp2 = new LDInputFrame[] { new LDInputFrame { action = 0, cell = 0 } }; mem.Seek(0, SeekOrigin.Begin); WriteArray <LDInputFrame>(mem, temp2); mem.Seek(0, SeekOrigin.Begin); ReadArray <LDInputFrame>(mem); mem.Seek(4, SeekOrigin.Begin); ReadInternal <LDInputFrame>(mem); //LDCharacter LDCharacter[] temp3 = new LDCharacter[] { new LDCharacter { attributes = temp1, color = 0, name = "", role = 0, timeLine = temp2 } }; mem.Seek(0, SeekOrigin.Begin); WriteArray <LDCharacter>(mem, temp3); mem.Seek(0, SeekOrigin.Begin); ReadArray <LDCharacter>(mem); mem.Seek(4, SeekOrigin.Begin); ReadInternal <LDCharacter>(mem); }
public void AppendInput(LDInputFrame input) { TimeLine.Add(input); }