Beispiel #1
0
        public void StartGame()
        {
            Application.targetFrameRate = 60;
            var self = GameServices.RealTime.GetSelf();

            selfId = self.ParticipantId;
            var opponent = GameServices.RealTime.GetConnectedParticipants().Where(p => !p.ParticipantId.Equals(selfId)).FirstOrDefault();

            opponentId = opponent.ParticipantId;
            model      = new Racing3DGameModel(selfId, opponentId);
            IsPlaying  = true;

            ClearOldPowerUps();
            ClearSideObjects();

            if (model.IsHost)
            {
                var powerUpsPosition = GenerateRandomPositions();
                InstantiatePowerUps(powerUpsPosition);
                model.PowerUpsPosition = powerUpsPosition;

                var sideObjectsPosition = GenerateRandomSidePositions();
                InstantiateSideObjects(sideObjectsPosition);
                model.SideObjectsPosition = sideObjectsPosition;

                isStartMessageReceived = false;
                shouldSendStartMessage = true;
            }

            ControllableCar.ResetValues();
            ControllableCar.Controllable = true;
            OpponentCar.ResetValues();
            OpponentCar.Controllable = false;

            cameraControl.transform.position = ControllableCar.PrepareCameraPosition;
            view.ShowPrepareText();
            view.ShowInGameUI();
            LoadInfos(self, opponent);
        }