void HandleInpput() { if (Input.GetKeyDown(KeyCode.Q)) { KeyQ.Execute(anim, true); oldCommands.Add(KeyQ); } else if (Input.GetKeyDown(KeyCode.W)) { KeyW.Execute(anim, true); oldCommands.Add(KeyW); } else if (Input.GetKeyDown(KeyCode.E)) { KeyE.Execute(anim, true); oldCommands.Add(KeyE); } else if (Input.GetKeyDown(KeyCode.UpArrow)) { upArrow.Execute(anim, true); oldCommands.Add(upArrow); } if (Input.GetKeyDown(KeyCode.Space)) { shouldStartReply = true; } if (Input.GetKeyDown(KeyCode.Z)) { UndoLastCommand(); } }
// TODO appears not to be thread safe: some tests fail under code coverage analysis with this enabled //private static DateTokens _dateTokenSingleton; //private static DateTokens Tokenizer //{ // get { return _dateTokenSingleton ?? (_dateTokenSingleton = new DateTokens()); } //} public static GEDDate DateParser(string datestr) { DateTokens tok = new DateTokens(); Context ctx = new Context(datestr, tok.Tokenize(datestr)); // TODO this is not standard, but some programs do this Cal calen = CheckCalendar(ctx); if (calen != Cal.Greg) // TODO other calendar support { return(new GEDDate(GEDDate.Types.Unknown)); } KeyW initKeyword = CheckInitialKeyword(ctx); ctx.gd = new GEDDate(); if (!parseDate(ref ctx, calen, second: false)) { return(ctx.gd); } // check for an era Era era = CheckEra(ctx); ctx.SetBC(era == Era.BC); KeyW secondKeyword = CheckSecondKeyword(ctx); if (secondKeyword != KeyW.None) { ctx.gd2 = new GEDDate(); // expecting a second date if (!parseDate(ref ctx, calen, second: true)) { return(new GEDDate(GEDDate.Types.Unknown)); // TODO track/note issues } Era era2 = CheckEra(ctx); ctx.SetBC(era2 == Era.BC, second: true); } // Still have unparsed stuff - must be problem if (ctx.LookAhead().type != TokType.EOF) { return(new GEDDate(GEDDate.Types.Unknown)); // TODO track/note issues } MakeJulianDayRange(ctx, initKeyword, secondKeyword); return(ctx.gd); }
void HandleInput() { //TODO: Break into chunks of actions that can be performed at the same time, ie movmenet actions, attack actions, etc if (Input.GetKeyDown(KeyCode.W)) { KeyW.Execute(Character, KeyW); } if (Input.GetKeyDown(KeyCode.A)) { KeyA.Execute(Character, KeyA); } if (Input.GetKeyDown(KeyCode.S)) { KeyS.Execute(Character, KeyS); } if (Input.GetKeyDown(KeyCode.D)) { KeyD.Execute(Character, KeyD); } //TODO: Ensure the following cant be pressed at the same time as an action else if (Input.GetKeyDown(KeyCode.R)) { KeyR.Execute(Character, KeyR); } else if (Input.GetKeyDown(KeyCode.Z)) { KeyZ.Execute(Character, KeyZ); } else { //No keys pushed //new IdleCommand().Execute(); } /*else if (Input.GetKeyDown(KeyCode.B)) * { * KeyB.Execute(KeyB); * }*/ }
// No key, exact date: date to julian, range=1 [Exact] // No key, range date, no month: beg of year to julian, range=365/366 [Between][Range] // No key, range date, month: beg of month to julian, range=month length [Between][Range] // firstKey: (no secondkey) // before - beg of date to julian [Before][Range] // after - end of date to julian [After][Range] // from - beg of date to julian [After][Period] // initialTo - end of date to julian [before][Period] // firstkey with second key: // from - beg of date1 to end of date2 [Between][Period] // between - beg of date1 to end of date2 [between][Range] private static void MakeJulianDayRange(Context ctx, KeyW firstKey, KeyW secondKey) { long jdn = 0; long range = 0; GEDDate.Types finalType = ctx.gd.Type; switch (firstKey) { case KeyW.None: case KeyW.Estimate: jdn = StartToJulian(ctx.gd); long jdn2 = jdn + 1; if (ctx.gd.Type != GEDDate.Types.Exact) { jdn2 = EndToJulian(ctx.gd); } range = jdn2 - jdn; if (firstKey == KeyW.Estimate) { finalType = GEDDate.Types.Estimated; } // TODO e.g. "1910 to 1920" needs to be marked non-standard break; case KeyW.Before: jdn = StartToJulian(ctx.gd); finalType = GEDDate.Types.Before; // TODO mark as range? break; case KeyW.After: jdn = EndToJulian(ctx.gd); finalType = GEDDate.Types.After; // TODO mark as range? break; case KeyW.InitialTo: jdn = EndToJulian(ctx.gd); finalType = GEDDate.Types.Before; // TODO mark as period? break; case KeyW.From: jdn = StartToJulian(ctx.gd); if (secondKey == KeyW.None) { finalType = GEDDate.Types.After; // TODO mark as range? } else if (secondKey != KeyW.From) { finalType = GEDDate.Types.Unknown; // TODO error mark? } else { jdn2 = EndToJulian(ctx.gd2); range = jdn2 - jdn; finalType = GEDDate.Types.Range; // TODO mark as period? } break; case KeyW.Between: if (secondKey == KeyW.None || secondKey != KeyW.Between || ctx.gd2 == null) { finalType = GEDDate.Types.Unknown; // TODO error mark? break; } jdn = StartToJulian(ctx.gd); jdn2 = EndToJulian(ctx.gd2); range = jdn2 - jdn; finalType = GEDDate.Types.Range; // TODO mark as range? break; } ctx.gd.JDN = jdn; ctx.gd.JDR = range; ctx.gd.Type = finalType; }
static void Main(string[] args) { Console.WriteLine("Please enter keyword to create object you want"); Console.WriteLine(); Console.WriteLine("Please enter 1 to create basic object for class DocumentProgram"); Console.WriteLine(); Console.WriteLine("Please enter 2 to create pro object for class ProDocumentProgram"); Console.WriteLine(); Console.WriteLine("Please enter 3 to create expert object for class ExpertDocument"); Console.WriteLine(); int number = Convert.ToInt32(Console.ReadLine()); KeyW keyword = (KeyW)number; switch (keyword) { case KeyW.basic: { Console.Clear(); DocumentProgram Mybasic = new DocumentProgram(); Console.WriteLine(); Console.WriteLine("Object is created and Methods of DocumentProgram CLASS are called: "); Console.WriteLine(); Console.WriteLine(); Mybasic.OpenDocument(); Console.WriteLine(); Mybasic.EditDocument(); Console.WriteLine(); Mybasic.SaveDocument(); Console.WriteLine(); Console.WriteLine(); } break; case KeyW.pro: { ProDocumentProgram Mypro = new ProDocumentProgram(); Console.Clear(); Console.WriteLine(); Console.WriteLine("Object is created and Methods of ProDocumentProgram CLASS are " + "called as DOWNCAST or plain way: "); Console.WriteLine(); Console.WriteLine(); Mypro.OpenDocument(); Console.WriteLine(); Mypro.EditDocument(); Console.WriteLine(); Mypro.SaveDocument(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Methods of ProDocumentProgram CLASS are called as UPCAST way: "); Console.WriteLine(); Console.WriteLine(); DocumentProgram BaseforPro = new ProDocumentProgram(); BaseforPro.OpenDocument(); Console.WriteLine(); BaseforPro.EditDocument(); Console.WriteLine(); BaseforPro.SaveDocument(); Console.WriteLine(); Console.WriteLine(); } break; case KeyW.expert: { ExpertDocument Myexpert = new ExpertDocument(); Console.Clear(); Console.WriteLine(); Console.WriteLine("Object is created and Methods of ExpertDocument CLASS are " + "called as DOWNCAST or plain way: "); Console.WriteLine(); Console.WriteLine(); Myexpert.OpenDocument(); Console.WriteLine(); Myexpert.EditDocument(); Console.WriteLine(); Myexpert.SaveDocument(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Methods of ExpertDocument CLASS are called as UPCAST way: "); Console.WriteLine(); Console.WriteLine(); DocumentProgram BaseforExpert = new ExpertDocument(); BaseforExpert.OpenDocument(); Console.WriteLine(); BaseforExpert.EditDocument(); Console.WriteLine(); BaseforExpert.SaveDocument(); Console.WriteLine(); Console.WriteLine(); } break; default: Console.WriteLine("Invalid choice"); break; } }