/// <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); }
/// <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); }
/// <summary> /// 设置位置动画表现 /// </summary> public void ExchangeAnimation(Int2 grid) { //LeaveRoom (); MoveWithRoom(MyCore()); Vector3 posWold = RoomMap.GetShipBuildLocalPos(grid, m_Core.m_type); Transform tStart = BattleEnvironmentM.GetLifeMBornNode(true); if (null != tStart) { posWold = tStart.TransformPoint(posWold); } m_tTarget.DOMove(posWold, 0.3f); }
/// <summary> /// 根据当前所在格子设置局部坐标位置 /// </summary> private void SetPosByGrid(bool isAni = false) { #if UNITY_EDITOR_LOG if (m_Core.m_type == ShipBuildType.Soldier && m_posMapGrid.Unit % MapGrid.m_UnitRoomGridNum != 4) { NGUIUtil.DebugLog("炮弹兵位置出错:" + m_posMapGrid); } #endif Vector3 localPos = RoomMap.GetShipBuildLocalPos(m_posMapGrid, m_Core.m_type); if (isAni == false) { m_tTarget.localPosition = localPos; } else { //m_bAnimating = true; PutCanvasM.CanOperate = false; m_tTarget.DOMove(localPos, 0.2f); } }
/// <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 Vector3 GetPosByGrid(Int2 grid) { return(RoomMap.GetShipBuildLocalPos(grid, m_Core.m_type)); }