Beispiel #1
0
 public MovementManager(Station firstStation, Station lastStation, Route route, Movement firstMovement, Movement normalMovement, Movement goOutMovement, TrainPassengers passengers, TimeCounter timeCounter, CurrentPoints points, GuiManager gui, GuiRendererControl backToMenuButton, GuiRendererControl showRankingButton, bool isLocal, GuiPlayersPointsElement playersPoints, NetworkEntityPlaying network)
 {
     this.firstStation      = firstStation;
     this.lastStation       = lastStation;
     this.route             = route;
     this.movement          = firstMovement;
     this.normalMovement    = normalMovement;
     this.goOutMovement     = goOutMovement;
     this.passengers        = passengers;
     this.timeCounter       = timeCounter;
     this.points            = points;
     this.gui               = gui;
     this.backToMenuButton  = backToMenuButton;
     this.showRankingButton = showRankingButton;
     this.isLocal           = isLocal;
     this.playersPoints     = playersPoints;
     this.network           = network;
 }
Beispiel #2
0
 public MovementManager(Station firstStation, Station lastStation, Route route, Movement firstMovement, Movement normalMovement, Movement goOutMovement, TrainPassengers passengers, TimeCounter timeCounter, CurrentPoints points, GuiManager gui, GuiRendererControl backToMenuButton, GuiRendererControl showRankingButton, bool isLocal, GuiPlayersPointsElement playersPoints, NetworkEntityPlaying network)
 {
     this.firstStation = firstStation;
     this.lastStation = lastStation;
     this.route = route;
     this.movement = firstMovement;
     this.normalMovement = normalMovement;
     this.goOutMovement = goOutMovement;
     this.passengers = passengers;
     this.timeCounter = timeCounter;
     this.points = points;
     this.gui = gui;
     this.backToMenuButton = backToMenuButton;
     this.showRankingButton = showRankingButton;
     this.isLocal = isLocal;
     this.playersPoints = playersPoints;
     this.network = network;
 }
Beispiel #3
0
 public CurrentPoints(GameMap map, TrainPassengers passengers, TimeCounter timeCounter)
 {
     this.map         = map;
     this.passengers  = passengers;
     this.timeCounter = timeCounter;
 }
Beispiel #4
0
 public GuiHudElement(TrainPassengers passengers, TimeCounter timeCounter)
 {
     this.passengers  = passengers;
     this.timeCounter = timeCounter;
 }
Beispiel #5
0
    private MovementManager getMovementFor(Train train, bool isLocalTrain, NetworkTrainPlayer networkPlayer, GuiPlayersPointsElement playersPoints, NetworkEntityPlaying network)
    {
        float rotationSpeed = train.RotationSpeed;
        float translationSpeed = train.TranslationSpeed * GameMapSizeFactor.GetFactorForCurrentMapRelativeToFirstMap();
        int maxPassengers = train.MaxPassengers;
        Transform mover = train.transform.parent ?? train.transform;

        TransformOperations.To(mover).SetRotationTo(FirstStation.transform.position);

        Route route = new Route();
        route.Add(null);
        route.Add(FirstStation);

        if (isLocalTrain) {
            FirstStation.StartHighlight();
        }

        Player player = networkPlayer == null ? PlayerFactory.CreateLocal(train) : networkPlayer;

        TrainPassengersLimit trainPassengersLimit = TrainPassengersLimitFactory.Get(TrainPassengersLimitType);
        trainPassengersLimit.SetLimit(maxPassengers);
        TrainPassengers passengers = new TrainPassengers(trainPassengersLimit, player);

        TimeCounter timeCounter = new TimeCounter();
        timeCounters.Add(timeCounter);

        CurrentPoints points = new CurrentPoints(CurrentMap.GetCurrentMap(), passengers, timeCounter);
        playersPoints.AddPoints(player, points);

        GuiButtonRendererControl backToMenuButton = null;
        GuiButtonRendererControl showRankingButton = null;

        Movement firstMovement, normalMovement, goOutMovement;
        if (isLocalTrain) {
            Camera camera = Camera.main;
            Vector3 cameraOffset = -(mover.position - camera.transform.position);

            firstMovement = new ParallelMovement()
                .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationStartStepType, TERRESTRIAL))
                .AddMovement(new TranslationMovement(camera.transform, translationSpeed, TranslationStartStepType, TERRESTRIAL, cameraOffset));
            //firstMovement.Update(FirstStation.transform.position);

            normalMovement = new SequentialMovement()
                .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL))
                .AddMovement(new ParallelMovement()
                    .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL))
                    .AddMovement(new TranslationMovement(camera.transform, translationSpeed, TranslationDefaultStepType, TERRESTRIAL, cameraOffset)));

            goOutMovement = new SequentialMovement()
                .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL))
                .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL));

            MapCamera trainCamera = new TrainCamera(Camera.main);
            MapCamera freeCamera = new FreeCamera(Camera.main);
            CameraManager cameraManager = new CameraManager(trainCamera);

            backToMenuButton = new GuiButtonRendererControl(() => Application.LoadLevel(SceneNames.MENU));
            showRankingButton = new GuiButtonRendererControl(() => SocialManager.ForegroundActions.ShowLeaderboard(CurrentMap.GetCurrentMap()));
            GuiButtonRendererControl setTrainCameraButton = new GuiButtonRendererControl(() => cameraManager.SetCamera(trainCamera));
            GuiButtonRendererControl setFreeCameraButton = new GuiButtonRendererControl(() => cameraManager.SetCamera(freeCamera));

            gui.AddElement(new GuiHudElement(passengers, timeCounter));
            gui.AddElement(GuiElementFactory.GetSwitchCameraElement("Train\nCam", GuiPosition.DOWN_LEFT, setTrainCameraButton));
            gui.AddElement(GuiElementFactory.GetSwitchCameraElement("Free\nCam", GuiPosition.DOWN_RIGHT, setFreeCameraButton));

            input.AddLocal(route, cameraManager);
            input.AddButtons(backToMenuButton, showRankingButton, setTrainCameraButton, setFreeCameraButton);
        } else {
            firstMovement = new TranslationMovement(mover, translationSpeed, TranslationStartStepType, TERRESTRIAL);
            //firstMovement.Update(FirstStation.transform.position);

            goOutMovement = normalMovement = new SequentialMovement()
                .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL))
                .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL));

            networkPlayer.SetRoute(route);
        }

        return new MovementManager(FirstStation, LastStation, route, firstMovement, normalMovement, goOutMovement, passengers, timeCounter, points, gui, backToMenuButton, showRankingButton, isLocalTrain, playersPoints, network);
    }
Beispiel #6
0
    private MovementManager getMovementFor(Train train, bool isLocalTrain, NetworkTrainPlayer networkPlayer, GuiPlayersPointsElement playersPoints, NetworkEntityPlaying network)
    {
        float     rotationSpeed    = train.RotationSpeed;
        float     translationSpeed = train.TranslationSpeed * GameMapSizeFactor.GetFactorForCurrentMapRelativeToFirstMap();
        int       maxPassengers    = train.MaxPassengers;
        Transform mover            = train.transform.parent ?? train.transform;

        TransformOperations.To(mover).SetRotationTo(FirstStation.transform.position);

        Route route = new Route();

        route.Add(null);
        route.Add(FirstStation);

        if (isLocalTrain)
        {
            FirstStation.StartHighlight();
        }

        Player player = networkPlayer == null?PlayerFactory.CreateLocal(train) : networkPlayer;

        TrainPassengersLimit trainPassengersLimit = TrainPassengersLimitFactory.Get(TrainPassengersLimitType);

        trainPassengersLimit.SetLimit(maxPassengers);
        TrainPassengers passengers = new TrainPassengers(trainPassengersLimit, player);

        TimeCounter timeCounter = new TimeCounter();

        timeCounters.Add(timeCounter);

        CurrentPoints points = new CurrentPoints(CurrentMap.GetCurrentMap(), passengers, timeCounter);

        playersPoints.AddPoints(player, points);

        GuiButtonRendererControl backToMenuButton  = null;
        GuiButtonRendererControl showRankingButton = null;

        Movement firstMovement, normalMovement, goOutMovement;

        if (isLocalTrain)
        {
            Camera  camera       = Camera.main;
            Vector3 cameraOffset = -(mover.position - camera.transform.position);

            firstMovement = new ParallelMovement()
                            .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationStartStepType, TERRESTRIAL))
                            .AddMovement(new TranslationMovement(camera.transform, translationSpeed, TranslationStartStepType, TERRESTRIAL, cameraOffset));
            //firstMovement.Update(FirstStation.transform.position);

            normalMovement = new SequentialMovement()
                             .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL))
                             .AddMovement(new ParallelMovement()
                                          .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL))
                                          .AddMovement(new TranslationMovement(camera.transform, translationSpeed, TranslationDefaultStepType, TERRESTRIAL, cameraOffset)));

            goOutMovement = new SequentialMovement()
                            .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL))
                            .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL));

            MapCamera     trainCamera   = new TrainCamera(Camera.main);
            MapCamera     freeCamera    = new FreeCamera(Camera.main);
            CameraManager cameraManager = new CameraManager(trainCamera);

            backToMenuButton  = new GuiButtonRendererControl(() => Application.LoadLevel(SceneNames.MENU));
            showRankingButton = new GuiButtonRendererControl(() => SocialManager.ForegroundActions.ShowLeaderboard(CurrentMap.GetCurrentMap()));
            GuiButtonRendererControl setTrainCameraButton = new GuiButtonRendererControl(() => cameraManager.SetCamera(trainCamera));
            GuiButtonRendererControl setFreeCameraButton  = new GuiButtonRendererControl(() => cameraManager.SetCamera(freeCamera));

            gui.AddElement(new GuiHudElement(passengers, timeCounter));
            gui.AddElement(GuiElementFactory.GetSwitchCameraElement("Train\nCam", GuiPosition.DOWN_LEFT, setTrainCameraButton));
            gui.AddElement(GuiElementFactory.GetSwitchCameraElement("Free\nCam", GuiPosition.DOWN_RIGHT, setFreeCameraButton));

            input.AddLocal(route, cameraManager);
            input.AddButtons(backToMenuButton, showRankingButton, setTrainCameraButton, setFreeCameraButton);
        }
        else
        {
            firstMovement = new TranslationMovement(mover, translationSpeed, TranslationStartStepType, TERRESTRIAL);
            //firstMovement.Update(FirstStation.transform.position);

            goOutMovement = normalMovement = new SequentialMovement()
                                             .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL))
                                             .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL));

            networkPlayer.SetRoute(route);
        }

        return(new MovementManager(FirstStation, LastStation, route, firstMovement, normalMovement, goOutMovement, passengers, timeCounter, points, gui, backToMenuButton, showRankingButton, isLocalTrain, playersPoints, network));
    }
Beispiel #7
0
 public CurrentPoints(GameMap map, TrainPassengers passengers, TimeCounter timeCounter)
 {
     this.map = map;
     this.passengers = passengers;
     this.timeCounter = timeCounter;
 }