private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { TheSceneManager.getInstance().enterNextScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name, NextSceneName, BornPositionNum); SceneManager.LoadScene(NextSceneName); } }
static public TheSceneManager getInstance() { if (instance == null) { instance = new TheSceneManager(); return(instance); } return(instance); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); } else { _instance = this; } DontDestroyOnLoad(gameObject); }
private void Awake() { System.DateTime currentTime = new System.DateTime(); Random.InitState(currentTime.Millisecond); script1 = GameObject.Find("MainCamera").GetComponent <CameraFollow>(); script2 = GameObject.Find("MainCamera").GetComponent <CameraFollow_Start>(); instance = this; character = GameObject.Find("character"); character.transform.position = GameFunction.getVector3(BornPosition[TheSceneManager.getInstance().BornPositionNum].position.x, BornPosition[TheSceneManager.getInstance().BornPositionNum].position.y, -0.1f); // 更改位置 character.GetComponent <CharacterControl>().enabled = false; black = GameObject.Find("black"); script1.enabled = false; }
public override bool OnMouse(int button, int state, int x, int y) { if (button == Glut.GLUT_LEFT_BUTTON && state == Glut.GLUT_DOWN) { MouseWorld = ConvertScreenToWorldCoords(x, y, TheCamera.ViewMatrix, projectionMatrix, TheCamera.Position, TheRenderStatus); Vector3 playerMouseVec = (new Vector3(MouseWorld.x, 0.0, MouseWorld.z) - TheGameStatus.ThePlayer.Location).Normalize(); TheGameStatus.ThePlayer.Orientation = playerMouseVec; // TheGameStatus.ThePlayer.Orientation = new Vector(playerMouseVec.x, playerMouseVec.y); int mod = Glut.glutGetModifiers(); if (mod == Glut.GLUT_ACTIVE_CTRL) { TheSceneManager.TileSelected(MouseWorld); } } else if (button == Glut.GLUT_RIGHT_BUTTON) { // this method gets called whenever a new mouse button event happens mouseDown = (state == Glut.GLUT_DOWN); // if the mouse has just been clicked then we hide the cursor and store the position if (mouseDown) { Glut.glutSetCursor(Glut.GLUT_CURSOR_NONE); prevX = downX = x; prevY = downY = y; } else // unhide the cursor if the mouse has just been released { Glut.glutSetCursor(Glut.GLUT_CURSOR_LEFT_ARROW); Glut.glutWarpPointer(downX, downY); } } return(true); }