public void spawnLevelNine() { GameObject fish = Instantiate(guppie, new Vector3(12, 3, 0), Quaternion.Euler(0, 180, 0)).gameObject; Fish specificFish = fish.GetComponent <Fish>(); fishStats.activeFishWeight = specificFish.fishWeight; fishStats.activeFishType = specificFish.fishType; stateManager.quickTimeDifficulty = specificFish.fishDiff; GameObject catchingFish = Instantiate(guppie, new Vector3(32, 5.59f, 0), Quaternion.identity).gameObject; catchingFish.transform.localScale = new Vector3(1, 2, 1); GameObject displayFish = Instantiate(guppie, new Vector3(32, 26, 0), Quaternion.identity).gameObject; displayFish.transform.localScale = new Vector3(1, 2, 1); FishMovement fishMovement = fish.GetComponent <FishMovement>(); for (int i = 0; i < 8; i++) { fishMovement.fishMoveQueue.Add(Vector3.left); } Instantiate(rock, new Vector3(3, 4, 0), Quaternion.identity); Instantiate(rock, new Vector3(5, 4, 0), Quaternion.identity); Instantiate(rock, new Vector3(7, 4, 0), Quaternion.identity); Instantiate(rock, new Vector3(9, 4, 0), Quaternion.identity); Instantiate(rock, new Vector3(11, 4, 0), Quaternion.identity); }
public void spawnLevelTen() { GameObject fish = Instantiate(alphaFish, new Vector3(6, 2, 0), Quaternion.Euler(0, 180, 0)).gameObject; Fish specificFish = fish.GetComponent <Fish>(); fishStats.activeFishWeight = specificFish.fishWeight; fishStats.activeFishType = specificFish.fishType; stateManager.quickTimeDifficulty = specificFish.fishDiff; GameObject catchingFish = Instantiate(alphaFish, new Vector3(32, 5.59f, 0), Quaternion.identity).gameObject; catchingFish.transform.localScale = new Vector3(1, 1, 1); GameObject displayFish = Instantiate(alphaFish, new Vector3(32, 26, 0), Quaternion.identity).gameObject; displayFish.transform.localScale = new Vector3(1, 1, 1); FishMovement fishMovement = fish.GetComponent <FishMovement>(); for (int i = 0; i < 4; i++) { fishMovement.fishMoveQueue.Add(vectorNone); } for (int i = 0; i < 5; i++) { fishMovement.fishMoveQueue.Add(Vector3.left); } Instantiate(log, new Vector3(4, 4, 0), Quaternion.Euler(0, 0, 90)); Instantiate(log, new Vector3(8, 4, 0), Quaternion.Euler(0, 0, 90)); Instantiate(log, new Vector3(6, 3, 0), Quaternion.identity); }
/* * creates a new fish and returns it. * leader is the cluster's name * isLeader defines if it is main fish that represents the cluster. */ public GameObject SpawnFish(string leader, bool isLeader) { GameObject fish = Instantiate(fishPrefab, transform.FindChild("center").transform.position, Quaternion.identity) as GameObject; FishData fd = fish.GetComponent <FishData> (); FishMovement fm = fish.GetComponent <FishMovement>(); fd.school = leader; if (isLeader) { fd.name = leader; fd.isSchoolLeader = isLeader; GameObject[] allfish = GameObject.FindGameObjectsWithTag("fish"); foreach (GameObject followerFish in allfish) { if (followerFish.GetComponent <FishData> ().school.Equals(leader)) { followerFish.GetComponent <FishMovement> ().leaderFish = fish; } if (followerFish.name.Equals(leader) && followerFish != fish) { Destroy(followerFish); } } } else { fm.leaderFish = GameObject.Find(leader); } if (leader.Equals("sandhills")) { if (isLeader) { fd.fishColor = new Color(0f, 0.3f, 0f); } else { fd.fishColor = Color.green; } } else if (leader.Equals("red-workers")) { if (isLeader) { fd.fishColor = new Color(0.3f, 0f, 0f); } else { fd.fishColor = Color.red; } } else { fd.fishColor = Color.cyan; } fd.SetColor(fd.fishColor); return(fish); }
void Start() { fishMovement = GetComponent <FishMovement>(); fishOxygen = GetComponent <FishOxygen>(); fishIndicators = GetComponent <FishIndicators>(); rb = GetComponent <Rigidbody>(); respawning = false; wonLevel = false; }
void ChangeFishSpeed(int speedModifer) { GameObject[] allFish = GameObject.FindGameObjectsWithTag("fish"); foreach (GameObject fish in allFish) { FishMovement fishMove = fish.GetComponent <FishMovement>(); fishMove.swimSpeed += speedModifer * tankScale; } Debug.Log(allFish[1].GetComponent <FishMovement>().swimSpeed); }
void ChangeFishZone(int zoneModifer) { GameObject[] allFish = GameObject.FindGameObjectsWithTag("fish"); foreach (GameObject fish in allFish) { FishMovement fishMove = fish.GetComponent <FishMovement>(); fishMove.ZONE_TWO_DIST += zoneModifer * tankScale; fishMove.ZONE_THREE_DIST += (zoneModifer * 2); } Debug.Log(allFish[1].GetComponent <FishMovement>().ZONE_TWO_DIST + ", " + allFish[1].GetComponent <FishMovement>().ZONE_THREE_DIST); }
void Start() { fishData = GameManager.instance.GetFishDataById(GameManager.instance.currentSpawnedFish.id); lineRenderer = GameManager.instance.hook.GetComponent <LineRenderer>(); fish = GameManager.instance.fish; fishAnimation = GameManager.instance.fish.animator.GetComponent <Transform>(); onTrigger = false; onTriggerEnter = false; swingAnimation = false; caught = false; pauseCounter = 0.5f; }
public IEnumerator lightningBoltSkill(float seconds) { fish = GameManager.instance.fish; fish.moveForce = 0; fish.currentDrag += 3; yield return(new WaitForSeconds(seconds)); if (fish != null) { fish.moveForce = GameManager.instance.GetFishDataById(GameManager.instance.currentSpawnedFish.id).moveForce; fish.currentDrag -= 3; } }
public void spawnLevelTwo() { GameObject fish = Instantiate(rainBowFish, new Vector3(1, 2, 0), Quaternion.identity).gameObject; Fish specificFish = fish.GetComponent <Fish>(); fishStats.activeFishWeight = specificFish.fishWeight; fishStats.activeFishType = specificFish.fishType; stateManager.quickTimeDifficulty = specificFish.fishDiff; GameObject catchingFish = Instantiate(rainBowFish, new Vector3(32, 5.59f, 0), Quaternion.identity).gameObject; catchingFish.transform.localScale = new Vector3(1, 2, 1); GameObject displayFish = Instantiate(rainBowFish, new Vector3(32, 26, 0), Quaternion.identity).gameObject; displayFish.transform.localScale = new Vector3(1, 2, 1); Instantiate(log, new Vector3(1, 3, 0), Quaternion.identity); Instantiate(log, new Vector3(3, 4, 0), Quaternion.Euler(0, 0, 90)); Instantiate(log, new Vector3(5, 4, 0), Quaternion.Euler(0, 0, 90)); Instantiate(log, new Vector3(7, 3, 0), Quaternion.identity); GameObject crabOne = Instantiate(crab, new Vector3(4, 3, 0), Quaternion.identity).gameObject; FishMovement fishMovement = fish.GetComponent <FishMovement>(); FishMovement crabMovement = crabOne.GetComponent <FishMovement>(); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.down); crabMovement.fishMoveQueue.Add(Vector3.down); crabMovement.fishMoveQueue.Add(Vector3.down); }
// Public Functions public IEnumerator moveAllFishes() { yield return(new WaitForFixedUpdate()); List <GameObject> fishes = GameObject.FindGameObjectsWithTag("Fish").ToList(); fishes.AddRange(GameObject.FindGameObjectsWithTag("Crab")); for (int i = 0; i < fishes.Count; i++) { FishMovement fishMovement = fishes[i].GetComponent <FishMovement>(); fishMovement.moveFish(); } }
public void InstantiateRCFishInAquarium() { RenderTextureCamera renderTextureCamera = fishPrefab.transform.parent.GetComponent <ColoringTrackingHandler>().RC.GetComponent <RenderTextureCamera>(); GameObject fish = (GameObject)Instantiate(fishPrefab, fishPrefab.transform.position, fishPrefab.transform.rotation); fish.transform.parent = aquariumBehavior.fishHolder.transform; fish.transform.localPosition = new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(0.08f, 0.3f), Random.Range(-0.18f, 0.15f)); while (Vector3.Distance(fish.transform.localPosition, aquariumBehavior.forbiddenArea.transform.localPosition) < 0.2f) { fish.transform.localPosition = new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(0.08f, 0.3f), Random.Range(-0.18f, 0.15f)); } fish.transform.localScale = new Vector3(1f, 1f, 1f); fish.transform.Rotate(fish.transform.up * Random.Range(20f, 200f)); //Texture2D tex2D = new Texture2D(renderTextureCamera.GetRenderTexture().width, renderTextureCamera.GetRenderTexture().height); //tex2D.ReadPixels(RenderTextureCamera.ARCamera_Camera.rect, 0, 0); //tex2D.Apply(); fish.GetComponentInChildren <GetTexture>().enabled = false; Texture2D FrameTexture = new Texture2D(renderTextureCamera.GetRenderTexture().width, renderTextureCamera.GetRenderTexture().height, TextureFormat.RGB24, false); RenderTexture.active = renderTextureCamera.GetRenderTexture(); FrameTexture.ReadPixels(new Rect(0, 0, renderTextureCamera.GetRenderTexture().width, renderTextureCamera.GetRenderTexture().height), 0, 0); RenderTexture.active = null; FrameTexture.Apply(); Material newMat = Resources.Load("FishMat", typeof(Material)) as Material; newMat.EnableKeyword("_MainTex"); newMat.SetTexture("_MainTex", FrameTexture); fish.GetComponentInChildren <SkinnedMeshRenderer>().material = newMat; //GetComponentInChildren<SkinnedMeshRenderer>().material.SetTexture("_MainTex", FrameTexture); FishMovement fishMovement = fish.AddComponent <FishMovement>(); fishMovement.aquariumBehavior = aquariumBehavior; fishMovement.SetPassPoints(passPoints); //fishMovement.movementType = (FishMovement.MovementType)Random.Range(0, 2); }
public void OnTriggerStay(Collider other) { if (other.gameObject.tag == "Player") { if (PairedHandler) // If the edge is paired { // Check if fish has passed the teleportation thingy FishMovement fishMov = other.GetComponentInParent <FishMovement>(); Vector3 fishDelta = Edge.transform.InverseTransformPoint(fishMov.transform.position); Vector3 reflectedDelta = Vector3.Reflect(fishDelta, Vector3.up); Debug.Log(fishDelta.normalized); Debug.Log(reflectedDelta.normalized); Transform pairedTrans = PairedHandler.GetComponentInParent <EdgeWall>().transform; Vector3 newPos = pairedTrans.TransformPoint(reflectedDelta); // Teleport that fish if the boundary is crossed! if (fishDelta.y < -0.01) { fishMov.transform.position = newPos; } else // Create/update clone { if (!Clone) // Add clone instance if pairs are established { Clone = Instantiate(ClonePrefab, newPos, fishMov.GetComponentInChildren <SpriteRenderer>().transform.rotation); } else { Clone.transform.position = newPos; Clone.GetComponentInChildren <SpriteRenderer>().transform.rotation = fishMov.GetComponentInChildren <SpriteRenderer>().transform.rotation; } } } else // Delete clone instance as pairs are deleted { if (Clone != null) { Destroy(Clone); } } } }
public void spawnLevelOne() { GameObject fish = Instantiate(guppie, new Vector3(6, 5, 0), Quaternion.identity).gameObject; Fish specificFish = fish.GetComponent <Fish>(); fishStats.activeFishWeight = specificFish.fishWeight; fishStats.activeFishType = specificFish.fishType; stateManager.quickTimeDifficulty = specificFish.fishDiff; GameObject catchingFish = Instantiate(guppie, new Vector3(32, 7, 0), Quaternion.identity).gameObject; catchingFish.transform.localScale = new Vector3(1, 2, 1); GameObject displayFish = Instantiate(guppie, new Vector3(32, 26, 0), Quaternion.identity).gameObject; displayFish.transform.localScale = new Vector3(1, 2, 1); Instantiate(log, new Vector3(6, 6, 0), Quaternion.identity); Instantiate(log, new Vector3(3, 6, 0), Quaternion.identity); Instantiate(log, new Vector3(9, 6, 0), Quaternion.identity); GameObject crabOne = Instantiate(crab, new Vector3(3, 7, 0), Quaternion.identity).gameObject; FishMovement fishMovement = fish.GetComponent <FishMovement>(); FishMovement crabMovement = crabOne.GetComponent <FishMovement>(); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.up); fishMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); }
public void spawnLevelSix() { GameObject fish = Instantiate(whale, new Vector3(8, 6, 0), Quaternion.Euler(0, 180, 0)).gameObject; Fish specificFish = fish.GetComponent <Fish>(); fishStats.activeFishWeight = specificFish.fishWeight; fishStats.activeFishType = specificFish.fishType; stateManager.quickTimeDifficulty = specificFish.fishDiff; GameObject catchingFish = Instantiate(whale, new Vector3(32, 5.59f, 0), Quaternion.identity).gameObject; catchingFish.transform.localScale = new Vector3(1, 1, 1); GameObject displayFish = Instantiate(whale, new Vector3(32, 26, 0), Quaternion.identity).gameObject; displayFish.transform.localScale = new Vector3(1, 1, 1); FishMovement fishMovement = fish.GetComponent <FishMovement>(); fishMovement.fishMoveQueue.Add(Vector3.down); fishMovement.fishMoveQueue.Add(Vector3.down); fishMovement.fishMoveQueue.Add(Vector3.down); fishMovement.fishMoveQueue.Add(Vector3.down); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); Instantiate(rock, new Vector3(7, 7, 0), Quaternion.identity); Instantiate(rock, new Vector3(9, 7, 0), Quaternion.identity); Instantiate(rock, new Vector3(9, 3, 0), Quaternion.identity); Instantiate(log, new Vector3(7, 5, 0), Quaternion.Euler(0, 0, 90)); Instantiate(log, new Vector3(9, 5, 0), Quaternion.Euler(0, 0, 90)); Instantiate(log, new Vector3(6, 3, 0), Quaternion.identity); Instantiate(log, new Vector3(12, 3, 0), Quaternion.identity); Instantiate(log, new Vector3(3, 3, 0), Quaternion.identity); }
public void InstantiateFishInAquarium() { GameObject fish = (GameObject)Instantiate(fishPrefab, fishPrefab.transform.position, fishPrefab.transform.rotation); fish.transform.parent = aquariumBehavior.fishHolder.transform; fish.transform.localPosition = new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(0.08f, 0.3f), Random.Range(-0.18f, 0.15f)); while (Vector3.Distance(fish.transform.localPosition, aquariumBehavior.forbiddenArea.transform.localPosition) < 0.2f) { fish.transform.localPosition = new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(0.08f, 0.3f), Random.Range(-0.18f, 0.15f)); } fish.transform.localScale = new Vector3(1f, 1f, 1f); fish.transform.Rotate(fish.transform.up * Random.Range(20f, 200f)); FishMovement fishMovement = fish.AddComponent <FishMovement>(); fishMovement.aquariumBehavior = aquariumBehavior; fishMovement.SetPassPoints(passPoints); //fishMovement.movementType = (FishMovement.MovementType)Random.Range(0, 2); }
public void spawnLevelFive() { GameObject fish = Instantiate(alphaFish, new Vector3(6, 2, 0), Quaternion.Euler(0, 180, 0)).gameObject; Fish specificFish = fish.GetComponent <Fish>(); fishStats.activeFishWeight = specificFish.fishWeight; fishStats.activeFishType = specificFish.fishType; stateManager.quickTimeDifficulty = specificFish.fishDiff; GameObject catchingFish = Instantiate(alphaFish, new Vector3(32, 5.59f, 0), Quaternion.identity).gameObject; catchingFish.transform.localScale = new Vector3(1, 1, 1); GameObject displayFish = Instantiate(alphaFish, new Vector3(32, 26, 0), Quaternion.identity).gameObject; displayFish.transform.localScale = new Vector3(1, 1, 1); FishMovement fishMovement = fish.GetComponent <FishMovement>(); fishMovement.repeats = true; fishMovement.fishMoveQueue.Add(Vector3.right); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.left); fishMovement.fishMoveQueue.Add(Vector3.right); GameObject crabOne = Instantiate(crab, new Vector3(4, 4, 0), Quaternion.identity).gameObject; FishMovement crabMovement = crabOne.GetComponent <FishMovement>(); crabMovement.repeats = true; crabMovement.fishMoveQueue.Add(vectorNone); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(vectorNone); crabMovement.fishMoveQueue.Add(vectorNone); crabMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(vectorNone); GameObject crabTwo = Instantiate(crab, new Vector3(8, 4, 0), Quaternion.identity).gameObject; crabMovement = crabTwo.GetComponent <FishMovement>(); crabMovement.repeats = true; crabMovement.fishMoveQueue.Add(vectorNone); crabMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(vectorNone); crabMovement.fishMoveQueue.Add(Vector3.right); Instantiate(log, new Vector3(2, 4, 0), Quaternion.identity); Instantiate(log, new Vector3(10, 4, 0), Quaternion.identity); Instantiate(log, new Vector3(3, 5, 0), Quaternion.identity); Instantiate(log, new Vector3(9, 5, 0), Quaternion.identity); Instantiate(log, new Vector3(6, 4, 0), Quaternion.Euler(0, 0, 90)); Instantiate(rock, new Vector3(4, 6, 0), Quaternion.identity); Instantiate(rock, new Vector3(6, 6, 0), Quaternion.identity); Instantiate(rock, new Vector3(8, 6, 0), Quaternion.identity); Instantiate(rock, new Vector3(9, 3, 0), Quaternion.identity); Instantiate(rock, new Vector3(8, 3, 0), Quaternion.identity); Instantiate(rock, new Vector3(8, 2, 0), Quaternion.identity); Instantiate(rock, new Vector3(4, 3, 0), Quaternion.identity); Instantiate(rock, new Vector3(4, 2, 0), Quaternion.identity); Instantiate(rock, new Vector3(3, 3, 0), Quaternion.identity); }
public void spawnLevelFour() { GameObject fish = Instantiate(dragonFish, new Vector3(6, 2, 0), Quaternion.identity).gameObject; Fish specificFish = fish.GetComponent <Fish>(); fishStats.activeFishWeight = specificFish.fishWeight; fishStats.activeFishType = specificFish.fishType; stateManager.quickTimeDifficulty = specificFish.fishDiff; GameObject catchingFish = Instantiate(dragonFish, new Vector3(32, 5.59f, 0), Quaternion.identity).gameObject; catchingFish.transform.localScale = new Vector3(1, 1, 1); GameObject displayFish = Instantiate(dragonFish, new Vector3(32, 26, 0), Quaternion.identity).gameObject; displayFish.transform.localScale = new Vector3(1, 1, 1); for (int i = 1; i < 12; i++) { Instantiate(crab, new Vector3(i, 7, 0), Quaternion.identity); } GameObject crabOne = Instantiate(crab, new Vector3(4, 5, 0), Quaternion.identity).gameObject; FishMovement crabMovement = crabOne.GetComponent <FishMovement>(); crabMovement.repeats = true; crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(Vector3.right); GameObject crabTwo = Instantiate(crab, new Vector3(8, 5, 0), Quaternion.identity).gameObject; crabMovement = crabTwo.GetComponent <FishMovement>(); crabMovement.repeats = true; crabMovement.fishMoveQueue.Add(Vector3.left); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.right); crabMovement.fishMoveQueue.Add(Vector3.left); GameObject crabThree = Instantiate(crab, new Vector3(4, 2, 0), Quaternion.identity).gameObject; GameObject crabFour = Instantiate(crab, new Vector3(8, 2, 0), Quaternion.identity).gameObject; crabMovement = crabThree.GetComponent <FishMovement>(); crabMovement.repeats = true; crabMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.down); crabMovement.fishMoveQueue.Add(Vector3.down); crabMovement = crabFour.GetComponent <FishMovement>(); crabMovement.repeats = true; crabMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.up); crabMovement.fishMoveQueue.Add(Vector3.down); crabMovement.fishMoveQueue.Add(Vector3.down); Instantiate(log, new Vector3(6, 3, 0), Quaternion.identity); Instantiate(log, new Vector3(2, 3, 0), Quaternion.Euler(0, 0, 90)); Instantiate(log, new Vector3(10, 3, 0), Quaternion.Euler(0, 0, 90)); }
public void removeFish(FishMovement fish) { fishCurrentlyFollowingPlayer.Remove(fish); }
public void addFish(FishMovement fish) { fishCurrentlyFollowingPlayer.Add(fish); }
public void setLeadFish(FishMovement fish) { leadFish = fish.transform.gameObject; leadFishOffset = leadFish.transform.position - transform.position; leadFishDistance = Vector3.Distance(transform.position, leadFish.transform.position); }
public void removeFish(FishMovement fish) { followingFish.removeFish(fish); stateController.RemoveFollowingFish(fish); if (!fish.isSpecial()) thirdPersonCamera.removeObjectThatMustAlwaysRemainInFieldOfView(fish.transform.gameObject); updateMinimumSpeed(); }
public void GetFish() { if (!hooked) { if (!possibleHookedFish) { if (Random.Range(0, 500) == 99 && isLocalPlayer) { currentHook.GetComponent <Hook>().Anim.SetBool("hooked", true); currentHook.GetComponent <Hook>().AnimInChild.SetBool("hooked", true); maxHookedFishTimer = Random.Range(3.0f, 6.0f); CmdHooked(true, maxHookedFishTimer); } } else { possibleHookedFishTimer += Time.deltaTime; if (possibleHookedFishTimer > maxHookedFishTimer && isLocalPlayer) { possibleHookedFish = false; currentHook.GetComponent <Hook>().Anim.SetBool("hooked", false); currentHook.GetComponent <Hook>().AnimInChild.SetBool("hooked", false); CmdHooked(false, 0.0f); possibleHookedFishTimer = 0.0f; } } if (InputManager.GetInputManager.GetButtonUp("Jump")) { if (possibleHookedFish) { hooked = true; possibleHookedFish = false; //create UI canvas = Instantiate(Canvas); } else { CmdDestroyHook(); Destroy(currentHook); } } } bool haveWin = false; if (canvas) { FishMovement fishmvt = canvas.GetComponentInChildren <FishMovement>(); haveWin = fishmvt.Win; if (fishmvt.Flee) { CmdDestroyHook(); Destroy(currentHook); } if (fishmvt.Win) { CmdDestroyHook(); Destroy(currentHook); Instantiate(Reward).GetComponent <FishingReward>().fishing = this; if (canvas) { Destroy(canvas); } } } if (!currentHook) { if (!haveWin) { isFishing = false; } ResetStates(); Destroy(fishingRod); } }
void Start() { _timeBetweenTouch = 0.0f; _fish = GameObject.FindObjectOfType(typeof(FishMovement)) as FishMovement; biometrics.plotter.breathingListener = _fish.EmitBubbles; }
// FIXME replace FishMovement with FishController public void AddFollowingFish(FishMovement fish) { followingFish.Add(fish); }
// FIXME replace FishMovement with FishController public void RemoveFollowingFish(FishMovement fish) { followingFish.Remove(fish); }
// FIXME this is just a wrapper for followingFish :/ public void addFish(FishMovement fish) { followingFish.addFish(fish); stateController.AddFollowingFish(fish); if (!fish.isSpecial()) thirdPersonCamera.addObjectThatMustAlwaysRemainInFieldOfView(fish.transform.gameObject); updateMinimumSpeed(); if (fish.isTheLeadFish() && fish.parentSchool().isGameWinner()) Invoke("freedGameWinningFish", 5f); }
private FishMovement fishMovement; // fish script // Use this for initialization void Start() { chargeBar = GameObject.Find("ChargeSlider"); chargeBar.SetActive(false); fishMovement = GameObject.Find("Fish_Player").GetComponent <FishMovement>(); }
public void AddSpecialFish(FishMovement fish) { specialFish.AddFish(fish); }
/// <summary> /// Moves the fishing hook and updates the finite state of the fishing rod /// </summary> private void UpdateFishingHook() { hookPrevPosition = hookPosition; switch (finiteState) { case FishingState.Inactive: // Finite state handled in CastLine(...) break; case FishingState.Casting: if (hookVelocity.y >= 0.0f) { hookVelocity = new Vector2(0.0f, 2.0f); finiteState = FishingState.Rising; } else { if (hookPosition.y > transform.position.y - 2.0f) { hookVelocity += new Vector2(0.0f, -4.0f) * Time.deltaTime; } hookPosition += hookVelocity * Time.deltaTime; hookVelocity -= hookVelocity.normalized * 3.0f * Time.deltaTime; // Reduces velocity by 1.0 per second if (hookPosition.x < -2.1f) { hookPosition.x = -2.1f; hookVelocity.x *= -0.8f; hookVelocity.y *= 0.8f; } else if (hookPosition.x > 2.7f) { hookPosition.x = 2.7f; hookVelocity.x *= -0.8f; hookVelocity.y *= 0.8f; } if (hookPosition.y < -68.0f) { hookPosition.y = -68.0f; hookVelocity.y = 0.0f; } } break; case FishingState.Rising: hookVelocity = hookVelocity * 0.9f + new Vector2(0.0f, 2.0f) * 0.1f; if (hookPosition.y > transform.position.y - 1.0f) { Catch newCatch = new Catch(); foreach (GameObject fish in hookedFish) { // collect money for fish FishMovement fishComp = fish.GetComponent <FishMovement>(); fishComp.goldManager.ReturnGoldByWeight(fish.GetComponent <Fish>().type, fishComp.fishWeight); // get fish weight and add it to fish object Fish fishData = fish.GetComponent <Fish>(); fishData.weight = fishComp.fishWeight; // add fish obj to catch newCatch.fish.Add(fish.GetComponent <Fish>()); // get rid of caught fish from scene Destroy(fish); vfxMachine.GetComponent <fishReeled>().Begin("", new Vector3(0.0f, 0.0f, 0.0f)); //WaitForSeconds (0.1f); } FishmongerFile.UpdateFishmongerFile(newCatch); hookedFish.Clear(); hookPosition = hookInactivePosition; finiteState = FishingState.Inactive; } else { hookPosition += hookVelocity * Time.deltaTime; HandleFishCollision(); for (int i = 0; i < hookedFish.Count; i++) { hookedFish[i].transform.position = hookPosition + new Vector2(0.0f, -0.2f); } } break; } fishingHook.transform.position = hookPosition; }
// Start is called before the first frame update void Start() { audioData = gameObject.GetComponent <AudioSource>(); fishMovement = fish.GetComponent <FishMovement>(); }