/// <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 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); }