private void Start() { _currentSong = ""; _currentTempo = "1x"; if (onGameStateChange != null) { onGameStateChange.Invoke(_currentSong); onGameStateChange.Invoke(_currentTempo); } }
public void UpdateGameState(GameState state) { GameState previous = currentGameState; currentGameState = state; switch (currentGameState) { case GameState.PREGAME: Debug.Log("PREGAME"); break; case GameState.RUNNING: Debug.Log("RUNNING"); break; case GameState.PAUSE: Debug.Log("PAUSE"); break; default: break; } gameStateChange.Invoke(currentGameState, previous); }
protected virtual void OnGameStateChange(EventArgs <RoboGameState> args) { GameState = args.Value; GameStateChange?.Invoke(this, args); }
private void HandlePowerTaskList(Line line) { var match = _gameEntityRegex.Match(line.Text); if (match.Success) { var id = int.Parse(match.Groups["id"].Value); _currentEntity = id; GameStateChange?.Invoke(new FullEntity(new GameEntityData(id), null)); return; } match = _playerEntityRegex.Match(line.Text); if (match.Success) { var entityId = int.Parse(match.Groups["id"].Value); var playerId = int.Parse(match.Groups["playerId"].Value); _currentEntity = entityId; GameStateChange?.Invoke(new FullEntity(new PlayerEntityData(entityId, playerId), null)); return; } match = _fullEntityRegex.Match(line.Text); if (match.Success) { var id = int.Parse(match.Groups["id"].Value); _currentEntity = id; var cardId = match.Groups["cardId"].Value; var zone = GameTagParser.ParseEnum <Zone>(match.Groups["zone"].Value); if (string.IsNullOrEmpty(cardId) && zone != Zone.SETASIDE) { cardId = _currentBlock?.Data.NextPredictedCard() ?? cardId; } GameStateChange?.Invoke(new FullEntity(new EntityData(id, null, cardId, zone), _currentBlock?.Data)); return; } match = _tagChangeRegex.Match(line.Text); if (match.Success) { var entity = ParseEntity(match.Groups["entity"].Value); Enum.TryParse(match.Groups["tag"].Value, out GameTag tag); var value = GameTagParser.ParseTag(tag, match.Groups["value"].Value); var entityId = entity.Id == -1 ? null : (int?)entity.Id; GameStateChange?.Invoke(new TagChange(new TagChangeData(tag, value, false, entityId, entity.Name))); return; } match = _updatingEntityRegex.Match(line.Text); if (match.Success) { var cardId = match.Groups["cardId"].Value; var entity = ParseEntity(match.Groups["entity"].Value); _currentEntity = entity.Id; var type = match.Groups["type"].Value; if (type == "CHANGE_ENTITY") { GameStateChange?.Invoke(new ChangeEntity(new EntityData(entity.Id, entity.Name, cardId, null))); } else { GameStateChange?.Invoke(new ShowEntity(new EntityData(entity.Id, entity.Name, cardId, null), _currentBlock?.Data)); } return; } match = _creationTagRegex.Match(line.Text); if (match.Success && !line.Text.Contains("HIDE_ENTITY")) { var tag = GameTagParser.ParseEnum <GameTag>(match.Groups["tag"].Value); var value = GameTagParser.ParseTag(tag, match.Groups["value"].Value); GameStateChange?.Invoke(new TagChange(new TagChangeData(tag, value, true, _currentEntity, null))); return; } match = _hideEntityRegex.Match(line.Text); if (match.Success) { var id = int.Parse(match.Groups["id"].Value); _currentEntity = id; GameStateChange?.Invoke(new HideEntity(new EntityData(id, "", null, null))); } match = _blockStartRegex.Match(line.Text); if (match.Success) { var type = match.Groups["type"].Value; var entity = ParseEntity(match.Groups["entity"].Value.Trim()); var target = ParseEntity(match.Groups["target"].Value.Trim()); var effectCardId = match.Groups["effectCardId"].Value; var effectIndex = int.Parse(match.Groups["effectIndex"].Value); var rawTriggerKeyword = match.Groups["triggerKeyword"].Value; var triggerKeyword = string.IsNullOrEmpty(rawTriggerKeyword) || rawTriggerKeyword == "0" ? null : (GameTag?)GameTagParser.ParseEnum <GameTag>(rawTriggerKeyword); var blockData = new BlockData(type, entity.Id, entity.CardId, effectCardId, effectIndex, triggerKeyword, target); _currentBlock = _currentBlock?.CreateChild(blockData) ?? new Block(null, blockData); foreach (var card in _blockHelper.GetCreatedCards(blockData)) { blockData.PredictedCards.Add(card); } BlockStart?.Invoke(blockData); return; } match = _debugDumpRegex.Match(line.Text); if (match.Success) { if (int.Parse(match.Groups["id"].Value) == 2) { SetupComplete?.Invoke(); } } if (line.Text.Contains("BLOCK_END")) { BlockEnd?.Invoke(_currentBlock?.Data); _currentBlock = _currentBlock?.Parent; } }