Пример #1
0
        public RacePlayer(Ball ball, MatchMessenger matchMessenger, MatchPlayer associatedMatchPlayer)
        {
            sr = StageReferences.Active;

            this.matchMessenger        = matchMessenger;
            this.associatedMatchPlayer = associatedMatchPlayer;
            matchMessenger.CreateListener <CheckpointPassedMessage>(CheckpointPassedHandler);
            matchMessenger.CreateListener <RaceTimeoutMessage>(RaceTimeoutHandler);

            lap = 1;

            ball.CanMove           = false;
            ball.AutoBrake         = true;
            ball.CheckpointPassed += Ball_CheckpointPassed;
            ball.RespawnRequested += Ball_RespawnRequested;
            currentCheckpointPos   = sr.checkpoints[0].transform.position;
            this.ball              = ball;

            ball.CameraCreated += (sender, e) =>
            {
                ballCamera = e.CameraCreated;
                ballCamera.SetDirection(sr.checkpoints[0].transform.rotation);
            };

            checkpointTimes = new float[StageReferences.Active.checkpoints.Length];

            SetNextCheckpoint();
        }
Пример #2
0
        public void Init(MatchSettings settings, MatchManager matchManager, MatchMessenger messenger, bool raceIsInProgress)
        {
            this.settings     = settings;
            this.matchManager = matchManager;
            this.messenger    = messenger;

            messenger.CreateListener <StartRaceMessage>(StartRaceCallback);
            messenger.CreateListener <ClientLeftMessage>(ClientLeftCallback);
            messenger.CreateListener <DoneRacingMessage>(DoneRacingCallback);

            if (raceIsInProgress)
            {
                Debug.Log("Starting race in progress");
                joinedWhileRaceInProgress = true;
                CreateBallObjects();
            }
        }
Пример #3
0
        private void Start()
        {
            DontDestroyOnLoad(gameObject);

            //A messenger should be created by now! Time to create some message listeners
            messenger.CreateListener <SettingsChangedMessage>(SettingsChangedCallback);
            messenger.CreateListener <ClientJoinedMessage>(ClientJoinedCallback);
            messenger.CreateListener <ClientLeftMessage>(ClientLeftCallback);
            messenger.CreateListener <PlayerJoinedMessage>(PlayerJoinedCallback);
            messenger.CreateListener <PlayerLeftMessage>(PlayerLeftCallback);
            messenger.CreateListener <CharacterChangedMessage>(CharacterChangedCallback);
            messenger.CreateListener <ChangedReadyMessage>(ChangedReadyCallback);
            messenger.CreateListener <LoadRaceMessage>(LoadRaceCallback);
            messenger.CreateListener <ChatMessage>(ChatCallback);
            messenger.CreateListener <LoadLobbyMessage>(LoadLobbyCallback);
            messenger.CreateListener <AutoStartTimerMessage>(AutoStartTimerCallback);

            //Create this client
            myGuid = Guid.NewGuid();
            messenger.SendMessage(new ClientJoinedMessage(myGuid, ActiveData.GameSettings.nickname));
        }