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