void Update() { levelRunTime += Time.deltaTime; if (p1 == null) { p1 = GameObject.FindGameObjectWithTag("PLAYER1"); if (p1 != null) { player1 = p1.GetComponent <PlayerScript>(); } } if (p2 == null) { p2 = GameObject.FindGameObjectWithTag("PLAYER2"); if (p2 != null) { player2 = p2.GetComponent <PlayerScript>(); } } if (p1 == null || p2 == null) { return; } PlayerScript.FingerState p1finger = player1.MouseFingerDown(); PlayerScript.FingerState p2finger = player2.MouseFingerDown(); if (p1finger == PlayerScript.FingerState.Single && p2finger == PlayerScript.FingerState.Single) { player1.SetDoLinkInk(true); player2.SetDoLinkInk(true); } else { player1.SetDoLinkInk(false); player2.SetDoLinkInk(false); } GameObject[] blackHoles = GameObject.FindGameObjectsWithTag("blackhole"); foreach (GameObject bh in blackHoles) { BlackHoleScript blackHoleScript = bh.GetComponent <BlackHoleScript>(); if (Network.isServer) { player1.UpdateAgainstBlackHole(blackHoleScript); } else if (Network.isClient) { player2.UpdateAgainstBlackHole(blackHoleScript); } } if (levelRunTime > 5.0f && blackHoles.Length == 0) { GameLogicController.instance.MoveToNextLevel(); } }
// Update is called once per frame void Update() { if (p1 == null) { p1 = GameObject.FindGameObjectWithTag("PLAYER1"); if (p1 != null) { player1 = p1.GetComponent <PlayerScript>(); } } if (p2 == null) { p2 = GameObject.FindGameObjectWithTag("PLAYER2"); if (p2 != null) { player2 = p2.GetComponent <PlayerScript>(); } } if (p1 == null || p2 == null) { return; } PlayerScript.FingerState p1finger = player1.MouseFingerDown(); PlayerScript.FingerState p2finger = player1.MouseFingerDown(); //Find out if they are touching... Vector3 v1 = p1.transform.position; Vector3 v2 = p2.transform.position; Vector3 vD = (v2 - v1); float difference = vD.magnitude; Vector3 halfwayPoint = v1 + (vD * 0.5f); transform.position = halfwayPoint; ParticleSystem psystem = GetComponent <ParticleSystem>(); if (difference < 50.0f && (p1finger == 0 || p2finger == 0)) { psystem.enableEmission = true; psystem.startSize += 10.0f; if (psystem.startSize > 20000) { psystem.startSize = 20000; } } else { psystem.startSize -= 50.0f; if (psystem.startSize < 10) { psystem.startSize = 10; } psystem.enableEmission = false; } }
void Update() { if (p1 == null) { p1 = GameObject.FindGameObjectWithTag("PLAYER1"); if (p1 != null) { player1 = p1.GetComponent <PlayerScript>(); } } if (p2 == null) { p2 = GameObject.FindGameObjectWithTag("PLAYER2"); if (p2 != null) { player2 = p2.GetComponent <PlayerScript>(); } } if (p1 == null || p2 == null) { return; } PlayerScript.FingerState p1finger = player1.MouseFingerDown(); PlayerScript.FingerState p2finger = player1.MouseFingerDown(); if (p1finger == PlayerScript.FingerState.None && p2finger == PlayerScript.FingerState.None) { return; } //Find out if they are touching... Vector2 v1 = p1.transform.position; Vector2 v2 = p2.transform.position; Vector2 vMiddle = v1 - v2; float difference = vMiddle.magnitude; if (difference < 150.0f) { if (InkBouncer != null) { Vector2 inkPos = InkBouncer.transform.position; float differenceToInk = (inkPos - vMiddle).magnitude; if (differenceToInk < 50) { InkBouncer.ReduceSpitRate(0.075f * Time.deltaTime); } } else if (InkBouncer == null) { GameLogicController.instance.MoveToNextLevel(); } } }
void Update() { if (p1 == null) { p1 = GameObject.FindGameObjectWithTag("PLAYER1"); if (p1 != null) { player1 = p1.GetComponent <PlayerScript>(); } } if (p2 == null) { p2 = GameObject.FindGameObjectWithTag("PLAYER2"); if (p2 != null) { player2 = p2.GetComponent <PlayerScript>(); } } if (p1 == null || p2 == null) { return; } PlayerScript.FingerState p1finger = player1.MouseFingerDown(); PlayerScript.FingerState p2finger = player1.MouseFingerDown(); if (p1finger == PlayerScript.FingerState.None && p2finger == PlayerScript.FingerState.None) { return; } //Find out if they are touching... Vector3 v1 = p1.transform.position; Vector3 v2 = p2.transform.position; float difference = (v1 - v2).magnitude; if (difference < 50.0f) { timeTogether += Time.deltaTime; if (timeTogether > 5.0f) { GameLogicController.instance.MoveToNextLevel(); } } else { timeTogether = 0.0f; } }
void FixedUpdate() { if (p1 == null) { p1 = GameObject.FindGameObjectWithTag("PLAYER1"); if (p1 != null) { player1 = p1.GetComponent <PlayerScript>(); } } if (p2 == null) { p2 = GameObject.FindGameObjectWithTag("PLAYER2"); if (p2 != null) { player2 = p2.GetComponent <PlayerScript>(); } } bool doInkLink = false; bool riverComplete = SoundBuoyScript.CheckForRiverCompletion(); if (p1 != null && p2 != null) { PlayerScript.FingerState p1finger = player1.MouseFingerDown(); PlayerScript.FingerState p2finger = player2.MouseFingerDown(); foreach (BlackHoleScript bh in BlackHoleScript.WorldBlackHoles) { if (Network.isServer) { player1.UpdateAgainstBlackHole(bh); } else if (Network.isClient) { player2.UpdateAgainstBlackHole(bh); } } bool canCreateRiverBetweenActivatedBuoys = false; int buoysWithFingersDownActivated = 0; //if(Network.isServer) { if (player1.DoLinkInk() && player1.DoLinkInk()) { SoundBuoyScript buoy1 = null; SoundBuoyScript buoy2 = null; float minDist = 160.0f; float best1 = 9999.0f; float best2 = 9999.0f; Vector2 p1v = player1.transform.position; Vector2 p2v = player2.transform.position; foreach (SoundBuoyScript sbs in SoundBuoyScript.WorldBuoysList) { Vector2 sbspos = sbs.transform.position; float mag1 = (sbspos - p1v).magnitude; float mag2 = (sbspos - p2v).magnitude; if (mag1 < minDist && mag1 < best1) { best1 = mag1; buoy1 = sbs; } if (mag2 < minDist && mag2 < best2) { best2 = mag2; buoy2 = sbs; } } if (buoy1 != null && buoy2 != null) { if (buoy1 != buoy2) { buoy1.ActivatedWithOther = buoy2; buoy2.ActivatedWithOther = buoy1; } } } } //Find out if they are touching... Vector3 v1 = p1.transform.position; Vector3 v2 = p2.transform.position; float difference = (v1 - v2).magnitude; if (difference < 50.0f) { if (p1finger == PlayerScript.FingerState.Single && p2finger == PlayerScript.FingerState.Single) { timeTogetherNotMoving += Time.deltaTime; } if (timeTogetherNotMoving > 1.0f && !playTogetherAudio) { playTogetherAudio = true; audio.Play(); } if (timeTogetherNotMoving > 5.0f) { playTogetherAudio = false; timeTogetherNotMoving = -5; ClearAllGameEntitiesOut(); //GameLogicController.instance.MoveToNextLevel(); //not anymore! } } else { if (playTogetherAudio) { playTogetherAudio = false; audio.Stop(); } if (timeTogetherNotMoving >= 1.0f) { player1.SetDoLinkInk(true); player2.SetDoLinkInk(true); } timeTogetherNotMoving = 0.0f; } if (p1finger != PlayerScript.FingerState.Single || p2finger != PlayerScript.FingerState.Single) { timeTogetherNotMoving = 0; player1.SetDoLinkInk(false); player2.SetDoLinkInk(false); } } }
void Update() { levelRunTime += Time.deltaTime; if (p1 == null) { p1 = GameObject.FindGameObjectWithTag("PLAYER1"); if (p1 != null) { player1 = p1.GetComponent <PlayerScript>(); } } if (p2 == null) { p2 = GameObject.FindGameObjectWithTag("PLAYER2"); if (p2 != null) { player2 = p2.GetComponent <PlayerScript>(); } } if (p1 == null || p2 == null) { return; } PlayerScript.FingerState p1finger = player1.MouseFingerDown(); PlayerScript.FingerState p2finger = player2.MouseFingerDown(); Vector2 v1 = player1.transform.position; Vector2 v2 = player2.transform.position; if (linkTimeEnabled > 0.0f && (p1finger == PlayerScript.FingerState.Single && p2finger == PlayerScript.FingerState.Single)) { player1.SetDoLinkInk(true); player2.SetDoLinkInk(true); } else { player1.SetDoLinkInk(false); player2.SetDoLinkInk(false); } linkTimeEnabled -= Time.deltaTime; if (linkTimeEnabled < 0) { linkTimeEnabled = 0; } GameObject[] connectors = GameObject.FindGameObjectsWithTag("line connector"); int id = 0; foreach (GameObject lc in connectors) { LineConnectorScript linesscript = lc.GetComponent <LineConnectorScript>(); Vector2 lcp = lc.transform.position; float dist1 = (lcp - v1).magnitude; float dist2 = (lcp - v2).magnitude; if (id == 0 && dist1 < 30) { linesscript.LineLinkEnabled = true; } else if (id == 0 && dist1 > 10) { linesscript.LineLinkEnabled = false; } if (id == 1 && dist2 < 30) { linesscript.LineLinkEnabled = true; } else if (id == 1 && dist2 > 10) { linesscript.LineLinkEnabled = false; } if (linesscript.LineLinkEnabled) { linkTimeEnabled = 5; } if (++id > 1) { id = 0; } } if (levelRunTime > 5.0f && connectors.Length == 0) { GameLogicController.instance.MoveToNextLevel(); } }
void FixedUpdate() { if (p1 == null) { p1 = GameObject.FindGameObjectWithTag("PLAYER1"); if (p1 != null) { player1 = p1.GetComponent <PlayerScript>(); } } if (p2 == null) { p2 = GameObject.FindGameObjectWithTag("PLAYER2"); if (p2 != null) { player2 = p2.GetComponent <PlayerScript>(); } } if (p1 == null) // || p2 == null) { return; } float dt = Time.fixedDeltaTime; timeSinceRang += dt; if (timeSinceRang < 10.0f) { } PlayerScript.FingerState p1finger = player1.MouseFingerDown(); //PlayerScript.FingerState p2finger = player1.MouseFingerDown(); int circles = NumCirclesAroundBuoy(); int newcircles = circles - numCirclesCompleted; numCirclesCompleted = circles; Vector2 vMe = transform.position; Vector2 v1 = p1.transform.position; //Vector2 v2 = p2.transform.position; //Vector3 scale = transform.localScale; //scale = Vector2.Lerp(scale, originalScale*(Mathf.Abs(Mathf.Cos(Time.realtimeSinceStartup*7)) * 1.3f + 0.4f), 3.0f*dt); //transform.localScale = scale; float increaseRate = 3.0f; float decreaseRate = 5.0f; Vector2 vBurstDirection = v1 - vMe; int cnt = WorldBuoysList.Count; //if(!SoundActivated && CheckForInkLineOverBuoy()) // SoundActivated = true; //if(!SoundActivated && circles > 5) // SoundActivated = true; float amountOfInkSuckedIn = fluidField.SuckInkInAt(vMe.x, vMe.y, 10); float invVolume = (amountOfInkSuckedIn / 2500.0f); audio.volume = invVolume * invVolume; //DebugStreamer.message = "amount sucked: " + amountOfInkSuckedIn.ToString(); /* * if(ActivatedWithOther != null) * { * timeActivated += dt; * if(timeActivated > 5.0f) * Submerge(); * Vector2 vOther = ActivatedWithOther.transform.position; * vBurstDirection = vOther-vMe; * float power = UnityEngine.Random.Range(0.0f, 0.065f); * if(submerged) * power *= 2.0f; * fluidField.DropVelocityInDirection(vMe.x, vMe.y, vBurstDirection.x, vBurstDirection.y, power); * sprite.color = Color.Lerp(sprite.color, new Color(0.3f, 0.1f, 1.0f, 1.0f), dt*increaseRate); * } * else * { * sprite.color = Color.Lerp(sprite.color, new Color(0.1f, 0.1f, 0.35f, 1.0f), dt*increaseRate); * } */ if (!submerged) { vBurstDirection.Normalize(); if (newcircles > 0) { //PlayRingingSound(); SetCurrentAnimation(3); } //for(int i = 0; i < newcircles; ++i) //{ // Network.Instantiate(flareTemplate, transform.position, Quaternion.identity, 0); // fluidField.DropVelocityInDirection(vMe.x, vMe.y, vBurstDirection.x, vBurstDirection.y, riverPower); //} } if (!submerged) { if (Network.isServer) { p1MovementPoints.Add(v1); if (p1finger == PlayerScript.FingerState.None) // && p2finger == PlayerScript.FingerState.None) { numCirclesCompleted = 0; p1MovementPoints.Clear(); } } else if (Network.isClient) { //p1MovementPoints.Add(v2); //if(p2finger == PlayerScript.FingerState.None)// && p2finger == PlayerScript.FingerState.None) { numCirclesCompleted = 0; p1MovementPoints.Clear(); } } if (p1MovementPoints.Count > 90) { p1MovementPoints.RemoveAt(0); //then remove the last one! } } }
public void UpdateMouses(float dt) { //System.Random rand = new System.Random(); Vector2[] playerScreenPos = new Vector2[2] { Vector2.zero, Vector2.zero }; Vector2[] playerWorldPos = new Vector2[2] { Vector2.zero, Vector2.zero }; int inkLinks = 0; float prevSad = amountOfSadness; float prevHap = amountOfHappiness; float prevAng = amountOfAngriness; amountOfSadness = 0; amountOfHappiness = 0; amountOfAngriness = 0; for (int m = 0; m < 2; ++m) { if (ownerPlayerMouseInfo[m].player == null) { continue; } if (ownerPlayerMouseInfo[m].playerScript.DoLinkInk()) { ++inkLinks; } playerWorldPos[m] = ownerPlayerMouseInfo[m].player.transform.position; Vector3 screenPos = camcam.WorldToViewportPoint(playerWorldPos[m]); playerScreenPos[m].x = screenPos.x; playerScreenPos[m].y = screenPos.y; if (ownerPlayerMouseInfo[m].playerScript.doInkBurst) { DoVelocityBurst(screenPos.x, screenPos.y, 10, 100); ownerPlayerMouseInfo[m].playerScript.doInkBurst = false; } amountOfSadness += ownerPlayerMouseInfo[m].playerScript.totalSadness; amountOfHappiness += ownerPlayerMouseInfo[m].playerScript.totalHappiness; amountOfAngriness += ownerPlayerMouseInfo[m].playerScript.totalAngriness; float mouseChangeX = ownerPlayerMouseInfo[m].previousScreenPos.x - screenPos.x; float mouseChangeY = ownerPlayerMouseInfo[m].previousScreenPos.y - screenPos.y; PlayerScript.FingerState curMouseState = ownerPlayerMouseInfo[m].playerScript.MouseFingerDown(); if (ownerPlayerMouseInfo[m].previousMouseState != curMouseState) { mouseChangeX = mouseChangeY = 0; ownerPlayerMouseInfo[m].previousMouseState = curMouseState; } ownerPlayerMouseInfo[m].previousScreenPos = screenPos; if (ownerPlayerMouseInfo[m].playerScript.MouseFingerDown() == PlayerScript.FingerState.None) { continue; } int chunkSize = N / ChunkFieldN; int mouseIterations = 10; float singlePass = 1.0f / (float)(mouseIterations - 1); for (int i = 0; i < mouseIterations; ++i) { float p = (float)i / (float)(mouseIterations - 1); float curScreenPosx = screenPos.x + (mouseChangeX * p); float curScreenPosy = screenPos.y + (mouseChangeY * p); int xCell = (int)(curScreenPosx * N); int yCell = (int)(curScreenPosy * N); int xChunk = (int)(xCell / chunkSize); int yChunk = (int)(yCell / chunkSize); if (xChunk >= 0 && xChunk < ChunkFieldN && yChunk >= 0 && yChunk < ChunkFieldN) { chunks[xChunk, yChunk].mouseTime += 2; } float mouseRadius = ownerPlayerMouseInfo[m].mouseRadius; float dx = mouseChangeX * -100 * singlePass; float dy = mouseChangeY * -100 * singlePass; float mousePower = 1.0f; float velPower = ownerPlayerMouseInfo[m].velocityFlow; float inkflow = ownerPlayerMouseInfo[m].inkFlow; UpdateBlackHole(curScreenPosx, curScreenPosy, dx, dy, mouseRadius, velPower, mousePower, inkflow, dt); } } if (amountOfSadness > 0.5f) { amountOfSadness *= 10; } if (amountOfHappiness > 0.5f) { amountOfHappiness *= 10; } if (amountOfAngriness > 0.5f) { amountOfAngriness *= 10; } amountOfSadness = Mathf.Lerp(prevSad, amountOfSadness, dt * 0.33f); amountOfHappiness = Mathf.Lerp(prevHap, amountOfHappiness, dt * 0.33f); amountOfAngriness = Mathf.Lerp(prevAng, amountOfAngriness, dt * 0.33f); if (inkLinks == 2) { float offset = 3; for (int i = 0; i < 5; ++i) { float frx1 = UnityEngine.Random.Range(-offset, offset); float fry1 = UnityEngine.Random.Range(-offset, offset); float frx2 = UnityEngine.Random.Range(-offset, offset); float fry2 = UnityEngine.Random.Range(-offset, offset); InkAlongLine(playerWorldPos[0].x + frx1, playerWorldPos[0].y + fry1, playerWorldPos[1].x + frx2, playerWorldPos[1].y + fry2); } } }