/* * Execute command */ public override void Execute() { if (_codesQueue.Count != 0) { ByteCodes.Codes code = _codesQueue.Dequeue(); switch (code) { case ByteCodes.Codes.Hit: ByteCodes.Codes objectCode = _codesQueue.Dequeue(); GameObject hitObject = GameObject.Find(objectCode.ToString()); new HitCommand(hitObject).Execute(); break; case ByteCodes.Codes.IncrementScore: TMP_Text scoreText = GameObject.Find("ScoreText").GetComponent <TMP_Text>(); scoreText.SetText(scoreText.text + "."); break; case ByteCodes.Codes.Move: break; case ByteCodes.Codes.EndGame: break; default: Debug.Log("Unknown code"); break; } } }
/* * Add new command * @code - new code commnad */ public void AddCode(ByteCodes.Codes code) { _codesQueue.Enqueue(code); }