protected override void OnStart()
        {
            _transform = GetComponent <Transform>();

            _inputController = _controller as InputController;

            _runController            = _bootstrap.GetController(ControllerTypes.Run) as RunController;
            _runController.OnGameEnd += StartSelfDestruction;

            _tracksInfo = _bootstrap.GetModel(ModelTypes.Tracks) as RunTracks;

            _screen = _bootstrap.GetModel(ModelTypes.Screen) as ScreenInfo;

            CalculateCameraDistance();

            _bounds = new Bounds(transform.position, Vector3.zero);
            var childs = transform.GetComponentsInChildren <Renderer>();

            for (int i = 0; i < childs.Length; i++)
            {
                _bounds.Encapsulate(childs[i].bounds);
            }

            SetIdleAnimation();
        }
Example #2
0
 private void InitializeControllers()
 {
     this.ProjectController     = new ProjectController(this);
     this.ModelSystemController = new ModelSystemController(this);
     this.NetworkingController  = new NetworkingController(this);
     this.RunController         = new RunController(this);
 }
    protected IEnumerator waitForValidLocomotionModeToInteract()
    {
        if (locomotionTracker != null && locomotionTracker.GetCurrentController() is RunController)
        {
            Animator      anim          = GetComponent <Animator>();
            RunController runController = (RunController)locomotionTracker.GetCurrentController();
            RunController.ControllerBehaviour oldBehaviour = runController.Behaviour;
            runController.Behaviour = new RunController.ControllerBehaviour
            {
                IgnoreCollisions   = false,
                IgnoreGravity      = false,
                IgnoreRotation     = false,
                IgnoreTranslation  = false,
                IgnoreJumpRequests = true,
                IgnoreStickInput   = true,
                LastModifier       = this
            };
            AnimatorStateInfo animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim);
            while (!LocomotionUtils.IsLocomoting(animStateInfo) && !LocomotionUtils.IsLanding(animStateInfo) && !LocomotionUtils.IsIdling(animStateInfo))
            {
                yield return(null);

                animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim);
            }
            runController.ResetMomentum();
            if (runController.Behaviour.LastModifier == this)
            {
                runController.Behaviour = oldBehaviour;
            }
        }
    }
        public void Patch_ReturnOkResult_UpdateRun()
        {
            var mapper = MapperService.DefaultMapper();

            Run run      = GetRuns()[0];
            var mockRepo = new Mock <IRunRepository>();

            mockRepo.Setup(repo => repo.GetRun(It.IsAny <int>()))
            .ReturnsAsync(run);
            mockRepo.Setup(repo => repo.UpdateRun(It.IsAny <Run>()))
            .ReturnsAsync(true);

            JsonPatchDocument <RunViewModel> patchRequest = new JsonPatchDocument <RunViewModel>();

            patchRequest.Replace(r => r.RunId, 1);
            patchRequest.Replace(r => r.runStatus, RunStatus.OnTheRun);

            var controller = new RunController(mockRepo.Object, mapper);
            var result     = controller.Patch(1, patchRequest);
            var okResult   = Assert.IsType <OkObjectResult>(result.Result);

            Assert.Equal(200, okResult.StatusCode);
            var item = Assert.IsAssignableFrom <RunViewModel>(okResult.Value);

            Assert.Equal(1, item.RunId);
            Assert.Equal(RunStatus.OnTheRun, item.runStatus);
        }
        protected override void Update()
        {
            if (LocomotionHelper.IsCurrentControllerOfType <RunController>(GetTarget()))
            {
                RunController component = GetTarget().GetComponent <RunController>();
                component.Behaviour = new RunController.ControllerBehaviour
                {
                    IgnoreTranslation = !Controller,
                    IgnoreCollisions  = !Collisions,
                    IgnoreRotation    = !Steering,
                    IgnoreGravity     = !Gravity
                };
                if (!Gravity)
                {
                    component.ResetMomentum();
                }
            }
            PenguinUserControl component2 = GetTarget().GetComponent <PenguinUserControl>();

            if (component2 != null)
            {
                component2.enabled = UserControls;
            }
            Completed();
        }
Example #6
0
 protected override void OnEnable()
 {
     if (IsEnabled)
     {
         actionTarget = GetTarget();
         tracker      = actionTarget.GetComponent <LocomotionTracker>();
         if (tracker.SetCurrentController <RunController>())
         {
             thisTransform    = actionTarget.transform;
             raycastLayerMask = LayerConstants.GetPlayerLayerCollisionMask();
             actorRadius      = 0f;
             actorHalfHeight  = 0.1f;
             CharacterController component = actionTarget.GetComponent <CharacterController>();
             if (component != null)
             {
                 actorRadius     = component.radius;
                 actorHalfHeight = component.height / 2f;
             }
             runController = actionTarget.GetComponent <RunController>();
             base.OnEnable();
             CoroutineRunner.Start(doMoveTo(), this, "doMoveTo");
         }
     }
     else
     {
         CoroutineRunner.Start(completeAfterFrame(), this, "completeAfterFrame");
     }
 }
Example #7
0
        protected override void OnStart()
        {
            base.OnStart();
            _runController = _controller as RunController;

            StartEngine();
            _runController.OnGameEnd += StopEngine;
        }
Example #8
0
 protected override void OnEnable()
 {
     actionTarget  = GetTarget();
     motionTracker = actionTarget.GetComponent <MotionTracker>();
     runController = actionTarget.GetComponent <RunController>();
     broadcaster   = actionTarget.GetComponent <LocomotionEventBroadcaster>();
     base.OnEnable();
 }
 public void Awake()
 {
     agent   = GetComponent <NavMeshAgent>();
     tracker = GetComponent <LocomotionTracker>();
     agent.updatePosition = false;
     agent.updateRotation = false;
     tracker.SetCurrentController <RunController>();
     runController = GetComponent <RunController>();
     runController.Behaviour.SetStyle(LocoStyle);
 }
        public void SetUp()
        {
            _contextMock = new Mock <IDbContext>();

            _compiler    = new TestCompiler();
            _runner      = new TestRunner();
            _participant = new Participant {
                Email = "", Id = 12
            };
            _controller = new RunController(_contextMock.Object, _compiler, _runner, _participant);
        }
Example #11
0
        /*
         * private Vector3 _lastPosition;
         * private float _velocity;
         * private float _speed = 1.5f;
         * /**/

        protected override void OnStart()
        {
            _runController = _controller as RunController;
            _tracksInfo    = _bootstrap.GetModel(ModelTypes.Tracks) as RunTracks;

            /*
             * _lastPosition = transform.position;
             * _velocity = 0;
             * _speed = _runController.FixedSpeed;
             * /**/

            _offset = transform.TransformDirection(Vector3.forward);
            _offset = new Vector3(_offset.x, 0, _offset.z).normalized *Offset;
        }
Example #12
0
 public void Start()
 {
     animator      = base.gameObject.GetComponent <Animator>();
     runController = base.gameObject.GetComponent <RunController>();
     if (runController != null)
     {
         runController.OnSteer += OnStickDirectionEvent;
     }
     locomotionStateSetter = base.gameObject.GetComponent <AvatarLocomotionStateSetter>();
     if (locomotionStateSetter != null)
     {
         locomotionStateSetter.ActionButtonInvoked += OnActionButtonClicked;
     }
 }
        public void GetById_ReturnNotFoundResult_NoRun()
        {
            var mapper = MapperService.DefaultMapper();

            Run run      = null;
            var mockRepo = new Mock <IRunRepository>();

            mockRepo.Setup(repo => repo.GetRun(It.IsAny <int>()))
            .ReturnsAsync(run);

            var controller     = new RunController(mockRepo.Object, mapper);
            var result         = controller.Get(1);
            var notFoundResult = Assert.IsType <NotFoundResult>(result.Result.Result);

            Assert.Equal(404, notFoundResult.StatusCode);
        }
Example #14
0
        public void GetFinishedUsers()
        {
            //Arrange

            var controller = new RunController();

            //Act
            var         real     = controller.GetFinishedUsers(Users);
            List <User> excepted = new List <User>()
            {
                Users[0], Users[4]
            };

            // Assert
            Assert.Equal(real, excepted);
        }
        public void Get_ReturnsNotFoundResult_NoRuns()
        {
            var mapper = MapperService.DefaultMapper();

            IEnumerable <Run> runs = null;
            var mockRepo           = new Mock <IRunRepository>();

            mockRepo.Setup(repo => repo.GetAllRuns())
            .ReturnsAsync(runs);

            var controller     = new RunController(mockRepo.Object, mapper);
            var result         = controller.Get();
            var NotFoundResult = Assert.IsType <NotFoundResult>(result.Result.Result);

            Assert.Equal(404, NotFoundResult.StatusCode);
        }
        public void Patch_ReturnNotFoundResult_NoRun()
        {
            var mapper = MapperService.DefaultMapper();

            Run run      = null;
            var mockRepo = new Mock <IRunRepository>();

            mockRepo.Setup(repo => repo.GetRun(It.IsAny <int>()))
            .ReturnsAsync(run);

            JsonPatchDocument <RunViewModel> patchRequest = new JsonPatchDocument <RunViewModel>();
            var controller     = new RunController(mockRepo.Object, mapper);
            var result         = controller.Patch(1, patchRequest);
            var notFoundResult = Assert.IsType <NotFoundResult>(result.Result);

            Assert.Equal(404, notFoundResult.StatusCode);
        }
    private void OnDisable()
    {
        base.Broadcaster.OnInteractionPreStartedEvent -= onInteractionPreStartedEvent;
        if (animator != null)
        {
            animator.SetBool(AnimationHashes.Params.Sit, value: false);
        }
        RunController component = GetComponent <RunController>();

        if (component != null)
        {
            component.Behaviour.Reset();
        }
        if (chair != null)
        {
            chair.gameObject.SetActive(value: true);
        }
    }
Example #18
0
 private void OnParticlesLoaded(string key, GameObject asset)
 {
     if (!base.gameObject.IsDestroyed())
     {
         levelUpParticles = Object.Instantiate(asset);
         levelUpParticles.transform.SetParent(base.transform);
         levelUpParticles.transform.localPosition = Vector3.zero;
         RunController component = base.gameObject.GetComponent <RunController>();
         float         t         = 1f;
         if (component != null && component.enabled)
         {
             animator.SetTrigger("LevelUp");
             t = animator.GetCurrentAnimatorClipInfo(0)[0].clip.length + 1f;
         }
         Object.Destroy(levelUpParticles, t);
         Object.Destroy(this, t);
     }
 }
        public void Get_ReturnsOkResult_WithAllRuns()
        {
            var mapper = MapperService.DefaultMapper();

            var mockRepo = new Mock <IRunRepository>();

            mockRepo.Setup(repo => repo.GetAllRuns())
            .ReturnsAsync(GetRuns());

            var controller = new RunController(mockRepo.Object, mapper);
            var result     = controller.Get();
            var okResult   = Assert.IsType <OkObjectResult>(result.Result.Result);

            Assert.Equal(200, okResult.StatusCode);
            var items = Assert.IsAssignableFrom <IEnumerable <RunViewModel> >(okResult.Value);

            Assert.Equal(2, items.Count());
        }
Example #20
0
 protected override void OnEnable()
 {
     anim          = GetComponent <Animator>();
     stateID       = Animator.StringToHash(StateName);
     controller    = GetComponent <CharacterController>();
     runController = base.gameObject.GetComponent <RunController>();
     animDuration  = Duration;
     thisTransform = base.transform;
     isWarping     = IdealStartTransform != null;
     lastValidPos  = thisTransform.position;
     lastValidRot  = thisTransform.rotation;
     animFound     = anim.HasState(LayerIndex, stateID);
     if (animFound)
     {
         anim.Play(stateID, LayerIndex, NormStartTime);
         elapsedTime = 0f;
     }
     base.OnEnable();
 }
        public void GetById_ReturnOkResult_WithRun()
        {
            var mapper = MapperService.DefaultMapper();

            var run      = GetRuns()[0];
            var mockRepo = new Mock <IRunRepository>();

            mockRepo.Setup(repo => repo.GetRun(It.IsAny <int>()))
            .ReturnsAsync(run);

            var controller = new RunController(mockRepo.Object, mapper);
            var result     = controller.Get(1);
            var okResult   = Assert.IsType <OkObjectResult>(result.Result.Result);

            Assert.Equal(200, okResult.StatusCode);
            var item = Assert.IsAssignableFrom <RunViewModel>(okResult.Value);

            Assert.Equal(1, item.RunId);
        }
Example #22
0
        private IEnumerator Start()
        {
            bool animationCompleted = false;

            if (DelaySeconds > 0f)
            {
                yield return(new WaitForSeconds(DelaySeconds));
            }
            localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject;
            if (localPlayerGameObject != null)
            {
                RunController           runController           = localPlayerGameObject.GetComponent <RunController>();
                ParticipationController participationController = localPlayerGameObject.GetComponent <ParticipationController>();
                if (runController != null && runController.enabled && participationController != null && (participationController.GetParticipationData().CurrentParticipationState == ParticipationState.Ready || participationController.GetParticipationData().CurrentParticipationState == ParticipationState.Pending))
                {
                    Animator animator = localPlayerGameObject.GetComponent <Animator>();
                    if (animator != null)
                    {
                        localPlayerGameObject.GetComponent <Animator>().SetTrigger(AnimationTrigger);
                        focusCameraOnPenguin();
                        if (this.OnAnimationStarted != null)
                        {
                            this.OnAnimationStarted();
                        }
                        yield return(null);

                        yield return(new WaitForSeconds(animator.GetCurrentAnimatorClipInfo(0)[0].clip.length));

                        animationCompleted = true;
                    }
                }
            }
            if (wasCameraMoved)
            {
                resetCamera();
            }
            if (this.OnAnimationEnded != null)
            {
                this.OnAnimationEnded(animationCompleted);
            }
            UnityEngine.Object.Destroy(base.gameObject);
        }
    public IEnumerator Start()
    {
        playerPenguinGO = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject;
        if (playerPenguinGO != null)
        {
            RunController           runController           = playerPenguinGO.GetComponent <RunController>();
            ParticipationController participationController = playerPenguinGO.GetComponent <ParticipationController>();
            if (runController != null && runController.enabled && participationController != null && (participationController.GetParticipationData().CurrentParticipationState == ParticipationState.Ready || participationController.GetParticipationData().CurrentParticipationState == ParticipationState.Pending))
            {
                Animator anim = playerPenguinGO.GetComponent <Animator>();
                if (anim != null)
                {
                    playerPenguinGO.GetComponent <Animator>().SetTrigger("LevelUp");
                    focusCameraOnPenguin();
                    yield return(null);

                    yield return(new WaitForSeconds(anim.GetCurrentAnimatorClipInfo(0)[0].clip.length));
                }
            }
        }
        Object.Destroy(base.gameObject);
    }
Example #24
0
 protected override void OnEnable()
 {
     runController = GetComponent <RunController>();
     thisTransform = base.transform;
     prevPos       = thisTransform.position;
     if (runController != null)
     {
         runController.ResetState();
         runController.Behaviour = new RunController.ControllerBehaviour
         {
             IgnoreCollisions  = true,
             IgnoreRotation    = true,
             IgnoreGravity     = true,
             IgnoreTranslation = true
         };
     }
     pilot = PilotTransform;
     if (pilot == null && IncomingUserData != null && IncomingUserData.GetType() == typeof(GameObject))
     {
         pilot = ((GameObject)IncomingUserData).transform;
     }
     base.OnEnable();
 }
Example #25
0
    void Awake()
    {
        Debug.Log("GameController awake");
        // LoadAssets(); // Load Prefabs/Materials from Resources folder
        assets = (AssetData)GameObject.FindObjectOfType(typeof(AssetData));

        audioController     = (AudioController)GameObject.FindObjectOfType(typeof(AudioController));
        runController       = (RunController)GameObject.FindObjectOfType(typeof(RunController));
        interfaceController = (InterfaceController)GameObject.FindObjectOfType(typeof(InterfaceController));
        stage = (Stage)GameObject.FindObjectOfType(typeof(Stage));

        tileContainer = (GameObject)GameObject.Find("TileContainer");

        /*
         * p1 = new Player(1, stage.Dimensions);
         * p2 = new Player(2, stage.Dimensions);
         * p1.Opponent = p2;
         * p2.Opponent = p1;
         */


        gameView = (GameView)GameObject.FindObjectOfType(typeof(GameView));
    }
        public void Patch_ReturnBadResult_CannotUpdateRun()
        {
            var mapper = MapperService.DefaultMapper();

            Run run      = GetRuns()[0];
            var mockRepo = new Mock <IRunRepository>();

            mockRepo.Setup(repo => repo.GetRun(It.IsAny <int>()))
            .ReturnsAsync(run);
            mockRepo.Setup(repo => repo.UpdateRun(It.IsAny <Run>()))
            .ReturnsAsync(false);

            JsonPatchDocument <RunViewModel> patchRequest = new JsonPatchDocument <RunViewModel>();

            patchRequest.Replace(r => r.RunId, 1);
            patchRequest.Replace(r => r.runStatus, RunStatus.OnTheRun);

            var controller = new RunController(mockRepo.Object, mapper);
            var result     = controller.Patch(1, patchRequest);
            var BadResult  = Assert.IsType <BadRequestResult>(result.Result);

            Assert.Equal(400, BadResult.StatusCode);
        }
Example #27
0
 public RunControllerDisplayModel(XTMFRuntime runtime)
 {
     _runController = runtime.RunController;
 }
Example #28
0
 protected override void identifiedLocalPlayer(GameObject localPlayer)
 {
     locomotionEventBroadcaster = localPlayer.GetComponent <LocomotionEventBroadcaster>();
     runController = localPlayer.GetComponent <RunController>();
     base.identifiedLocalPlayer(localPlayer);
 }
 public void Awake()
 {
     controller = GetComponent <RunController>();
 }
Example #30
0
 private void Construct(RunController runController)
 {
     _moveController = runController;
 }