void OnDisable() { UIFunction.ClearChild(PlayerListPanel); PlayerContainer.Clear(); ObjectContainer.Clear(); LocalMessage.SetHandler(null); }
//加载地图 private void LoadMap() { // //设置地图区域的位置 UIFunction.SetPosition(MapPanel, new Vector2(0, 0)); //设置地图区域的大小 UIFunction.SetSize(MapPanel, new Vector2(BaseLength, BaseLength)); int line = LocalMessage.Map.Length, column = LocalMessage.Map[0].Length; float width = BaseLength / column, height = BaseLength / line, halfWidth = width / 2, halfHeight = height / 2; Vector3 scale = new Vector3(width, height, 0.01f); for (int i = 0; i < line; i++) { for (int j = 0; j < column; j++) { string temp = Floor[LocalMessage.Map[i][j]]; if (i == LocalMessage.StartGrid.line && j == LocalMessage.StartGrid.column) { temp = Floor[3]; } else if (i == LocalMessage.EndGrid.line && j == LocalMessage.EndGrid.column) { temp = Floor[4]; } GameObject go = (GameObject)Instantiate(Resources.Load(temp)); go.transform.localEulerAngles = new Vector3(0, 0, 180); go.transform.SetParent(MapPanel.transform); go.name = go.name.Replace("(Clone)", ""); UIFunction.SetScale(go, scale); UIFunction.Set3DPosition(go, new Vector3(halfHeight + j * height + x_offset, -(halfWidth + i * width) + y_offset, -0.09f)); } } LocalMessage.grid.width = width; LocalMessage.grid.height = height; }
void OnDisable() { xml.Close(); TowerFileXml.Close(); UIFunction.ClearChild(MapPanel); LocalMessage.SetHandler(null); }
// Use this for initialization void Start() { if (!GameRunning.TowerFileXml.IsOpen) { GameRunning.TowerFileXml.Open(GameRunning.tower_data); } LinkedList <string> node = GameRunning.TowerFileXml.GetChildren(); Vector3 one = new Vector3(1, 1, 1); foreach (string str in node) { try{ GameObject go = (GameObject)Instantiate(Resources.Load(TowerPicturePath + str)); GameObject parent = (GameObject)Instantiate(Resources.Load(Template)); Vector3 temp = parent.transform.localPosition; temp.z = 0; parent.transform.SetParent(transform); parent.SendMessage("AddImage", go); //SelectTower.cs parent.transform.localPosition = temp; UIFunction.SetScale(parent, one); } catch { continue; } } }
void OnDisable() { RoomContainer1.Clear(); RoomContainer2.Clear(); UIFunction.ClearChild(RoomListPanel); //EditorUtility.DisplayDialog("关闭", "离开大厅", "关闭"); }
/* 获取到房间信息列表 * param[list]:包含版本号和类别号 */ private void GetRoomMsgList(byte[] list) { int i = 2; for (i = 2; i < list.Length - 4; i += 4) { uint temp_num = BitConverter.ToUInt32(list, i); if (temp_num == 0) { break; } RoomMessage temp_room = new RoomMessage(temp_num); ushort temp_room_num = temp_room.GetRoomNumber(); GameObject temp_go = null; if (RoomContainer2.ContainsKey(temp_room_num)) { temp_go = RoomContainer2[temp_room_num]; UIFunction.SetRoomMessage(temp_go, temp_room); } else { //创建新的物体 temp_go = (GameObject)Instantiate(Resources.Load("Prefabs/RoomBar")); temp_go.transform.parent = RoomListPanel.transform; UIFunction.SetPosition(temp_go, new Vector2(0, 0)); temp_go.transform.localScale = new Vector3(1, 1, 1); UIFunction.SetRoomMessage(temp_go, temp_room, RoomClick); RoomContainer2.Add(temp_room_num, temp_go); RoomContainer1.Add(temp_go, temp_room_num); } } }
//创建一个玩家条 private GameObject CreatePlayerBar(string name, byte identity) { GameObject go = (GameObject)Instantiate(Resources.Load("Prefabs/PlayerBar")); UIFunction.SetPlayerMessage(go, name, identity, KickPlayer); go.transform.SetParent(PlayerListPanel.transform); go.transform.localScale = new Vector3(1, 1, 1); return(go); }
private void CreateMonster(string monster, MonsterProperty message, Vector3 scale) { GameObject go = (GameObject)Instantiate(Resources.Load("Prefabs/" + monster)); go.transform.SetParent(MapPanel.transform); UIFunction.SetScale(go, scale); go.SetActive(true); go.SendMessage("SetMessageReceiver", gameObject); //MoveRoute.cs go.SendMessage("LoadCurrentCheckPointMessage", message); //MonsterProperties.cs }
}; //终点坐标 // Use this for initialization void Start() { float small = LocalMessage.grid.height > LocalMessage.grid.width ? LocalMessage.grid.width : LocalMessage.grid.height; UIFunction.SetScale(gameObject, new Vector3(small, small, small)); UIFunction.SetMapPosition(gameObject, LocalMessage.StartGrid); if (EndPoint.x == 0 && EndPoint.y == 0) { EndPoint = UIFunction.GetPixelPosition(LocalMessage.EndGrid); } transform.localEulerAngles = DIRECTION[LocalMessage.MonsterRoute[0].GetDirection()]; }
public void Deinitialize() { InputMapper.MouseInputUI -= ReceiveMouseInput; InputMapper.TouchInputUI -= ReceiveTouchInput; InputMapper.ActionKey -= ReceiveActionkeyInput; InputMapper.ActionKey_2 += ReceiveActionkey2Input; InputMapper.DirectionalInputRightStick -= ReceiveDirectionalInput; _instance = null; ActionKey = null; ActionKey2 = null; ActionDirectional = null; }
//创建一个房间条 private GameObject CreateRoomBar(string room_number, string person, string difficulty, string checkpoint, string enter, UIFunction.Call call = null) { if (call == null) { call = RoomClick; } GameObject go = (GameObject)Instantiate(Resources.Load("Prefabs/RoomBar")); UIFunction.SetRoomMessage(go, room_number, person, difficulty, checkpoint, enter, call); go.transform.SetParent(RoomListPanel.transform); //UIFunction.SetPosition(go, new Vector2(0, 0)); go.transform.localScale = new Vector3(1, 1, 1); return(go); }
//MonsterProperties.cs调用 public void SetMoveSpeed(float speed) { MoveSpeed = speed; Position temp1 = new Position(); if (StartMove) { temp1.SetPixelPosition(UIFunction.GetPixelPosition(LocalMessage.StartGrid)); StartMove = false; } else { temp1.SetPixelPosition(transform.localPosition); } Position temp2 = LocalMessage.MonsterRoute[currentIndex]; iTween.moveTo(gameObject, Vector3.Distance(temp1.GetPixel(), temp2.GetPixel()) / MoveSpeed, 0, temp2.GetX(), temp2.GetY(), -8.5f, iTween.EasingType.linear, "CompleteMove", null); }
//设置怪物的路线 /* 将拐点添加到容器中 */ private static void SetMonsterRoute() { byte currentDirection = GetNextGridDirection(StartGrid, MoveRoute.NONE), lastDirection = MoveRoute.NONE; GPosition currentPosition = new GPosition(), lastPosition = new GPosition(); uint i = 0, max = (uint)(Map.Length * Map[0].Length); uint index = 0; for (currentPosition.CopyFrom(StartGrid), lastPosition.CopyFrom(StartGrid); i < max; i++) { //遇到拐点,则保存到容器中 if (currentDirection != lastDirection) { lastDirection = currentDirection; MonsterRoute.Add(index++, new Position(lastPosition, UIFunction.GetPixelPosition(lastPosition), currentDirection)); } //如果达到终点,则结束 if (currentPosition.Equals(EndGrid)) { MonsterRoute.Add(index++, new Position(currentPosition, UIFunction.GetPixelPosition(currentPosition), currentDirection)); break; } lastPosition.CopyFrom(currentPosition); //将当前位置保存到上一个位置 //获取下一个位置的方向,并避免180度回头的情况 currentDirection = GetNextGridDirection(currentPosition, currentDirection); switch (currentDirection) { case MoveRoute.UP: currentPosition.line -= 1; break; case MoveRoute.DOWN: currentPosition.line += 1; break; case MoveRoute.LEFT: currentPosition.column -= 1; break; case MoveRoute.RIGHT: currentPosition.column += 1; break; } } }
private void Awake() { Instance = this; }
public void RegisterUI(UIFunction d) //注册UI的函数 { UiBlocks.Add(d); }