// Update is called once per frame void Update() { foregroundSpriteJD.ResetAnchors(); foregroundSpritePolimi.ResetAnchors(); foregroundSpriteJD.UpdateAnchors(); foregroundSpritePolimi.UpdateAnchors(); if (Time.timeSinceLevelLoad > 6.0f && !started) { backgrounSprite.color = Color.white; foregroundSpritePolimi.alpha = 0f; foregroundSpriteJD.alpha = 1f; uiCamera.audio.Play(); started = true; } if (InputMapping.GetAction(Actions.Skip) > 0) { Application.LoadLevel("LevelSelectionMenu"); } if (Input.GetMouseButtonDown(0)) { Application.LoadLevel("LevelSelectionMenu"); } if (!uiCamera.audio.isPlaying && started) { Application.LoadLevel("LevelSelectionMenu"); } }
void Update() { if (InputMapping.GetAction(Actions.Quit) > 0) { Application.LoadLevel("Abouts"); } }
// Update is called once per frame void Update() { if (InputMapping.GetAction(Actions.Quit) > 0 || InputMapping.GetAction(Actions.Skip) > 0) { Application.Quit(); } }
void Rotate() { Vector3 rotation = new Vector3(0, 0, 0); if (InputMapping.GetAction(Actions.RotateEnabled) > 0) { rotation.x -= InputMapping.GetAction(Actions.RotateHorizontal) * rotationAngle; rotation.y += InputMapping.GetAction(Actions.RotateVertical) * rotationAngle; rotation.z = 0; Vector3 interpolatedRotation = Vector3.Slerp(transform.eulerAngles, transform.eulerAngles + rotation, Time.deltaTime * rotationSpeed); if (interpolatedRotation.x <= minAngleX || interpolatedRotation.x >= maxAngleX) { distFromMin = interpolatedRotation.x - minAngleX; distFromMax = interpolatedRotation.x - maxAngleX; if (distFromMin < 0) { distFromMin *= -1; } if (distFromMax < 0) { distFromMax *= -1; } if (distFromMin >= distFromMax) { interpolatedRotation.x = maxAngleX; } else { interpolatedRotation.x = minAngleX; } } //Debug.Log(interpolatedRotation.x); transform.eulerAngles = interpolatedRotation; } }
void Update() { if ((InputMapping.GetAction(Actions.Use) > 0) && !menuCamera.isRunning) { ChangeLevel(); } if (running) { return; } GameManager.NextScene = sceneName; /* * try * { * //Pass the filepath and filename to the StreamWriter Constructor * StreamWriter sw = new StreamWriter(path, false); * * //Write a line of text * sw.WriteLine(sceneName); * sw.Flush(); * * //Close the file * sw.Close(); * } * catch (Exception e) * { * Debug.Log("Exception in WriteFile" + e.Message); * } */ if (Application.GetStreamProgressForLevel("LoadingScreen") == 1) { Application.LoadLevel("LoadingScreen"); } }
void Update() { //souls = GlobalManager.globalManager.souls; if (ready) { //PREVIEW ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); var zoomLevel = cameraControl.zoomLevel; distance = ((zoomLevel) * cameraZoomScaleFactor); Location.x = ray.origin.x + (ray.direction.x * distance); Location.y = 0; Location.z = ray.origin.z + (ray.direction.z * distance); transform.position = Location; particleEffect.transform.position = new Vector3(particleEffect.transform.position.x, 17.5f, particleEffect.transform.position.z); //Debug.Log(InputMapping.GetAction(Actions.Use)); if ((InputMapping.GetAction(Actions.Use) > 0) && enableUse) { Debug.Log(InputMapping.GetAction(Actions.Use)); Vector3 clickPosition = InputMapping.GetActionPosition(Actions.Use); if (clickPosition != Vector3.zero) { ray = Camera.main.ScreenPointToRay(clickPosition); RaycastHit hit; int layerMask = 1 << 10 | 1 << 2; layerMask = ~layerMask; Debug.Log(layerMask); if (Physics.Raycast(ray, out hit, 1000, layerMask)) { //Debug.DrawRay(ray.origin, ray.direction, Color.blue, 100f); //Debug.Log("hit ray " + hit.transform.tag); } else { //Debug.Log("NO"); Debug.Log(hit.point.ToString()); } Location.x = hit.point.x; Location.y = 0; Location.z = hit.point.z; transform.position = Location; //Debug.Log(Location); particleEffect.transform.position = new Vector3(particleEffect.transform.position.x, 17.5f, particleEffect.transform.position.z); } ready = false; previousParticlePosY = particleEffect.transform.position.y; } } else { particleEffect.transform.position = particleEffect.transform.position + Vector3.down * speed * Time.deltaTime; //transform.position = transform.position; if (particleEffect.transform.position.y <= -10f) { ready = true; particleEffect.transform.position = new Vector3(Location.x, previousParticlePosY, Location.z); GlobalManager.globalManager.decrementSouls(price); } } }
// Update is called once per frame void Update() { dt = Time.deltaTime; time += dt; if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 0) { if (time >= messagePass) { messageLabel.text = "You are a GOD!!! But these people are not adoring you."; messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 1) { if (time >= messagePass) { if (LevelGUI.levelGUI.isDisplayingMessages()) { LevelGUI.levelGUI.clearMessages(); } if (controllerType == "Xbox360Pad") { messageLabel.text = "Look at them just laughing. To zoom press Left Trigger."; } else { messageLabel.text = "Look at them just laughing. To zoom press Q."; } //LevelGUI.levelGUI.WriteMessage("Look at them just laughing.",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("To zoom press Q.",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0 || InputMapping.GetAction(Actions.Zoom) > 0) && messageCount == 2) { if (time >= messagePass) { if (LevelGUI.levelGUI.isDisplayingMessages()) { LevelGUI.levelGUI.clearMessages(); } if (controllerType == "Xbox360Pad") { messageLabel.text = "Good, you can zoom back with Right Trigger. You should use your powers to teach them who's the boss."; } else { messageLabel.text = "Good, you can zoom back with E. You should use your powers to teach them who's the boss."; } //LevelGUI.levelGUI.WriteMessage("Good, you can zoom back with E.",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("You should use your powers to teach them who's the boss.",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0 || InputMapping.GetAction(Actions.Zoom) < 0) && messageCount == 3) { if (time >= messagePass) { messageLabel.text = "Ok, let's try a little FIRE!!"; //LevelGUI.levelGUI.WriteMessage("Ok, let's try a little FIRE!!",1.7f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 4) { if (time >= messagePass) { GlobalManager.globalManager.incrementSouls(5); firePower.powerState = PowerState.Disabled; PowersManager.powersManager.refreshPowersStates(GlobalManager.globalManager.souls); ((BasePowerDealer)firePower).enableUse = false; if (controllerType == "Xbox360Pad") { messageLabel.text = "Press X to select FIRE! Use the analog stick to move the god ray to your target."; } else { messageLabel.text = "Press Number 1 to select FIRE! Use the arrows to move the god ray to your target."; } //LevelGUI.levelGUI.WriteMessage("Press Number 1 to select FIRE!",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("Use the arrows to move the god ray to your target.",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if (messageCount == 5 && PowersManager.powersManager.SelectedPower == firePower) { if (time >= messagePass) { ((BasePowerDealer)firePower).enableUse = true; if (controllerType == "Xbox360Pad") { messageLabel.text = "Good! Now burn the unworthy. Press A to use your Power."; } else { messageLabel.text = "Good! Now burn the unworthy. Press SPACE to use your Power."; } //LevelGUI.levelGUI.WriteMessage("Good! Now burn the unworthy.",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("Press SPACE to use your Power.",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if (messageCount == 6 && GlobalManager.globalManager.population <= 1) { messageCount++; } if (messageCount == 7) { messageLabel.text = "HAHAHAHAHHAHAHAHAHAHAHA..."; //LevelGUI.levelGUI.WriteMessage("HAHAHAHAHHAHAHAHAHAHAHA...",1.7f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; } if (messageCount == 6 && GlobalManager.globalManager.souls < 5 && GlobalManager.globalManager.population > 1 && firstTze.ActivePower == null && secondTze.ActivePower == null) { messageLabel.text = "You missed. Did you not?"; //LevelGUI.levelGUI.WriteMessage("You missed. Did you not?",1.7f,0.25f,0f,LevelGUI.sBlue,true); messageCount = 20; time = 0; } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 8) { if (time >= messagePass) { messageLabel.text = "Sorry, I got carried away."; //LevelGUI.levelGUI.WriteMessage("Sorry, I got carried away",1.7f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if (messageCount == 20 && GlobalManager.globalManager.population >= 1 && GlobalManager.globalManager.souls <= 7) { if (time >= 5f) { if (controllerType == "Xbox360Pad") { messageLabel.text = "Do not worry. You can Redo the level any time. Press the Redo button up in the left or the back button on your controller."; } else { messageLabel.text = "Do not worry. You can Redo the level any time. Press the Redo button up in the left, or the R button on your keyboard."; } //LevelGUI.levelGUI.WriteMessage("Do not worry. You can Redo the level any time",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("Press the Redo button up in the left",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 9) { if (time >= messagePass) { ((BasePowerDealer)firePower).enableUse = false; messageLabel.text = "However be aware! When you use your powers you use SOULS. The number of SOULS you own is up there with the crosses."; //LevelGUI.levelGUI.WriteMessage("However be aware! When you use your powers you use SOULS",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("The number of SOULS you own is up there with the crosses",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 10) { if (time >= messagePass) { messageLabel.text = "You have a limited number of SOULS. But with each infidel dead you get his sins weight in SOULS."; //LevelGUI.levelGUI.WriteMessage("You have a limited number of SOULS",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("But with each infidel dead you get his sins weight in SOULS",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 11) { if (time >= messagePass) { messageLabel.text = "Some will be worth more of your time, some less. It depends on their actions, and yours. These guys are worth 3 souls each."; //LevelGUI.levelGUI.WriteMessage("Some will be worth more of your time, some less",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("It depends on their actions, and Yours. These guys worth 3 souls each",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 12) { if (time >= messagePass) { messageLabel.text = "The cost of the Powers is stated next to it. You can use some extra SOULS this time."; //LevelGUI.levelGUI.WriteMessage("The cost of the Powers is stated next to it",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("You can use some extra SOULS this time",1.8f,0.25f,0f,LevelGUI.sBlue,true); GlobalManager.globalManager.incrementSouls(8); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 13) { if (time >= messagePass) { if (GlobalManager.globalManager.population > 0) { ((BasePowerDealer)firePower).enableUse = true; messageLabel.text = "Now, Do me a favor and kill that other guy too."; //LevelGUI.levelGUI.WriteMessage("Now, Do me a favor and kill that other infidel too.",1.7f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; } else { messageLabel.text = "Now, Do me a favor and kill that other guy too."; //LevelGUI.levelGUI.WriteMessage("Nice!! you got 2 for 1",1.7f,0.25f,0f,LevelGUI.sBlue,true); messageCount += 2; } time = 0; } } if (GlobalManager.globalManager.population == 0 && messageCount == 14) { if (time >= messagePass) { messageLabel.text = "Good Job!!!"; //LevelGUI.levelGUI.WriteMessage("Good Job!!!",1.7f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if (messageCount == 14 && GlobalManager.globalManager.population > 0 && GlobalManager.globalManager.souls < 5) { if (time >= 5f) { messageCount = 20; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 15) { if (time >= messagePass) { messageLabel.text = "Great Work !!! You managed to kill all the infidels. Now, let's go learn some more ."; //LevelGUI.levelGUI.WriteMessage("Great Work !!! You managed to kill all the infidels.",1.7f,0.25f,0f,LevelGUI.sBlue,true); //LevelGUI.levelGUI.WriteMessage("Now, let's go kill some more people",1.8f,0.25f,0f,LevelGUI.sBlue,true); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 16) { if (time >= messagePass) { Application.LoadLevel("TutorialRage"); } } }
void Update() { if (messages != null) { for (int i = 0; i < messages.Count; i++) { if (messages[i].duration > 0) { messages[i].timer += Time.deltaTime; if (messages[i].timer >= messages[i].duration) { messages[i].text.text = ""; messages.Remove(messages[i]); } } } } //Joystick Controls if (InputMapping.GetAction(Actions.PowerNext) == 1f) { simulatePowerButtonPress(powerJoy); powerJoy++; if (powerJoy >= PowersManager.length) { powerJoy = 0; } simulatePowerButtonPress(powerJoy); } if (InputMapping.GetAction(Actions.PowerPrev) == 1f) { simulatePowerButtonPress(powerJoy); powerJoy--; if (powerJoy < 0) { powerJoy = PowersManager.length - 1; } simulatePowerButtonPress(powerJoy); } if (InputMapping.GetAction(Actions.Retry) > 0) { Application.LoadLevel(Application.loadedLevel); } if (InputMapping.GetAction(Actions.Quit) > 0) { Application.LoadLevel("LevelSelectionMenu"); } if (InputMapping.GetAction(Actions.Power0) > 0) { simulatePowerButtonPress(0); } if (InputMapping.GetAction(Actions.Power1) > 0) { simulatePowerButtonPress(1); } if (InputMapping.GetAction(Actions.Power2) > 0) { simulatePowerButtonPress(2); } if (InputMapping.GetAction(Actions.Power3) > 0) { simulatePowerButtonPress(3); } if (InputMapping.GetAction(Actions.Power4) > 0) { simulatePowerButtonPress(4); } if (InputMapping.GetAction(Actions.Power5) > 0) { simulatePowerButtonPress(5); } if (InputMapping.GetAction(Actions.Power6) > 0) { simulatePowerButtonPress(6); } if (InputMapping.GetAction(Actions.Power7) > 0) { simulatePowerButtonPress(7); } if (InputMapping.GetAction(Actions.Power8) > 0) { simulatePowerButtonPress(8); } }
// Update is called once per frame void Update() { dt = Time.deltaTime; time += dt; if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 0) { if (time >= messagePass) { tutorialLabel.text = "But first take a look at the people. Have you noticed the red and blue balls hovering over their bodies ?"; //WriteMessage("But first take a look at the people.",1.7f,0.25f,9f); //WriteMessage("Have you noticed the red and blue balls hovering over their useless bodies ?",1.8f,0.25f,9f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 1) { if (time >= messagePass) { tutorialLabel.text = "This means that they are worshipping another god. It is obvious that you must kill them, but is not gonna be so easy."; //WriteMessage("This means that they are worshipping another god.",1.7f,0.25f,9f); //WriteMessage("It is obvious that you must kill them, but is not gonna be so easy",1.8f,0.25f,9f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 2) { if (time >= messagePass) { tutorialLabel.text = "You cannot hurt the man marked by the blue sphere. And if you kill the man with the red ball you will lose 6 souls."; //WriteMessage("You cannot hurt the man marked by the blue sphere.",1.7f,0.25f,9f); //WriteMessage("And if you kill the man with the red ball you will lose 6 souls.",1.8f,0.25f,9f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 3) { if (time >= messagePass) { tutorialLabel.text = "You still can kill them using your indirect powers. With Rage you can use a human to kill others without killing him."; //WriteMessage("You still can kill them using your indirect powers.",1.7f,0.25f,9f); //WriteMessage("With Rage you can use a human to kill others without killing him.",1.8f,0.25f,9f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 4) { if (time >= messagePass) { GlobalManager.globalManager.incrementSouls(10); ragePower.powerState = PowerState.Disabled; PowersManager.powersManager.refreshPowersStates(GlobalManager.globalManager.souls); ((BasePowerDealer)ragePower).enableUse = false; if (controllerType == "Xbox360Pad") { tutorialLabel.text = "Press the X button until RAGE is selcted!"; } else { tutorialLabel.text = "Press Number 4 to select RAGE!"; } //WriteMessage("Press Number 4 to select RAGE!",1.7f,0.25f,0f); messageCount++; time = 0; } } if (messageCount == 5 && PowersManager.powersManager.SelectedPower == ragePower) { if (time >= messagePass) { ((BasePowerDealer)ragePower).enableUse = true; if (controllerType == "Xbox360Pad") { tutorialLabel.text = "Target the one with the red orb. Press A to use your Power."; } else { tutorialLabel.text = "Target the one with the red orb. Press SPACE to use your Power."; } //WriteMessage("Target the one with the red orb",1.7f,0.25f,0f); //WriteMessage("Press SPACE to use your Power.",1.8f,0.25f,0f); messageCount++; time = 0; } } if (messageCount == 6 && GlobalManager.globalManager.population <= 2) { messageCount++; } if (messageCount == 7) { tutorialLabel.text = "Perfect!! Let the RAGE flow through you"; //WriteMessage("Perfect!! Let the RAGE flow through you",1.7f,0.25f,0f); messageCount++; } if (messageCount == 20 && GlobalManager.globalManager.population >= 1 && GlobalManager.globalManager.souls <= 5) { if (time >= 10f) { if (controllerType == "Xbox360Pad") { tutorialLabel.text = "Do not worry. You can Redo the level any time. Press the Redo button up in the left, or the Back button on your controller."; } else { tutorialLabel.text = "Do not worry. You can Redo the level any time. Press the Redo button up in the left."; } //WriteMessage("Do not worry. You can Redo the level any time",1.7f,0.25f,0f); //WriteMessage("Press the Redo button up in the left",1.8f,0.25f,0f); messageCount++; } } if (messageCount == 6 && GlobalManager.globalManager.souls < 5 && GlobalManager.globalManager.population > 2 && firstTze.ActivePower == null && secondTze.ActivePower == null) { tutorialLabel.text = "You missed. Did you not?"; //WriteMessage("You missed. Did you not?",1.7f,0.25f,0f); messageCount = 20; time = 0; } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 8) { if (time >= messagePass) { tutorialLabel.text = "Now, to the other powers. Lightning (1) will kill immediately with an electric shock."; //WriteMessage("Now, to the other powers",1.7f,0.25f,0f); //WriteMessage("Lightning (2) will kill inmediately with an electric shock",1.8f,0.25f,10f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 9) { if (time >= messagePass) { tutorialLabel.text = "CALM (2) make people stay still. It is a support power, it takes Rage away."; //WriteMessage("ZOMBIE (3) will create a shiny new zombie.",1.7f,0.25f,0f); //WriteMessage("Be aware though that zombie decay and die very fast with no food",1.8f,0.25f,10f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 10) { if (time >= messagePass) { tutorialLabel.text = "ZOMBIE (3) will create a shiny new zombie. Be aware though that zombie decay and die very fast with no food"; //WriteMessage("CALM (5) make people stay still.",1.7f,0.25f,0f); //WriteMessage("It is a support power, it takes Rage away",1.8f,0.25f,10f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 11) { if (time >= messagePass) { GlobalManager.globalManager.incrementSouls(10); foreach (var power in PowersManager.powersManager.powers) { power.powerState = PowerState.Disabled; } PowersManager.powersManager.refreshPowersStates(GlobalManager.globalManager.souls); tutorialLabel.text = "Ok, now you got 10 extra souls. Judge everyone, will ya."; //WriteMessage("Ok, now you got 10 extra souls.",1.7f,0.25f,0f); //WriteMessage("Judge everyone, will ya",1.8f,0.25f,0f); messageCount++; time = 0; } } if (messageCount == 12 && GlobalManager.globalManager.population == 0) { if (time >= messagePass) { GlobalManager.globalManager.incrementSouls(10); tutorialLabel.text = "You have killed them all !! Very good, I think you'll like what's coming next."; //WriteMessage("You have killed them all",1.7f,0.25f,0f); //WriteMessage("Very good, I think you'll like what's coming next",1.8f,0.25f,0f); messageCount++; time = 0; } } if ((InputMapping.GetAction(Actions.Skip) > 0) && messageCount == 13) { Application.LoadLevel("City"); } }
void Move() { Vector3 direction = new Vector3(0, 0, 0); Vector3 origin = transform.position; direction.x = InputMapping.GetAction(Actions.Horizontal) * horizontalMovement; direction.z = InputMapping.GetAction(Actions.Vertical) * verticalMovement; var rotation = transform.rotation; transform.Rotate(new Vector3(-rotation.eulerAngles.x, 0, 0)); if (!debugNoRaycast && direction.x != 0 && direction.x > 0 && Physics.Raycast(new Ray(transform.position, transform.TransformDirection(Vector3.right)), rayLenght)) { direction.x = 0; if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.right), Color.red); } } else if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.right)); } if (!debugNoRaycast && direction.x != 0 && direction.x < 0 && Physics.Raycast(new Ray(transform.position, transform.TransformDirection(Vector3.left)), rayLenght)) { direction.x = 0; if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.left), Color.red); } } else if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.left)); } if (!debugNoRaycast && direction.z != 0 && direction.z > 0 && Physics.Raycast(new Ray(transform.position, transform.TransformDirection(Vector3.forward)), rayLenght)) { direction.z = 0; if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward), Color.red); } } else if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward)); } if (!debugNoRaycast && direction.z != 0 && direction.z < 0 && Physics.Raycast(new Ray(transform.position, transform.TransformDirection(Vector3.back)), rayLenght)) { direction.z = 0; if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.back), Color.red); } } else if (debugDraw) { Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.back)); } Vector3 movement = transform.TransformDirection(direction); //movement.y = Input.GetAxis("Mouse ScrollWheel") * zoomAmount * -1; //if(movement.y == 0) movement.y = InputMapping.GetAction(Actions.Zoom) * zoomAmount * -1; if (!debugNoRaycast && movement.y != 0 && movement.y < 0 && Physics.Raycast(new Ray(transform.position, Vector3.down), rayLenght)) { movement.y = 0; } if (!debugNoRaycast && movement.y != 0 && movement.y > 0 && Physics.Raycast(new Ray(transform.position, Vector3.up), rayLenght)) { movement.y = 0; } Vector3 destination = origin + movement; transform.rotation = rotation; transform.position = Vector3.MoveTowards(origin, destination, Time.deltaTime * speed); if (transform.position.y != origin.y) { zoomLevel = zoomLevel + ((transform.position.y - origin.y) * 1.15f); } }
void Update() { if (running) { return; } direction = new Vector3(0, 0, 0); origin = transform.position; float movement = InputMapping.GetAction(Actions.Horizontal); //Input.GetAxis("Horizontal"); // Debug.Log (movement); if (movement == 0) { return; } else if (movement > 0) { ++selectedIsland; if (selectedIsland > numberOfIsles - 1) { selectedIsland--; return; } selectors[selectedIsland - 1].SetActive(false); } else if (movement < 0) { selectors[selectedIsland].SetActive(false); --selectedIsland; if (selectedIsland < 0) { selectedIsland = 0; return; } selectors[selectedIsland + 1].SetActive(false); } if (selectedIsland == 0) { corner = LevelCorner.Left; } else if (selectedIsland == numberOfIsles - 1) { corner = LevelCorner.Right; } else { corner = LevelCorner.None; } running = true; tweenPos.from = origin; tweenPos.to = new Vector3(islands[selectedIsland].transform.position.x, origin.y, islands[selectedIsland].transform.position.z); tweenPos.ResetToBeginning(); tweenPos.onFinished.Clear(); previousIsland = currentIsland; currentIsland = islands[selectedIsland].GetComponent <IslandDescriptor>(); if (islandTransitionStart != null) { islandTransitionStart(previousIsland, currentIsland, corner); } EventDelegate.Add(tweenPos.onFinished, OnTweenFinished); tweenPos.PlayForward(); }