public void HandleInput(InputStream stream) { if (Input.GetButton("A")) { stream.Add(new Punch1Command()); } if (Input.GetButton("B")) { stream.Add(new Punch2Command()); } if (Input.GetButton("X")) { stream.Add(new Kick1Command()); } if (Input.GetButton("Y")) { stream.Add(new Kick2Command()); } float x = Input.GetAxis("Joy1X"); float y = Input.GetAxis("Joy1Y"); if (Mathf.Abs(x) > xDeadzone || Mathf.Abs(y) > yDeadzone) { stream.Add(directionalInputFactory.MakeCommand(x, y)); } }
/// <summary> Tests the character stream </summary> public void TestCharStream() { // first, test the stream wrapper InputStream stream = new InputStream(); stream.Add("foo"); stream.Save(); Check(!stream.IsEmpty); Check(stream.Peek(), 'f'); // don't remove Check(stream.Read(), 'f'); // remove Check(stream.Peek(), 'o'); // don't remove Check(stream.Read(), 'o'); // remove Check(stream.Read(), 'o'); // remove last one Check(stream.Read(), (char)0); Check(stream.IsEmpty); Check(stream.Restore()); // make sure we can restore the old save Check(stream.Peek(), 'f'); // we're back at the beginning Check(!stream.Restore()); // there's nothing left to restore }
/// <summary> Adds a new string to the parse buffer </summary> public void AddString(string str) => _stream.Add(str);