void Update() { m_frameCount = Time.frameCount - m_savedStartFrames; m_timer -= Time.deltaTime; if (m_timer <= 0f) { m_timer += 1; m_fps = Time.frameCount - m_savedFrames; m_savedFrames = Time.frameCount; } if (Input.GetKeyDown(KeyCode.R)) { LoadLevel(GetLoadedLevelId()); } if (Input.GetKeyDown(KeyCode.C)) { FollowController cameraFollowCtrl = Camera.main.GetComponent <FollowController>(); if (cameraFollowCtrl != null) { cameraFollowCtrl.ApplyTargetRotation = !cameraFollowCtrl.ApplyTargetRotation; } } if (Input.GetKeyDown(KeyCode.G) && GetLoadedLevelName().Contains("Galaxy")) { StartCoroutine(GalaxyWorldView()); } }
public override void Entry() { this.followController = new FollowController(this.StateMachine.Companion, this.StateMachine.CompanionManager.Farmer); this.StateMachine.Companion.faceTowardFarmerTimer = 0; this.StateMachine.Companion.movementPause = 0; this.StateMachine.Companion.followSchedule = false; this.StateMachine.Companion.Schedule = null; this.StateMachine.Companion.controller = null; this.StateMachine.Companion.temporaryController = null; this.StateMachine.Companion.eventActor = true; this.StateMachine.Companion.farmerPassesThrough = true; this.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked; this.Events.GameLoop.TimeChanged += this.GameLoop_TimeChanged; this.Events.Player.Warped += this.Player_Warped; if (this.BuffManager.HasAssignableBuffs()) { this.BuffManager.AssignBuffs(); } else { this.StateMachine.Monitor.Log($"Companion {this.StateMachine.Name} has no buffs defined!", LogLevel.Alert); } if (DialogueHelper.GetVariousDialogueString(this.StateMachine.Companion, "companionRecruited", out string dialogueText)) { this.StateMachine.Companion.setNewDialogue(dialogueText); } this.CanCreateDialogue = true; }
public void Start() { gameController = GameController.Get; moveController = this.GetComponent <MoveController>(); wheatFollowController = GenWheat.gameObject.GetComponent <FollowController>(); // init generated instance GenWheat.State = gameController.DataStorage.GeneratedWheatState ?? new WheatState(initDebugState: true); GenWheat.InitAndEnable(); // initialize variables for collision warning _boxCollider2D = this.GetComponent <BoxCollider2D>(); // update collision indicator -> show it if we can't root on initial location // TODO: Have different system for showing the initial can't root to `can't root due to collision with other wheat`? wheatSpriteRenderers = GenWheat.GetComponentsInChildren <SpriteRenderer>(); UpdateCollisionIndicator(); // explicitly don't want to await if (CreateOtherWheats) { _ = InstantiateOtherWheatsAsync(); } // update the scale of collider depending on generated wheat's size _boxCollider2D.transform.localScale *= GenWheat.State.Size; // do animations and finish init _ = RescaleWheatUnzoomToFieldAndFinishInit(); }
IEnumerator GalaxyWorldView() { PixelPerfectCameraCtrl cameraCtrl = FindObjectOfType <PixelPerfectCameraCtrl>(); FollowController camFollowCtrl = cameraCtrl.GetComponent <FollowController>(); camFollowCtrl.Target = null;//GameObject.Find("Planet (2)").transform; camFollowCtrl.DampTime = 3f; camFollowCtrl.ApplyTargetRotation = false; camFollowCtrl.RotationDampTime = 0.001f; float oriZoom = cameraCtrl.Zoom; float t = 0f; for (float zoom = cameraCtrl.Zoom; zoom >= oriZoom / 5; zoom -= 0.002f, t += 0.000005f) { Vector3 vTarget = Vector3.zero; PlanetBehaviour[] aPlanets = FindObjectsOfType <PlanetBehaviour>(); for (int i = 0; i < aPlanets.Length; ++i) { vTarget += aPlanets[i].transform.position; } vTarget /= aPlanets.Length; vTarget.z = cameraCtrl.transform.position.z; cameraCtrl.transform.position = Vector3.Slerp(cameraCtrl.transform.position, vTarget, t); cameraCtrl.Zoom = zoom; yield return(null); } yield return(null); }
public void TestInitialize() { _applicationUsersRepo = new Mock <IApplicationUserRepository>(); _unitOfWork = new Mock <IUnitOfWork>(); _unitOfWork.Setup(u => u.ApplicationUsers).Returns(_applicationUsersRepo.Object); _followController = new FollowController(_unitOfWork.Object); _userId = "1"; _followController.MockCurrentUser(_userId, "*****@*****.**"); }
public void TestGetAllFollowingId() { mockfollowService.Setup(x => x.GetAllFollowingId(It.IsAny <string>())).Returns(getAllFollowingIds); var followController = new FollowController(mockfollowService.Object); IActionResult getAllFollowingId = followController.GetAllFollowingId("5d0a17701a0a4200017de6c7"); var type = getAllFollowingId.GetType(); Assert.AreEqual(type.Name, "OkObjectResult"); }
public void TestFollow() { var contextMock = new Mock <HttpContext>(); contextMock.Setup(x => x.User).Returns(new ClaimsPrincipal(claims)); mockfollowService.Setup(x => x.AddFollows(It.IsAny <Follow>())).Returns(follow); var followController = new FollowController(mockfollowService.Object); followController.ControllerContext.HttpContext = contextMock.Object; IActionResult addFollow = followController.Follow("5d0a17701a0a4200017de6c7"); var type = addFollow.GetType(); Assert.AreEqual(type.Name, "OkObjectResult"); }
public void TestGetAllFollowing() { IEnumerable <User> ienumableUser = new List <User>() { user, userSecond }; mockfollowService.Setup(x => x.GetAllFollower(It.IsAny <string>())).Returns(ienumableUser); var followController = new FollowController(mockfollowService.Object); IActionResult getAllFollowing = followController.GetAllFollowing("5d0a17701a0a4200017de6c7"); var type = getAllFollowing.GetType(); Assert.AreEqual(type.Name, "OkObjectResult"); }
public void TestGetCurrentUserFollowedReturnNoContent() { var contextMock = new Mock <HttpContext>(); contextMock.Setup(x => x.User).Returns(new ClaimsPrincipal(claims)); mockfollowService.Setup(x => x.IsFollowed(It.IsAny <string>(), It.IsAny <string>())).Returns(true); var followController = new FollowController(mockfollowService.Object); followController.ControllerContext.HttpContext = contextMock.Object; IActionResult getCurrentUserFollowed = followController.GetCurrentUserFollowed("5d0a17701a0a4200017de6c7"); var type = getCurrentUserFollowed.GetType(); Assert.AreEqual(type.Name, "NoContentResult"); }
public override void Exit() { this.BuffManager.ReleaseBuffs(); this.StateMachine.Companion.eventActor = false; this.StateMachine.Companion.farmerPassesThrough = false; this.CanCreateDialogue = false; this.Events.GameLoop.UpdateTicked -= this.GameLoop_UpdateTicked; this.Events.GameLoop.TimeChanged -= this.GameLoop_TimeChanged; this.Events.Player.Warped -= this.Player_Warped; this.followController = null; this.dismissalDialogue = null; }
public void TestUnfollowReturnBadRequest() { Follow followNull = null; var contextMock = new Mock <HttpContext>(); contextMock.Setup(x => x.User).Returns(new ClaimsPrincipal(claims)); mockfollowService.Setup(x => x.Unfollow(It.IsAny <Follow>())).Returns(followNull); var followController = new FollowController(mockfollowService.Object); followController.ControllerContext.HttpContext = contextMock.Object; IActionResult unFollow = followController.Unfollow("5d0a17701a0a4200017de6c7"); var type = unFollow.GetType(); Assert.AreEqual(type.Name, "BadRequestResult"); }
// Use this for initialization void Start() { FollowController follow = Camera.GetComponent <FollowController>(); Transform transform = (Transform)Instantiate(Ball, AppData.ListFlags[AppData.CurrentLevel][AppData.CurrentCheckPoint], Quaternion.identity); follow.target = transform; for (int i = 0; i < AppData.Stars.Count; i++) { Star item = AppData.Stars[i]; if (item.Show) { Transform form = (Transform)Instantiate(Star, new Vector2(item.X, item.Y), Quaternion.identity); form.gameObject.name = "Star" + i; } } }
public void CreateSoldier() { GameObject soldier = Instantiate(SoldierResource, transform) as GameObject; soldier.transform.position = new Vector2(Random.Range(0, 20), Random.Range(0, 20)); FollowController followController = soldier.GetComponent <FollowController>(); if (followController == null) { return; } followController.SetFollowTarget(FollowTarget); followController.SetPosition(soldier.transform.position); m_CharacterList.Add(followController); }