public void Edit() { var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance(); var fishController = new FishController(fishRepository); var result = fishController.Edit(1); var model = (Fish)result.Model; Assert.AreEqual(1, model.FishId); Assert.AreEqual("Lüfer", model.Name); Assert.AreEqual(15.90, model.Price); }
void OnTriggerStay(Collider other) { if (tubeController.SystemActivated && currentTarget == null) { FishController fish = GameController.Obj.GetFishFromCollider(other); if (fish != null && other.attachedRigidbody) { currentTarget = fish; } } }
// Use this for initialization void Start() { goodThoughts = 0; initialFloorAngles = Floor.transform.localEulerAngles; fishController = FindObjectOfType <FishController>(); // spawn baits foreach (Bait bait in FindObjectsOfType <Bait>()) { baits.Add(bait); } }
public void ReleaseFish(FishController fishController) { //Housekeeping for changing a fish back into "swim" mode. fishController.PutDown(); fishController.SetEnabled(false); fishController.fishMovementController.SetEnabled(true); fishController.fishMovementController.Initialise(); fishController.FishSchoolController.AddFishToSchool(fishController.gameObject); fishController.gameObject.transform.SetParent(null); fishToExtractController = null; fishToExtractObject = null; }
void OnTriggerEnter(Collider other) { FishController collidingFish = other.GetComponent <FishController> (); if (collidingFish != null) { collidingFish.TriggerTextFadeOut(); } //Tell fish animation controller that it has entered a hiding place collider if (other.tag.Equals(EssentialData.TAG_PLAYER)) { manager.TriggerEntered(); } }
public void EditWithNoImage() { var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance(); var fishController = new FishController(fishRepository) { ControllerContext = FakeControllerContext.GetContextWithMockedSession() }; var fish = new Fish { FishId = 1, UserId = 1, Name = "Lüfer", Price = 15.90, ImageData = Encoding.UTF8.GetBytes("LüferFoto"), ImageMimeType = "image/png" }; var result = fishController.Edit(fish, null); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
public void IndexListNothing() { var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance(); var fishController = new FishController(fishRepository) { ControllerContext = FakeControllerContext.GetContextWithMockedNullSession() }; var result = fishController.Index(); Assert.IsInstanceOfType(result, typeof(ViewResult)); var model = (FishListViewModel)((ViewResult)result).Model; Assert.AreEqual(null, model.Fishes); }
public override GameObject GenerateObjOnLine(int line) { bool right = (Random.Range(0, 2) == 1) ? true : false; float type = Random.Range(0, percentsSum); int num = ChooseFish(type); GameObject pr = Instantiate(Fish[num], SpawnCoordsByLine(line, right), Quaternion.identity); pr.GetComponent <SpriteRenderer>().flipX = !right; FishController fc = pr.GetComponent <FishController>(); fc.CoefRight(right); fc.SetParentSpawner(this); pr.SetActive(false); return(pr); }
public void ReturnDefaultView() { // Arrange var mockedFishFactory = new Mock <IFishFactory>(); var mockedFishService = new Mock <IFishService>(); var controller = new FishController(mockedFishFactory.Object, mockedFishService.Object); // Act var result = controller.Add() as ViewResult; var model = result.ViewData.Model as AddFishViewModel; // Assert Assert.AreEqual("", result.ViewName); Assert.IsNotNull(model); }
void CreateFishesFromPrefab() { foreach (DNA <Vector2> Gene in population.Genes) { FishController fish = Instantiate(Prefab, transform.position, Quaternion.identity, transform); fish.dna = Gene; fish.basePosition = transform.position; fish.StartMove(); //Attach Events fish.MovesCompleted += MoveCompletedCheck; Gene.MovesetUpdated += fish.StartMove; Gene.RankUpdated += fish.RankUpdated; Fishes.Add(fish); } }
public void AddSchool(FishSchoolController schoolController) { AquariumSchoolData newData = new AquariumSchoolData(); foreach (GameObject fish in schoolController.FishInSchool) { FishController fishController = fish.GetComponent <FishController>(); if (fishController != null) { newData.numberOfFishes++; newData.fishType = fishController.fishType; } } savedSchools.Add(newData); }
public void IndexListAllFishes() { var fishRepository = new FishRepositoryMock().GetUserRepoMockedInstance(); var fishController = new FishController(fishRepository) { ControllerContext = FakeControllerContext.GetContextWithMockedSession() }; var result = fishController.Index(); Assert.IsInstanceOfType(result, typeof(ViewResult)); var model = (FishListViewModel)((ViewResult)result).Model; Assert.AreEqual(3, model.Fishes.Count()); Assert.AreEqual("Lüfer", model.Fishes.ElementAt(0).Name); Assert.AreEqual("Palamut", model.Fishes.ElementAt(2).Name); }
override public void Interact(GameObject otherActor) { if (otherActor.tag == "Player") { if (currentState == State.Empty) { PlayerInteractionController playerControllerScript = (PlayerInteractionController)otherActor.GetComponent(typeof(PlayerInteractionController)); if (playerControllerScript != null) { //Get the object held by the player. GameObject objectToHold = playerControllerScript.GetHeldObject(); if (objectToHold != null) { FishController heldObjectControllerScript = (FishController)objectToHold.GetComponent(typeof(FishController)); if (heldObjectControllerScript != null) { playerControllerScript.DropObject(); heldObjectControllerScript.PutIn(); heldObjectControllerScript.StartSlowPanic(); holdObject(objectToHold); returnStationController.Activate(heldObjectControllerScript); labNavController.SetWireframe(heldObjectControllerScript.fishType); } } } } else if (currentState == State.Holding) { PlayerInteractionController playerControllerScript = (PlayerInteractionController)otherActor.GetComponent(typeof(PlayerInteractionController)); if (playerControllerScript != null) { //Check that the player is not already holding on to something. if (playerControllerScript.GetHeldObject() == null) { if (heldObject != null) { playerControllerScript.PickUpObject(heldObject); removeHeldObject(); returnStationController.Deactivate(); labNavController.SetWireframe(GameData.FishType.None); } } } } } }
public void ExtractFish(FishController fish, GameObject other) { if (this.playerInStation != null) { PlayerInteractionController player = this.playerInStation.GetComponent <PlayerInteractionController>(); if (player != null) { //Player is not currently holding anything and can pick up the sucked fish. if (player.GetHeldObject() == null) { if (GameController.Obj.isTutorial) { if (TutorialManager.Obj.currentStep == 6) { TutorialManager.Obj.hasCaughtFish = true; } } /*fish.transform.position = SpawnPoint.position + new Vector3( * GameController.RNG.Next(-SPAWN_LOCATION_OFFSET, SPAWN_LOCATION_OFFSET), * GameController.RNG.Next(-SPAWN_LOCATION_OFFSET, SPAWN_LOCATION_OFFSET), * GameController.RNG.Next(-SPAWN_LOCATION_OFFSET, SPAWN_LOCATION_OFFSET) * );*/ fish.gameObject.GetComponent <Rigidbody>().detectCollisions = false; fish.gameObject.GetComponent <Rigidbody>().isKinematic = true; fish.transform.position = SpawnPoint.position; fish.SetEnabled(true); fish.fishMovementController.SetEnabled(false); player.PickUpObject(other); /*fish.SetRigidbody(true); * fish.rb.velocity = Vector3.zero; * fish.transform.SetParent(SpawnPoint);*/ this.IsActivated = false; this.WhenDeactivated(); this.ReleasePlayerFromStation(); fishToExtractController = null; fishToExtractObject = null; } } } }
private void Pursuit() { if (enableBehaviorList[BehaviorType.Pursuit]) { Collider[] hitColliders = Physics.OverlapSphere(GetPosition(), TankManager.Instance.GetNeighborDistance(), LayerMask.GetMask("Fish")); foreach (Collider coll in hitColliders) { FishController fishcontroller = coll.gameObject.GetComponent <FishController>(); if (coll.gameObject != gameObject && preyIDList.Contains(fishcontroller.GetGroupID())) { float distance = Vector3.Distance(fishcontroller.GetPosition(), GetPosition()); Vector3 predictposition = fishcontroller.GetPosition() + fishcontroller.GetVelocity() * distance / fishState.MaxVelocity; Seek(predictposition); break; } } } }
override public void Interact(GameObject otherActor) { if (otherActor.tag == "Player") { PlayerController player = otherActor.GetComponent <PlayerController> (); if (currentState == State.Idle) { if (subNavController.CurrentState == SubNavigationStationController.State.Empty) { for (int i = 0; i < MultiplayerManager.Obj.playerControllerList.Count; i++) { PlayerController playerToAttach = MultiplayerManager.Obj.playerControllerList[i]; GameObject pingObject = (GameObject)Instantiate(pingObjectTemplate); pingObject.transform.SetParent(playerToAttach.canvas.GetComponent <RectTransform>(), false); pingObject.name = playerToAttach.gameObject.ToString(); pingObject.GetComponent <NavigationPingController>().Init(playerToAttach.canvas.GetComponent <RectTransform>(), transform.position, playerToAttach); } //pingObject.GetComponent<NavigationPingController>().Init(player.canvas.GetComponent<RectTransform> (), transform.position, player); } else if (subNavController.CurrentState == SubNavigationStationController.State.Holding) { if (subNavController.HeldObject != null) { FishController fishController = subNavController.HeldObject.GetComponent <FishController>(); if (fishController != null) { for (int i = 0; i < MultiplayerManager.Obj.playerControllerList.Count; i++) { PlayerController playerToAttach = MultiplayerManager.Obj.playerControllerList[i]; GameObject pingObject = (GameObject)Instantiate(pingObjectTemplate); pingObject.transform.SetParent(playerToAttach.canvas.GetComponent <RectTransform>(), false); pingObject.name = playerToAttach.gameObject.ToString(); pingObject.GetComponent <NavigationPingController>().Init(playerToAttach.canvas.GetComponent <RectTransform>(), fishController.CaughtPosition, playerToAttach); } //pingObject.GetComponent<NavigationPingController>().Init(player.canvas.GetComponent<RectTransform> (), fishController.CaughtPosition, player); } } } currentState = State.Pinging; } } }
public void ReturnCorrectErrorMessage_IfAddingFishFailed() { // Arrange var mockedFishService = new Mock <IFishService>(); mockedFishService.Setup(s => s.Add(It.IsAny <Fish>())).Verifiable(); mockedFishService.Setup(s => s.Save()).Throws <Exception>(); var mockedFishFactory = new Mock <IFishFactory>(); mockedFishFactory.Setup(f => f.CreateFish(It.IsAny <string>(), It.IsAny <FishType>(), It.IsAny <string>(), It.IsAny <string>())).Verifiable(); var mockedFile = new MockHttpPostedFileBase(); mockedFile.SetContentLength(Constants.ImageMaxSize); var mockedHttpContext = new Mock <ControllerContext>(); mockedHttpContext.Setup(c => c.HttpContext.Server.MapPath(It.IsAny <string>())).Returns("Test"); var controller = new FishController(mockedFishFactory.Object, mockedFishService.Object); controller.ControllerContext = mockedHttpContext.Object; var model = new AddFishViewModel() { FishName = "Test", FishType = FishType.SeaFish, Info = "Test" }; // Act var result = controller.Add(model, mockedFile) as ViewResult; // Assert ModelState modelError; result.ViewData.ModelState.TryGetValue("", out modelError); Assert.IsNull(result.TempData[GlobalMessages.FishAddedSuccessKey]); Assert.AreEqual(GlobalMessages.FishAddingFailMessage, modelError.Errors.First().ErrorMessage); mockedFishService.Verify(s => s.Add(It.IsAny <Fish>()), Times.Once); mockedFishFactory.Verify(f => f.CreateFish(It.IsAny <string>(), It.IsAny <FishType>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
override public void Interact(GameObject otherActor) { if (otherActor.tag == "Player") { if (currentState == State.Empty) { } else if (currentState == State.Inactive) { } else if (currentState == State.Active) { //Dead fishes cannot be put back to the sea. if (!fishController.IsDead()) { if (GameController.Obj.isTutorial) { if (TutorialManager.Obj.currentStep == 11) { TutorialManager.Obj.hasReleasedFish = true; } } //Housekeeping for changing a fish back into "swim" mode. fishController.PutDown(); fishController.SetEnabled(false); fishController.fishMovementController.SetEnabled(true); fishController.fishMovementController.Initialise(); fishController.FishSchoolController.AddFishToSchool(fishController.gameObject); GameObject fishObject = subNavStationController.removeHeldObject(); fishObject.transform.position = releaseSlot.transform.position; fishObject.transform.SetParent(null); fishController = null; subNavStationController.labNavController.SetWireframe(GameData.FishType.None); lightMaterial.SetColor("_EmissionColor", Color.red); Deactivate(); } } } }
public void ReturnDefaultView_AndSetSuccessMessageToTempData_IfAddingFishNotFailed() { // Arrange var mockedFishService = new Mock <IFishService>(); mockedFishService.Setup(s => s.Add(It.IsAny <Fish>())).Verifiable(); mockedFishService.Setup(s => s.Save()).Verifiable(); var mockedFishFactory = new Mock <IFishFactory>(); mockedFishFactory.Setup(f => f.CreateFish(It.IsAny <string>(), It.IsAny <FishType>(), It.IsAny <string>(), It.IsAny <string>())).Verifiable(); var mockedFile = new MockHttpPostedFileBase(); mockedFile.SetContentLength(Constants.ImageMaxSize); var mockedHttpContext = new Mock <ControllerContext>(); mockedHttpContext.Setup(c => c.HttpContext.Server.MapPath(It.IsAny <string>())).Returns("Test"); var controller = new FishController(mockedFishFactory.Object, mockedFishService.Object); controller.ControllerContext = mockedHttpContext.Object; var model = new AddFishViewModel() { FishName = "Test", FishType = FishType.SeaFish, Info = "Test" }; // Act var result = controller.Add(model, mockedFile) as ViewResult; // Assert Assert.IsNotNull(result.TempData[GlobalMessages.FishAddedSuccessKey]); Assert.AreEqual("", result.ViewName); Assert.AreEqual(model, result.ViewData.Model); mockedFishService.Verify(s => s.Add(It.IsAny <Fish>()), Times.Once); mockedFishService.Verify(s => s.Save(), Times.Once); mockedFishFactory.Verify(f => f.CreateFish(It.IsAny <string>(), It.IsAny <FishType>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
public void Can_Send_Pagination_View_Model() { // Организация (arrange) Mock <IFishRepository> mock = new Mock <IFishRepository>(); mock.Setup(m => m.Fishes).Returns(new List <Fish> { new Fish { FishId = 1, Name = "Игра1" }, new Fish { FishId = 2, Name = "Игра2" }, new Fish { FishId = 3, Name = "Игра3" }, new Fish { FishId = 4, Name = "Игра4" }, new Fish { FishId = 5, Name = "Игра5" } }); FishController controller = new FishController(mock.Object); controller.pageSize = 3; // Act FishesListViewModel result = (FishesListViewModel)controller.List(null, 2).Model; // Assert PagingInfo pageInfo = result.PagingInfo; Assert.AreEqual(pageInfo.CurrentPage, 2); Assert.AreEqual(pageInfo.ItemsPerPage, 3); Assert.AreEqual(pageInfo.TotalItems, 5); Assert.AreEqual(pageInfo.TotalPages, 2); }
public void Generate_Category_Specific_Fish_Count() { /// Организация (arrange) Mock <IFishRepository> mock = new Mock <IFishRepository>(); mock.Setup(m => m.Fishes).Returns(new List <Fish> { new Fish { FishId = 1, Name = "Игра1", Category = "Cat1" }, new Fish { FishId = 2, Name = "Игра2", Category = "Cat2" }, new Fish { FishId = 3, Name = "Игра3", Category = "Cat1" }, new Fish { FishId = 4, Name = "Игра4", Category = "Cat2" }, new Fish { FishId = 5, Name = "Игра5", Category = "Cat3" } }); FishController controller = new FishController(mock.Object); controller.pageSize = 3; // Действие - тестирование счетчиков товаров для различных категорий int res1 = ((FishesListViewModel)controller.List("Cat1").Model).PagingInfo.TotalItems; int res2 = ((FishesListViewModel)controller.List("Cat2").Model).PagingInfo.TotalItems; int res3 = ((FishesListViewModel)controller.List("Cat3").Model).PagingInfo.TotalItems; int resAll = ((FishesListViewModel)controller.List(null).Model).PagingInfo.TotalItems; // Утверждение Assert.AreEqual(res1, 2); Assert.AreEqual(res2, 2); Assert.AreEqual(res3, 1); Assert.AreEqual(resAll, 5); }
//int _point; void Start() { rockObjects.Add(rockOne); rockObjects.Add(rockTwo); rockObjects.Add(rockFree); fish = GameObject.FindWithTag("fish").GetComponent <FishController>(); //_point = GManager.point; objectsBase.Add(platform); //0 objectsBase.Add(hook); //1 objectsBase.Add(bomb); //2 objectsBase.Add(shark); //3 objectsBase.Add(fishBlade); //4 objectsBase.Add(AnglerFish); //5 objectsBase.Add(SpikePlatform); //6 objectsBase.Add(Spike); //7 objectsBase.Add(SpikeBox); //8 objectsBase.Add(column); //9 objectsBase.Add(columnDown); //10 objectsBase.Add(TwoColumn); //11 StartCoroutine(PlatformSpawn()); }
/* * void OnCollisionEnter(Collision other) * { * if (tubeController.SystemActivated) * { * FishController fish = GameController.Obj.GetFishFromCollider(other.collider); * if (fish != null) * { * tubeController.ExtractFish(fish, other.gameObject); * } * } * }*/ void Update() { if (currentTarget != null) { if (tubeController.SystemActivated) { if (Vector3.Distance(tubeHeadGameObject.transform.position, currentTarget.transform.position) < minDistance) { tubeController.StartExtraction(currentTarget, currentTarget.gameObject); currentTarget = null; } else { Vector3 dir = tubeHeadGameObject.transform.position - currentTarget.transform.position; tubeController.MoveFish(dir, currentTarget.transform); } } else { currentTarget = null; } } }
public void LoadPlayerFish(string skinName) { if (!isPlayerFishLoaded) { GameObject go = fishPool.GetGameObject(skinName); FishController control = go.GetComponent <FishController>(); if (control == null) { control = go.AddComponent <FishController>(); } control.SetTag(EssentialData.TAG_PLAYER); //Update Movement Control movementControl.gameObject.SetActive(true); movementControl.fishParentTransform = go.transform; movementControl.fishEye = control.fishEyeControl; playerFish = control; isPlayerFishLoaded = true; } }
public void Can_Paginate() { // Организация (arrange) Mock <IFishRepository> mock = new Mock <IFishRepository>(); mock.Setup(m => m.Fishes).Returns(new List <Fish> { new Fish { FishId = 1, Name = "Игра1" }, new Fish { FishId = 2, Name = "Игра2" }, new Fish { FishId = 3, Name = "Игра3" }, new Fish { FishId = 4, Name = "Игра4" }, new Fish { FishId = 5, Name = "Игра5" } }); FishController controller = new FishController(mock.Object); controller.pageSize = 3; // Действие (act) FishesListViewModel result = (FishesListViewModel)controller.List(null, 2).Model; // Утверждение (assert) List <Fish> Fishs = result.Fishes.ToList(); Assert.IsTrue(Fishs.Count == 2); Assert.AreEqual(Fishs[0].Name, "Игра4"); Assert.AreEqual(Fishs[1].Name, "Игра5"); }
public void Can_Filter_Fishes() { // Организация (arrange) Mock <IFishRepository> mock = new Mock <IFishRepository>(); mock.Setup(m => m.Fishes).Returns(new List <Fish> { new Fish { FishId = 1, Name = "Игра1", Category = "Cat1" }, new Fish { FishId = 2, Name = "Игра2", Category = "Cat2" }, new Fish { FishId = 3, Name = "Игра3", Category = "Cat1" }, new Fish { FishId = 4, Name = "Игра4", Category = "Cat2" }, new Fish { FishId = 5, Name = "Игра5", Category = "Cat3" } }); FishController controller = new FishController(mock.Object); controller.pageSize = 3; // Action List <Fish> result = ((FishesListViewModel)controller.List("Cat2", 1).Model) .Fishes.ToList(); // Assert Assert.AreEqual(result.Count(), 2); Assert.IsTrue(result[0].Name == "Игра2" && result[0].Category == "Cat2"); Assert.IsTrue(result[1].Name == "Игра4" && result[1].Category == "Cat2"); }
IEnumerator DeathAnimation(FishController removeFish, FishObjectPooling fishPool) { Vector3 deathScale = fishHead.transform.lossyScale; float increment = 0.04f; for (int i = 0; i < count / 2; i++) { gameObject.transform.localScale += new Vector3(increment, increment); yield return(new WaitForSeconds(delay / 2)); } float decrement = 0.18f; for (int i = 0; i < count; i++) { gameObject.transform.localScale -= new Vector3(decrement, decrement); yield return(new WaitForSeconds(delay)); } gameObject.transform.localScale = new Vector3(0, 0); //Player dead Animation GameObject deadEffect = (GameObject)Resources.Load("prefab/Death Prefab", typeof(GameObject)); GameObject death = Instantiate(deadEffect) as GameObject; //calc scale Vector3 newScale = new Vector3(death.transform.localScale.x * deathScale.x, death.transform.localScale.y * deathScale.y); death.transform.localScale = newScale; death.transform.position = fishHead.transform.position; yield return(new WaitForSeconds(2f)); Destroy(death); gameObject.transform.localScale = new Vector3(1, 1, 1); fishPool.ReturnGameObject(removeFish.localData.fishSkin, removeFish.gameObject); }
public override FishState Update(FishController fish) { fish.transform.position = fish.target.transform.position; return(null); }
public override void Exit(FishController fish) { }
/// <summary> /// Creates a new Fish with that FishType at location /// </summary> public static FishController CreateNewFish(FishType type, Vector3 locationToSpawn) { FishController fish = null; try { fish = Instantiate(Obj.DefaultEmptyFishPrefab, locationToSpawn, Quaternion.identity).GetComponent <FishController>(); } catch { Debug.Log("Error instantiating fish"); return(null); } if (fish != null) { Transform prefab; switch (type) { case FishType.ClownFish: prefab = Obj.ClownFishPrefab; break; case FishType.UnicornFish: prefab = Obj.UnicornFishPrefab; break; case FishType.Whale: prefab = Obj.WhalePrefab; break; case FishType.Flounder: prefab = Obj.FlounderPrefab; break; case FishType.Penguin: prefab = Obj.PenguinPrefab; break; case FishType.Octi: prefab = Obj.OctiPrefab; break; case FishType.Shark: prefab = Obj.SharkPrefab; break; case FishType.TutorialClownFish: prefab = Obj.ClownFishPrefab; break; case FishType.Seahorse: prefab = Obj.SeahorsePrefab; break; case FishType.PufferFish: default: prefab = Obj.PufferFishPrefab; break; } try { Transform model = Instantiate(prefab, fish.transform); fish.Setup(type, model.GetComponentInChildren <SkinnedMeshRenderer>(), model.GetComponentInChildren <Animator>()); } catch { Debug.Log("Error instantiating fish mesh"); } } return(fish); }
void Start() { player = gameObject.GetComponentInParent<FishController> (); }