/// <summary> /// 加载船上炮弹兵 /// </summary> public static void LoadShipPutSoldier(int ID, int DataID, SoldierInfo Info) { if (Info == null) { return; } Role r = new Role(); r.CreateSkin(GetLifeMBornNode(true), Info.m_modeltype, Info.m_name, AnimatorState.Stand, true); //IGameRole i = GameRoleFactory.Create(GetLifeMBornNode(true), Info.m_modeltype, Info.m_name, AnimatorState.Stand); GameObject go = r.RoleSkinCom.tRoot.gameObject; go.name = Info.m_name; Int2 BornPos = new Int2(Info.CX, Info.CY); go.transform.localPosition = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.Soldier); go.transform.localPosition = U3DUtil.SetZ(go.transform.localPosition, -2.0f); Transform tRole = go.transform.GetChild(0); TouchMove touch = tRole.gameObject.AddComponent <TouchMove>(); CanvasCore Core = new CanvasCore(ShipBuildType.Soldier, false, ID, DataID, Vector2.zero); touch.InitTouchMoveCore(Core, BornPos, null); AddBuildingEditPlugin(touch); if (Info.SoldierTypeID == 100003) //隐藏蹦蹦 //RolePropertyM rpm = i.GetBodyComponent<RolePropertyM>(); { r.RoleSkinCom.ShowLeftHand(false); } TouchMoveManager.JointShipBuild(touch); }
/// <summary> /// 加载船上楼梯 /// </summary> public static void LoadShipPutStairBuild(int ID, int DataID, BuildInfo Info) { if (Info == null) { return; } Transform parentT = GetLifeMBornNode(true); if (parentT == null) { return; } Int2 BornPos = new Int2(Info.m_cx, Info.m_cy); Vector3 local = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.BuildStair); Vector3 world = Local2WorldPos(local); Building buildlife = LifeFactory.CreateBuilding(Info, DataID, parentT, world, LifeEnvironment.Edit); TouchMove touch = buildlife.m_thisT.GetChild(0).gameObject.AddComponent <TouchMove>(); Vector2 size = new Vector2(Info.m_Shape.width, Info.m_Shape.height); CanvasCore Core = new CanvasCore(ShipBuildType.BuildStair, false, ID, DataID, size); touch.InitTouchMoveCore(Core, BornPos, buildlife); AddBuildingEditPlugin(touch); TouchMoveManager.JointShipBuild(touch); }
public static void ShowRoomGridUI(bool bShow) { TouchMove tm = TouchMoveManager.GetCurTouchMove(); if (tm != null) { tm.ShowTrapRoomUI(bShow); } }
public void RemoveSelf() { TouchMove tm = TouchMoveManager.GetShipBuild(this); if (tm != null) { tm.DestroyShipBuild(); } }
public static TouchMove GetTouchMoveByCore(CanvasCore core) { TouchMove tm = TouchMoveManager.GetShipBuild(core); if (tm != null) { return(tm); } return(null); }
public static void ReLoadShipCanvans(int shipDesignID) { ShipPlanDC.SetShipDesignID(shipDesignID); TouchMoveManager.ClearShipBuild(); ClearCombatScene(); // LoadCombatMap(); LoadShipCanvans(shipDesignID); LoadShipBuild(); GenerateDeck(); }
/// <summary> /// 加入一个房间。从仓库中加载。或加载方案 /// </summary> /// <param name="Core">核心结构</param> /// <param name="TargetPos">格子坐标</param> public static void AddNewCore(CanvasCore Core, Int2 TargetPos) { if (Core == null) { return; } ShipPlan P = ShipPlanDC.GetCurShipPlan(); if (P == null) { return; } ShipPutInfo Info = P.GetShipBuildInfo(Core); if (Info == null) { return; } if (Core.IsNewCreate) { Info.SetBuildPostion(TargetPos); P.AddShipBuildInfo(Info, Core.m_type); TouchMoveManager.MoveToShip(Core); Core.IsNewCreate = false; } // if (Core.m_type == ShipBuildType.BuildRoom) { if (Core.IsDeckRoom == false) { ShapeType Shape = Info.GetPutRoomShape(); if (Shape == null) { return; } RoomMap.OpenCanvans(Shape.GetShapeData(new Int2(Info.cxMapGrid, Info.cyMapGrid)), Core.m_ID); //设置甲板区域 RoomMap.UpdateDeckRoomGrid(); //更新金库房间 if (Info.IsGoldBuild() == true) { RoomMap.UpdateGoldRoomGrid(Core.GetPutRoomGridPos()); } } else { RoomMap.AddDeckBuild(Core.m_ID, Core.GetPutRoomGridPos()); } } else { RoomMap.AddMapPosition(Core, RoomMap.GetPutRoomGridPosition(Core)); } }
/// <summary> /// 新增士兵 /// </summary> public static void CreateSoldierFromWarehouse(int soldierId) { SoldierInfo infoSoldier = SoldierDC.GetSoldiers(soldierId); if (infoSoldier == null) { return; } CanvasCore Core = new CanvasCore(ShipBuildType.Soldier, true, ShipPutInfo.GetNewShipPutId(), infoSoldier.ID, Vector2.zero); Int2 BornPos = new Int2(0, 0); bool isCanPut = PutCanvasM.GetBornPos(Core, ref BornPos); if (isCanPut == false) { NGUIUtil.ShowTipWndByKey("88800007", 1.0f); return; } Transform t_start = GetLifeMBornNode(true); Role r = new Role(); r.CreateSkin(t_start, infoSoldier.m_modeltype, infoSoldier.m_name, AnimatorState.Stand, true); //IGameRole i = GameRoleFactory.Create(t_start, infoSoldier.m_modeltype, infoSoldier.m_name, AnimatorState.Stand); GameObject go = r.RoleSkinCom.tRoot.gameObject;; go.name = infoSoldier.m_name; Vector3 posMy = t_start.position; Vector3 screenSpace = Camera.main.WorldToScreenPoint(posMy); Vector3 pos = new Vector3(Screen.width / 2, Screen.height / 1.5f); Vector3 posTempmouse = Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, screenSpace.z)); posTempmouse = U3DUtil.SetZ(posTempmouse, 0f); go.transform.localPosition = Vector3.zero; Transform tRole = go.transform.GetChild(0); TouchMove touch = tRole.gameObject.AddComponent <TouchMove>(); tRole.gameObject.transform.parent.localPosition = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.Soldier); touch.InitTouchMoveCore(Core, BornPos, null); AddBuildingEditPlugin(touch); if (infoSoldier.SoldierTypeID == 100003) //隐藏蹦蹦 //RolePropertyM rpm = i.GetBodyComponent<RolePropertyM>(); { r.RoleSkinCom.ShowLeftHand(false); } TouchMoveManager.JointShipBuild(touch); TouchMoveManager.SetCurTouchMove(touch); touch.WareHouse2Ship(BornPos); }
public static Transform GetTransformByCore(CanvasCore core) { Transform t = null; TouchMove tm = TouchMoveManager.GetShipBuild(core); if (tm != null) { return(tm.gameObject.transform); } return(t); }
/// <summary> /// 加载船的画布表现 /// </summary> public static void LoadShipCanvans(int shipDesignID) { Transform parent = GetLifeMBornNode(true); if (parent != null) { GameObjectLoader.LoadPath("Prefabs/Others/", "PlaneCollider", parent); Int2 n2Pos = new Int2(0, 0); Int2 nEndPos = GetEndPosByShape(shipDesignID); string [] ShapeList = GetDesignShape(shipDesignID); if (ShapeList == null || ShapeList.Length != nEndPos.Layer) { NGUIUtil.DebugLog(" low version"); return; } RoomMap.RealMapSize = nEndPos; for (n2Pos.Layer = RoomMap.Mapv2Start.Layer; n2Pos.Layer < nEndPos.Layer; n2Pos.Layer++) { for (n2Pos.Unit = RoomMap.Mapv2Start.Unit; n2Pos.Unit < nEndPos.Unit; n2Pos.Unit++) { if (ShapeList.Length > 0 && ShapeList.Length <= nEndPos.Layer && ShapeList[n2Pos.Layer].Length <= nEndPos.Unit) { bool bDeck = CheckIsDeckGrid(ShapeList, n2Pos.Layer, n2Pos.Unit); if (ShapeList[n2Pos.Layer][n2Pos.Unit] == '0' && !bDeck) { continue; } } GameObject go = GameObjectLoader.LoadPath("Prefabs/Others/", "CanvasUnitBG", parent); go.name = string.Format("[{0},{1}]", n2Pos.Layer, n2Pos.Unit); go.transform.localPosition = new Vector3(3.0f * n2Pos.Unit, (3.0f + 0.3f) * n2Pos.Layer, 8.1f); CanvasUnitBG bk = go.GetComponent <CanvasUnitBG>(); if (bk != null) { TouchMoveManager.JoinCanvasUnitBk(n2Pos, bk); } } } } TouchMoveManager.SetAllGridBgStates(CanvasUnitState.Normal); TouchMoveManager.ShowCanvas(true); Vector3 pos = MainCameraM.GetDiffenceDisignCameraPos(); MainCameraM.s_Instance.SetCameraLimitParam(MainCameraM.s_reaLimitPyramidBoatView); MainCameraM.s_Instance.AutoMoveTo(pos, 0f); }
public static void PutDownNewBuild() { TouchMove curTouchMove = TouchMoveManager.GetCurTouchMove(); if (null != curTouchMove) { if (curTouchMove.MyCore().IsNewCreate) { bool canput = curTouchMove.MoveBuildUp(); if (canput == false) { curTouchMove.DestroyShipBuild(); } } } }
/// <summary> /// 从仓库中创建建筑。 /// </summary> public static void CreateBuildingFromWarehouse(BuildInfo infoBuild) { if (infoBuild == null) { return; } Vector2 size = new Vector2(infoBuild.m_Shape.width, infoBuild.m_Shape.height); CanvasCore Core = new CanvasCore(ShipBuildType.BuildRoom, true, ShipPutInfo.GetNewShipPutId(), infoBuild.ID, size); Int2 BornPos = new Int2(0, 0); bool isCanPut = PutCanvasM.GetBornPos(Core, ref BornPos); if (isCanPut == false) { NGUIUtil.ShowTipWndByKey("88800007", 1.0f); return; } Transform t_start = GetLifeMBornNode(true); Vector3 local = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.BuildRoom); Vector3 world = Local2WorldPos(local); Building buildlife = LifeFactory.CreateBuilding(infoBuild, 0, t_start, world, LifeEnvironment.Edit); if (buildlife == null) { return; } buildlife.ShowEditHp(infoBuild.m_bear); TouchMove touch = buildlife.m_thisT.GetChild(0).gameObject.AddComponent <TouchMove>(); touch.InitTouchMoveCore(Core, BornPos, buildlife); AddBuildingEditPlugin(touch); GenerateShip.m_vStart = Vector3.zero; TouchMoveManager.JointShipBuild(touch); TouchMoveManager.SetCurTouchMove(touch); touch.WareHouse2Ship(BornPos); }
private void CreateList() { if (MyHead.ListParent == null) { NGUIUtil.DebugLog("ShipCanvasDialogWnd ListParent!!!"); return; } //先删除 foreach (CanvasItem item in m_lItems) { if (item != null) { GameObject.DestroyImmediate(item.gameObject); } } ; m_lItems.Clear(); //重新添加。 if (m_shipBuildType == ShipBuildType.BuildRoom) { foreach (var a in warehouseBuildList) { if (TouchMoveManager.CheckHaveExist(m_shipBuildType, a.ID) == false) { AddBuild(a); } } } if (m_shipBuildType == ShipBuildType.Soldier) { foreach (var a in soldierList) { if (TouchMoveManager.CheckHaveExist(m_shipBuildType, a.ID) == false) { AddSoldier(a); } } } NGUIUtil.RepositionTable(MyHead.ListParent); }
private void CreateList() { if (m_shipBuildType == ShipBuildType.BuildRoom) { foreach (var a in warehouseBuildList) { if (TouchMoveManager.CheckHaveExist(m_shipBuildType, a.ID) == false) { AddBuild(a); } } } if (m_shipBuildType == ShipBuildType.Soldier) { foreach (var a in soldierList) { if (TouchMoveManager.CheckHaveExist(m_shipBuildType, a.ID) == false) { AddSoldier(a); } } } }
void OnMouseUp() { if (!m_bMouseDown || PutCanvasM.CanOperate == false) { return; } m_bMouseDown = false; bool bCancelSel = false; // MainCameraM.s_Instance.EnableDrag(true); TouchMove selNewTouchMov = null; if (TouchMove.g_bSetParaing == true) { SetPara(); return; } if (m_bTouchMoveChange) { if (m_roomGridTouchDown != null) { bCancelSel = true; selNewTouchMov = PutCanvasM.GetTouchMoveByRoomGrid(m_roomGridTouchDown, m_curClickType); if (null == selNewTouchMov) { CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom(); selNewTouchMov = PutCanvasM.GetTouchMoveByCore(buildRoomCoreTouchDown); } if (selNewTouchMov) { CanvasCore selCanvasCore = selNewTouchMov.MyCore(); bCancelSel = false; TouchMove selOldeTouchMove = TouchMoveManager.GetCurTouchMove(); selNewTouchMov.PlayEditSelectAnimation();//点选时播放房间内陷阱动画 TouchMoveManager.SetCurTouchMove(selNewTouchMov); selNewTouchMov.MoveWithRoom(selCanvasCore); } if (bCancelSel) { TouchMoveManager.SetCurTouchMove(null); } } } else { selNewTouchMov = TouchMoveManager.GetCurTouchMove(); } if (selNewTouchMov) { if (selNewTouchMov.MoveBuildUp()) { //TouchMoveManager.ShowCanvas(false); PutCanvasM.ShowRoomGridUI(true); } else { PutCanvasM.ShowRoomGridUI(true); } } else { TouchMoveManager.SetCurTouchMove(null); //TouchMoveManager.ShowCanvas(false); PutCanvasM.ShowRoomGridUI(true); } }
void Update() { if (MainCameraM.s_Instance.CheckIsZooming() || MainCameraM.s_Instance.CheckCameraMove()) { PutCanvasM.ShowRoomGridUI(false); } if (PutCanvasM.CanOperate == false) { return; } if (Input.touchCount >= 2) { PutCanvasM.ShowRoomGridUI(false); m_bTouchMoveChange = true; m_roomGridTouchDown = null; } // MainCameraM.s_Instance.EnableDrag(true); if (m_bMouseDown) { if (!m_isDrag) { float click = mouseClickThreshold; click *= click; m_vtotalmouseDelta += m_vlastFirstTouch - GetTouchPos(0); m_vlastFirstTouch = GetTouchPos(0); m_mag = m_vtotalmouseDelta.sqrMagnitude; if (m_mag > click) { m_isDrag = true; } else { //没有发生移动地图 或 没有发生长按 要判定 if (!m_isDrag && !m_bLongTouch) { //长按判定 if (!m_isDrag && m_roomGridTouchDown != null) { if (Time.time - m_fMouseDownTime > 0.5f) { m_bLongTouch = true; } //没有发生移动地图,但有发生长按,则更换选中房间,并将m_bTouchMoveChange=false if (m_bLongTouch) { CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom(); TouchMove selNewTouchMov = PutCanvasM.GetTouchMoveByCore(buildRoomCoreTouchDown); TouchMove selOldeTouchMove = TouchMoveManager.GetCurTouchMove(); if (selNewTouchMov != null && selNewTouchMov != selOldeTouchMove) { m_bTouchMoveChange = false; TouchMoveManager.SetCurTouchMove(selNewTouchMov); selNewTouchMov.OnMouseDown(); } } } } } } if (m_isDrag) { //按下是选中的是原选中房间,则直接移动该房间 //长按时会自动将最新选中房间,并将m_bTouchMoveChange设置为false if (!m_bTouchMoveChange) { MainCameraM.s_Instance.EnableDrag(false); TouchMove curTouchMove = TouchMoveManager.GetCurTouchMove(); if (null != curTouchMove) { PutCanvasM.ShowRoomGridUI(false); //TouchMoveManager.ShowCanvas(true); PutCanvasM.ShowRoomGridUI(false); curTouchMove.MoveBuild(); } } } } }
private void YesReAuth(UIButton sender) { TouchMoveManager.DeleteAll(); PutCanvasM.ShowRoomGridUI(false); }
public void BtnSelect_OnClickEventHandler() { if (m_iItemType == 3) { if (m_bSelect) { return; } m_bSelect = true; SoldierScrollWnd scrollWnd = WndManager.FindDialog <SoldierScrollWnd>(); if (scrollWnd) { scrollWnd.DoSelectItem(transform); } else { SelectSoldierwnd selectWnd = WndManager.FindDialog <SelectSoldierwnd>(); if (selectWnd) { selectWnd.SelectSoldier(Soldier.ID); } } return; } if (m_iItemType != 0) { return; } int id = 0; if (m_ShipBuildType == ShipBuildType.BuildRoom) { id = m_WareHouse [0].ID; } else if (m_ShipBuildType == ShipBuildType.Soldier) { id = Soldier.ID; } if (TouchMoveManager.CheckHaveExist(m_ShipBuildType, id)) { return; } CangKuWnd wnd = WndManager.FindDialog <CangKuWnd>(); //PlaneClickGrid.HideCangKuUI(); if (m_ShipBuildType == ShipBuildType.BuildRoom) { BattleEnvironmentM.CreateBuildingFromWarehouse(m_WareHouse [0]); m_WareHouse.RemoveAt(0); if (wnd) { wnd.RefreshTrapUI(); } } else if (m_ShipBuildType == ShipBuildType.Soldier) { ShipPlan P = ShipPlanDC.GetCurShipPlan(); if (P.CheckSoldierUpMaxCount() == true) { NGUIUtil.ShowTipWndByKey("88800014", 2.0f); } else { BattleEnvironmentM.CreateSoldierFromWarehouse(Soldier.ID); wnd.RefreshSoldierUI(CombatLoactionType.ALL); } } }
public static bool CheckSave() { PutCanvasM.StopEdit(); List <TouchMove> lOutShape = CheckBuildOutOfShape(); if (lOutShape.Count > 0) { NGUIUtil.ShowTipWndByKey <string>("10000204"); foreach (TouchMove item in lOutShape) { item.LoadEditEffect(TouchMoveState.CannotEdit); } PutCanvasM.SaveSuc = false; return(PutCanvasM.SaveSuc); } List <TouchMove> lDeckBuild = CheckDeckRoomInMaxLayer(); if (lDeckBuild.Count > 0) { NGUIUtil.ShowTipWndByKey <string>("10000206"); foreach (TouchMove item in lDeckBuild) { item.LoadEditEffect(TouchMoveState.CannotEdit); } PutCanvasM.SaveSuc = false; return(PutCanvasM.SaveSuc); } s_listNoLinkPutRoomcores = PutCanvasM.GetNoLinkPutRoom(); if (s_listNoLinkPutRoomcores.Count > 0) { //TouchMoveManager.ShowCanvas(true); TouchMoveManager.SetCanPutArea(ShipBuildType.BuildRoom, false); NGUIUtil.ShowTipWndByKey <string>("30000013"); int nCoreCount = s_listNoLinkPutRoomcores.Count; int nCoreCnt = 10; for (nCoreCnt = 0; nCoreCnt < nCoreCount; nCoreCnt++) { CanvasCore core = s_listNoLinkPutRoomcores[nCoreCnt]; PutCanvasM.GetTouchMoveByCore(core).LoadEditEffect(TouchMoveState.CannotEdit); } PutCanvasM.SaveSuc = false; return(PutCanvasM.SaveSuc); } s_listNoLinkPutDeckRoomcores = PutCanvasM.GetNoLinkPutDeckRoom(); if (s_listNoLinkPutDeckRoomcores.Count > 0) { //TouchMoveManager.ShowCanvas(true); TouchMoveManager.SetCanPutArea(ShipBuildType.BuildRoom, true); NGUIUtil.ShowTipWndByKey <string>("30000016"); int nCoreCount = s_listNoLinkPutDeckRoomcores.Count; int nCoreCnt = 10; for (nCoreCnt = 0; nCoreCnt < nCoreCount; nCoreCnt++) { CanvasCore core = s_listNoLinkPutDeckRoomcores[nCoreCnt]; PutCanvasM.GetTouchMoveByCore(core).LoadEditEffect(TouchMoveState.CannotEdit); } PutCanvasM.SaveSuc = false; return(PutCanvasM.SaveSuc); } s_listNoLinkSolders = PutCanvasM.GetNoLinkSolder(); if (s_listNoLinkSolders.Count > 0) { //TouchMoveManager.ShowCanvas(true); TouchMoveManager.SetCanPutArea(ShipBuildType.Soldier, false); NGUIUtil.ShowTipWndByKey <string>("30000015"); int nCoreCount = s_listNoLinkSolders.Count; int nCoreCnt = 10; for (nCoreCnt = 0; nCoreCnt < nCoreCount; nCoreCnt++) { CanvasCore core = s_listNoLinkSolders[nCoreCnt]; PutCanvasM.GetTouchMoveByCore(core).LoadEditEffect(TouchMoveState.CannotEdit); } PutCanvasM.SaveSuc = false; return(PutCanvasM.SaveSuc); } return(PutCanvasM.SaveSuc); }
public static void StopEdit() { TouchMoveManager.SetCurTouchMove(null); }
/// <summary> /// 检测建筑是否超出设计图范围. /// </summary> /// <returns><c>true</c>, if out of shape was built, <c>false</c> otherwise.</returns> public static List <TouchMove> CheckBuildOutOfShape() { return(TouchMoveManager.GetAllBuildOutShape()); }
public static List <TouchMove> CheckDeckRoomInMaxLayer() { return(TouchMoveManager.GetDeckBuildListInMaxLayer()); }