public void HandleEvent(GameStatusEvent aEvent)
        {
            currentGameStatus = aEvent;
            switch (aEvent)
            {
            case StartLevel _:
                frameOffset        = 0;
                transform.position = carPathPair.Path.Entrance;
                transform.rotation = Quaternion.Euler(0f, 0f, 90);
                carPathPair.Path.EventPerFrames.Clear();
                break;

            case StartNextPart _:
                frameOffset        = 0;
                transform.position = carPathPair.Path.Entrance;
                transform.rotation = Quaternion.Euler(0f, 0f, 90);
                isPathCompleted    = false;
                break;

            case ResetPart _:
                frameOffset        = 0;
                transform.position = carPathPair.Path.Entrance;
                transform.rotation = Quaternion.Euler(0f, 0f, 90);
                if (!isReplayMode)
                {
                    carPathPair.Path.EventPerFrames.Clear();
                }
                isPathCompleted = false;
                break;

            case null:
                throw new ArgumentNullException(nameof(aEvent));
            }
        }
예제 #2
0
 public void Awake()
 {
     startLevel           = CreateInstance <StartLevel>();
     finishLevel          = CreateInstance <FinishLevel>();
     startNextPart        = CreateInstance <StartNextPart>();
     finishPart           = CreateInstance <FinishPart>();
     resetPart            = CreateInstance <ResetPart>();
     GameStatusDispatcher = CreateInstance <GameStatusDispatcher>();
 }
        public async Task <bool> TryCreateEventAsync(ulong guildId, ulong channelId, CurrencyEvent.Type type,
                                                     EventOptions opts, Func <CurrencyEvent.Type, EventOptions, long, EmbedBuilder> embed)
        {
            SocketGuild       g  = _client.GetGuild(guildId);
            SocketTextChannel ch = g?.GetChannel(channelId) as SocketTextChannel;

            if (ch == null)
            {
                return(false);
            }

            ICurrencyEvent ce;

            if (type == CurrencyEvent.Type.Reaction)
            {
                ce = new ReactionEvent(_client, _cs, _bc, g, ch, opts, embed);
            }
            else if (type == CurrencyEvent.Type.GameStatus)
            {
                ce = new GameStatusEvent(_client, _cs, _bc, g, ch, opts, embed);
            }
            else
            {
                return(false);
            }

            var added = _events.TryAdd(guildId, ce);

            if (added)
            {
                try
                {
                    ce.OnEnded += OnEventEnded;
                    await ce.StartEvent().ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    _log.Warn(ex);
                    _events.TryRemove(guildId, out ce);
                    return(false);
                }
            }
            return(added);
        }
예제 #4
0
 private void Emit(GameStatusEvent @event)
 => _events.OnNext(@event);