public static void Update() { //左右移动 if (Input.GetAxis("Horizontal") < 0 && Input.GetAxis("Horizontal") <= lastHorizontal) { ThreadEventList.GetList(MainThread.ThreadId, GameThread.ThreadId).AddEvent(ThreadEvent.Create(ControlInputEvent.LEFT)); } if (Input.GetAxis("Horizontal") > 0 && Input.GetAxis("Horizontal") >= lastHorizontal) { ThreadEventList.GetList(MainThread.ThreadId, GameThread.ThreadId).AddEvent(ThreadEvent.Create(ControlInputEvent.RIGHT)); } lastHorizontal = Input.GetAxis("Horizontal"); //上下移动 if (Input.GetAxis("Vertical") < 0 && Input.GetAxis("Vertical") <= lastVertical) { ThreadEventList.GetList(MainThread.ThreadId, GameThread.ThreadId).AddEvent(ThreadEvent.Create(ControlInputEvent.DOWN)); } if (Input.GetAxis("Vertical") > 0 && Input.GetAxis("Vertical") >= lastVertical) { ThreadEventList.GetList(MainThread.ThreadId, GameThread.ThreadId).AddEvent(ThreadEvent.Create(ControlInputEvent.UP)); } lastVertical = Input.GetAxis("Horizontal"); //跳跃 if (Input.GetAxis("Jump") != 0 && lastJump == 0) { ThreadEventList.GetList(MainThread.ThreadId, GameThread.ThreadId).AddEvent(ThreadEvent.Create(ControlInputEvent.JUMP)); } lastJump = Input.GetAxis("Jump"); }
/// <summary> /// 检测是否有放不下的 /// </summary> private void CheckOut() { List <LevelConfig> levels = LevelConfig.Configs; for (int i = 0; i < levels.Count; i++) { ThreadEvent te = ThreadEvent.Create("check", levels[i]); te.URL = "gameLevel/level1/SceneBackground"; ThreadEventList.GetList(EditorMainThread.ThreadId, CheckThread.ThreadId).AddEvent(te); } }
public void Start() { //初始化数据模型 GameData data = new GameData(); //计算镜头实际大小 Camera camera = StartUp.Instance.mainCamera; Vector3 size = new Vector3(); size = camera.ViewportToWorldPoint(size); data.camera.Size = new Point2D(size.x, size.y); AddListener(CameraEvent.INIT, OnInitCamera); AddListener(ControlInputEvent.LEFT, OnControl); AddListener(ControlInputEvent.RIGHT, OnControl); AddListener(ControlInputEvent.UP, OnControl); AddListener(ControlInputEvent.DOWN, OnControl); ThreadEvent te = ThreadEvent.Create(ThreadEvent.CREATE_PREFAB); te.URL = "gameLevel/level1/SceneBackground"; ThreadEventList.GetList(GameThread.ThreadId, MainThread.ThreadId).AddEvent(te); }
private void Awake() { Instance = this; mainCamera = StartUp.Instance.mainCamera; cameraSize = new Vector3(); cameraSize = mainCamera.ViewportToWorldPoint(cameraSize); cameraSize.x = Mathf.Abs(cameraSize.x); cameraSize.y = Mathf.Abs(cameraSize.y); GameLayer[] layers = gameObject.GetComponentsInChildren <GameLayer>(); for (int i = 0; i < layers.Length; i++) { //计算镜头实际可移动范围 layers[i].cameraRange.x = layers[i].moveRange.x + Mathf.Abs(cameraSize.x); layers[i].cameraRange.width = layers[i].moveRange.width - 2 * Mathf.Abs(cameraSize.x); layers[i].cameraRange.y = layers[i].moveRange.y + Mathf.Abs(cameraSize.y); layers[i].cameraRange.height = layers[i].moveRange.height - 2 * Mathf.Abs(cameraSize.y); } cameraPosition = new Vector2(0, 0); //设置镜头属性 UnityEngine.Rect frontCameraRange = LayerManager.Instance.frontLayer.GetComponent <GameLayer>().cameraRange; cameraRange = new UnityEngine.Rect(frontCameraRange.x, frontCameraRange.y, frontCameraRange.width, frontCameraRange.height); //vo.camera.cameraTransform = mainCamera.transform; //记录场景大小 UnityEngine.Rect moveRange = frontLayer.GetComponent <GameLayer>().moveRange; sceneSize = new UnityEngine.Rect(moveRange.x, moveRange.y, moveRange.width, moveRange.height); ThreadEventList.GetList(MainThread.ThreadId, GameThread.ThreadId).AddEvent(ThreadEvent.Create(CameraEvent.INIT, moveRange)); MainThread.Instance.AddListener(CameraEvent.MOVE, OnCameraMove); }
public GameCheck(LevelConfig config) { //外面有 23 x 9 的大小 HaxgonCoord <Coord> sys = new HaxgonCoord <Coord>(); for (int py = 0; py > miny; py--) { for (int x = 0; x < maxx; x++) { int y = py - 3 + movesy[x]; sys.SetCoord(Point2D.Create(x, y), new Coord { type = 0 }); } } //颜色信息 int type = 1; //生成片信息 for (int i = 0; i < config.pieces.Count; i++) { Piece piece = new Piece(); piece.isAnswer = true; pieces[i] = piece; for (int p = 0; p < config.pieces[i].coords.Count; p++) { Coord coord = new Coord { x = config.pieces[i].coords[p].x, y = config.pieces[i].coords[p].y, piece = piece, type = type }; piece.coords.Add(coord); } type++; piece.Init(); } for (int i = 0; i < config.pieces2.Count; i++) { Piece piece = new Piece(); piece.isAnswer = false; pieces.Add(piece); for (int p = 0; p < config.pieces2[i].coords.Count; p++) { Coord coord = new Coord { x = config.pieces2[i].coords[p].x, y = config.pieces2[i].coords[p].y, piece = piece, type = type }; piece.coords.Add(coord); } type++; piece.Init(); } //创建主坐标系 for (int i = 0; i < pieces.length; i++) { Piece piece = pieces[i]; if (AutoSetPiece(pieces[i], sys) == null) { ThreadEvent te = ThreadEvent.Create("tip", "片超出范围 : 关卡" + config.id); ThreadEventList.GetList(CheckThread.ThreadId, EditorMainThread.ThreadId).AddEvent(te); } } }