public void OnUpdate() { float MAXDIST = Distance; float dist = gameObject.transform.position.Distance(fx.gameObject.transform.position); dist = MAXDIST - MMath.Clamp(dist, 0.0f, MAXDIST); fx.mBlockThreshold = dist / MAXDIST; fx.mLineThreshold = (dist / MAXDIST) * 2.0f; }
public Vector3 GetBoundsOnSphere() { float x = MMath.GetRandomFloat() * zone.width + zone.GetLeftBound(); float y = MMath.GetRandomFloat() * zone.height + zone.GetBottomBound(); float z = MMath.GetRandomFloat() * zone.depth + zone.GetFrontBound(); x = MMath.Clamp(x, zone.GetLeftBound(), zone.GetRightBound()); y = MMath.Clamp(y, zone.GetBottomBound(), zone.GetTopBound()); z = MMath.Clamp(z, zone.GetFrontBound(), zone.GetBackBound()); return(new Vector3(x, y, z)); }
public void OnUpdate() { // Vector3 camPos = playerCamera.transform.position; // Vector3 camDir = (Vector3)playerCamera.transform.GetForwardVector(); // gameObject.transform.SetPosition(camDir + camPos); // gameObject.transform.LookAt(camPos); // have the cursor look back at camera #if ZERO MouseVec = Cursor.transform.GetGlobalPosition().Sub(ocuCam.gameObject.transform.position); MouseVec.Normalize(); gameObject.transform.SetPositionX(MMath.Clamp(gameObject.transform.position.x, -1.54f, 2.5f)); gameObject.transform.SetPositionY(MMath.Clamp(gameObject.transform.position.y, 0.89f, 2.5f)); //Renderer.getInstance().DrawLine(MouseVec.Add(gameObject.transform.position), gameObject.transform.position, col); //Cursor.LookAt(gameObject); //float angle = zAxis.Dot(MouseVec) / MouseLength; //if(Math.Abs(Math.Acos(angle)) <= .3f) //{ gameObject.transform.Translate(Input.GetMouseDeltaX() * FrameController.DT() * .025f, -Input.GetMouseDeltaY() * FrameController.DT() * .025f, 0); //} GameObject gobj = PhysicEngine.getInstance().RayCast3DWithTag(ocuCam.gameObject.transform.position, MouseVec, 10000.0f, "Raycast"); if (Input.GetHeld(0, "MouseRClick") == 1.0f) { if (gobj != null) { Invoke(gobj, "OnMouseHeld", false); } } if (Input.GetReleased(0, "MouseLClick") == 1.0f) { //un click paper if currently there is one up if (PaperViewer.isPaperSelected) { paperViewer.TransitionDown(); return; } if (gobj != null) { if (gobj.GetID() == PickCam1.GetID()) { MapScreen.mMaterial.SetTexture("map_lvl1_cam1.png"); SurvCam.FoVmodifier(1.5f); SurvCam.gameObject.transform.SetPosition(-4.58f, 3.38f, -5.06f); SurvCam.gameObject.transform.rotation.Angles.x = .62f; SurvCam.gameObject.transform.rotation.Angles.y = .85f; SurvCam.gameObject.transform.rotation.Angles.z = -.47f; } else if (gobj.GetID() == PickCam2.GetID()) { MapScreen.mMaterial.SetTexture("map_lvl1_cam2.png"); SurvCam.FoVmodifier(1.7f); SurvCam.gameObject.transform.SetPosition(-17.05f, 7.48f, 47.15f); SurvCam.gameObject.transform.rotation.Angles.x = .48f; SurvCam.gameObject.transform.rotation.Angles.y = .80f; SurvCam.gameObject.transform.rotation.Angles.z = -.31f; } else if (gobj.GetID() == PickCam3.GetID()) { MapScreen.mMaterial.SetTexture("map_lvl1_cam3.png"); SurvCam.FoVmodifier(1.5f); SurvCam.gameObject.transform.SetPosition(-3.65f, 5.94f, 88.70f); SurvCam.gameObject.transform.rotation.Angles.x = .54f; SurvCam.gameObject.transform.rotation.Angles.y = .58f; SurvCam.gameObject.transform.rotation.Angles.z = -.27f; } else if (gobj.GetID() == PickCam4.GetID()) { MapScreen.mMaterial.SetTexture("map_lvl2_cam1.png"); SurvCam.FoVmodifier(1.7f); SurvCam.gameObject.transform.SetPosition(-31.73f, 45.63f, 144.12f); SurvCam.gameObject.transform.rotation.Angles.x = -.53f; SurvCam.gameObject.transform.rotation.Angles.y = 2.49f; SurvCam.gameObject.transform.rotation.Angles.z = .24f; } else if (gobj.GetID() == PickCam5.GetID()) { MapScreen.mMaterial.SetTexture("map_lvl2_cam3.png"); SurvCam.FoVmodifier(1.4f); SurvCam.gameObject.transform.SetPosition(-42.57f, 41.39f, 159.66f); SurvCam.gameObject.transform.rotation.Angles.x = -.46f; SurvCam.gameObject.transform.rotation.Angles.y = 2.59f; SurvCam.gameObject.transform.rotation.Angles.z = .36f; } else if (gobj.GetID() == PickCam6.GetID()) { MapScreen.mMaterial.SetTexture("map_lvl2_cam2.png"); SurvCam.FoVmodifier(1.2f); SurvCam.gameObject.transform.SetPosition(2.48f, 41.47f, 159.75f); SurvCam.gameObject.transform.rotation.Angles.x = -.66f; SurvCam.gameObject.transform.rotation.Angles.y = 4.03f; SurvCam.gameObject.transform.rotation.Angles.z = -.51f; } else { //set paper if it's a paper if (gobj.GetFlag("Paper")) { GetScript <Paper>(gobj).Set(); } else { Invoke(gobj, "OnClicked", false); } } } } #endif }
public void OnUpdate() { timer += FrameController.DT(); float scaletimer = timer + FrameController.DT(); //slowly modulate speed speedmod = (float)Math.Sin(scaletimer * 0.7f) + 2.0f; //gameObject.transform.scale = new Vector3(speedmod*0.1f); float timermod = Math.Abs((float)Math.Sin(scaletimer * 0.1f)) + 8.0f; timer += FrameController.DT() * timermod; if (!target.HasValue) { target = GetBoundsOnSphere(); } else { gameObject.transform.SetPosition(MMath.LerpVector(beginPos, target.Value, timer)); if (timer > 1.0f) { beginPos = gameObject.transform.position; timer = 0; target = null; sound.PlayIndependentEvent("RC_CAR_MOVE.vente", false, 1); } } const float MAXDIST = 7.0f; float dist = gameObject.transform.position.Distance(fx.gameObject.transform.position); dist = MAXDIST - MMath.Clamp(dist, 0.0f, MAXDIST); fx.mBlockThreshold = dist / MAXDIST; fx.mLineThreshold = (dist / MAXDIST) * 2.0f; /* * if (!zone.IsPointWithin(gameObject.transform.position)) * { * float rand_var_x = 1.0f;//(((float)rand.NextDouble()-0.5f)*0.9f) + 1.0f; * float rand_var_y = 1.0f;//(((float)rand.NextDouble()-0.5f)*0.9f) + 1.0f; * float rand_var_z = 1.0f;//(((float)rand.NextDouble()-0.5f)*0.9f) + 1.0f; * Vector3 newSpeed = new Vector3(); * newSpeed.X = -speed.X * rand_var_x; * newSpeed.Z = -speed.Z * rand_var_z; * newSpeed.Y = -speed.Y * rand_var_y; * * newSpeed.Normalize(); * speed.Normalize(); * * speed = newSpeed; * * gameObject.transform.Translate(speed); * } * * if (speed.X > 0) * speed.X = MMath.Clamp(speed.X, 0.1f, 0.7f); * else * speed.X = MMath.Clamp(speed.X, -0.1f, -0.7f); * if (speed.Y > 0) * speed.Y = MMath.Clamp(speed.Y, 0.1f, 0.7f); * else * speed.Y = MMath.Clamp(speed.Y, -0.1f, -0.7f); * if (speed.Z > 0) * speed.Z = MMath.Clamp(speed.Z, 0.1f, 0.7f); * else * speed.Z = MMath.Clamp(speed.Z, -0.1f, -0.7f); * * * gameObject.transform.Translate(speed*speedmod); */ }