Esempio n. 1
0
    /// <summary>
    /// 设置参数,第一个参数为关联的建筑Core
    /// </summary>
    public void SetBuildPara(CanvasCore Core, int data0, int data1)
    {
        ShipPlan P = ShipPlanDC.GetCurShipPlan();

        if (P == null)
        {
            return;
        }
        shipput_data0 = data0;
        shipput_data1 = data1;
        if (IsTransgateRoom() == true)
        {
            ShipPutInfo Info = P.GetShipBuildInfo(Core);
            if (Info != null)
            {
                OffX       = data0 - Info.cxMapGrid;
                OffY       = data1 - Info.cyMapGrid;
                LinkRoomID = Core.m_ID;
            }
            else
            {
                LinkRoomID = -1;
                OffX       = 0;
                OffY       = 0;
            }
        }
    }
Esempio n. 2
0
 public void DoDeckDataStartWithOut(ShipPutInfo info)
 {
     CalcMapArea();
     ReCalcShipBuildInfoXY(XYmode.Edit2Save);
     CalcMapShapeWithout(info);
     CalcMapWithout(info);
 }
Esempio n. 3
0
    /// <summary>
    /// 更新传送门- 传送点
    /// </summary>
    /// <param name="diffX"></param>
    /// <param name="diffY"></param>
    public void UpdateTransgateRoomParam(int diffX, int diffY)
    {
        ShipPlan P = ShipPlanDC.GetCurShipPlan();

        if (P == null)
        {
            return;
        }
        if (IsTransgateRoom() == false)
        {
            return;
        }
        ShipPutInfo Info = P.GetShipBuildInfo(new CanvasCore(ShipBuildType.BuildRoom, false, LinkRoomID, LinkRoomID, Vector2.zero));

        if (Info != null)
        {
            shipput_data0 = Info.cxMapGrid + OffX;
            shipput_data1 = Info.cyMapGrid + OffY;
        }
        else
        {
            shipput_data0 += diffX;
            shipput_data1 += diffY;
        }
    }
Esempio n. 4
0
    /// <summary>
    /// 可置换的房间
    /// </summary>
    public static bool CheckExchangeRoom(ShipPutInfo S1, ShipPutInfo S2)
    {
        if (S1 == null || S2 == null)
        {
            return(false);
        }
        if (S1.type != S1.type)
        {
            return(false);
        }
        if (S1.type == (int)ShipBuildType.Soldier)
        {
            return(true);
        }
        if (S1.type == (int)ShipBuildType.BuildStair)
        {
            return(false);
        }
        if (S1.m_DeckRoom != S2.m_DeckRoom)
        {
            return(false);
        }
        ShapeType t1 = S1.GetPutRoomShape();
        ShapeType t2 = S2.GetPutRoomShape();

        return(ShapeType.CheckShapeSame(t1, t2));
    }
Esempio n. 5
0
 private canvasedit.ShipPutInfo FillShipPutInfo(ShipPutInfo item, ShipBuildType Type)
 {
     canvasedit.ShipPutInfo info = new canvasedit.ShipPutInfo();
     info.id = item.id;
     if (info.id < 0)
     {
         info.id = 0;
     }
     info.type  = item.type;
     info.objid = item.objid;
     if (Type == ShipBuildType.BuildStair)
     {
         info.objid = 1201;
         info.type  = 3;
     }
     info.cx = item.cxMapGrid;
     info.cy = item.cyMapGrid;
     if (Type == ShipBuildType.BuildRoom && item.IsTransgateRoom())
     {
         item.IsTransgateRoom();
         info.shipput_data0 = item.shipput_data0;
         info.shipput_data1 = item.shipput_data1;
     }
     else
     {
         info.shipput_data0 = item.shipput_data0;
         info.shipput_data1 = item.shipput_data1;
     }
     return(info);
 }
Esempio n. 6
0
    /// <summary>
    /// 获取船上数据
    /// </summary>
    public List <ShipPutInfo> GetShipBuildInfo(ShipBuildType type)
    {
        List <ShipPutInfo> l = new List <ShipPutInfo>();

        if (type == ShipBuildType.BuildRoom || type == ShipBuildType.All)
        {
            if (m_RoomBuildings.Count == 0)   //当没有金库时,添加一个
            {
                BuildInfo info = BuildDC.SearchBuilding(1300);
                if (info != null)
                {
                    ShipPutInfo Build = new ShipPutInfo(ShipPutInfo.GetNewShipPutId(), info);
                    Build.cyMapGrid = 0;
                    Build.cxMapGrid = 24;
                    AddShipBuildInfo(Build, ShipBuildType.BuildRoom);
                }
            }
            l.AddRange(m_RoomBuildings);
        }

        if (type == ShipBuildType.Soldier || type == ShipBuildType.All)
        {
            l.AddRange(m_Soldiers);
        }

        if (type == ShipBuildType.BuildStair || type == ShipBuildType.All)
        {
            l.AddRange(m_StairBuildings);
        }

        return(l);
    }
Esempio n. 7
0
    /// <summary>
    /// 检测是否满足升级条件
    /// </summary>
    /// <param name="info"></param>
    /// <returns></returns>
    bool CanUpgrade(ShipPutInfo info)
    {
        /*UserInfo userInfo = UserDC.UserInfo;
         * if (userInfo!=null)
         * {
         * if (BuildInfo.m_levellimit>userInfo.level)
         * {
         * NGUIUtil.ShowTipWnd("升级失败:玩家等级小于建造该建筑物所需的等级!");
         * return false;
         * }
         *      if (BuildInfo.m_level == buildingM.GetBuildingMaxLevel(info.m_type))
         * {
         * NGUIUtil.ShowTipWnd("升级失败:该建筑物等级已经是最高等级!");
         * return false;
         * }
         * if (BuildInfo.m_coin > userInfo.coin || BuildInfo.m_wood>userInfo.wood ||
         * BuildInfo.m_stone > userInfo.stone || BuildInfo.m_steel>userInfo.steel )
         * {
         * NGUIUtil.ShowTipWnd("升级失败:所需的资源不足!");
         * return false;
         * }
         * }*/

        return(true);
    }
Esempio n. 8
0
    /// <summary>
    /// 还原方案
    /// </summary>
    public void ResetPlan()
    {
        m_Canvans.Copy(m_BackupCanvas);

        m_Soldiers.Clear();
        foreach (ShipPutInfo item in m_BackupSoldiers)
        {
            ShipPutInfo newItem = new ShipPutInfo();
            newItem.Copy(item);
            m_Soldiers.Add(newItem);
        }

        m_RoomBuildings.Clear();
        foreach (ShipPutInfo item in m_BackupRoomBuildings)
        {
            ShipPutInfo newItem = new ShipPutInfo();
            newItem.Copy(item);
            m_RoomBuildings.Add(newItem);
        }

        m_StairBuildings.Clear();
        foreach (ShipPutInfo item in m_BackupStairBuildings)
        {
            ShipPutInfo newItem = new ShipPutInfo();
            newItem.Copy(item);
            m_StairBuildings.Add(newItem);
        }

        BlackScienceID = m_BackupBlackScienceID;
    }
Esempio n. 9
0
 /// <summary>
 /// 移除建筑物,如果是新增的可以直接移除,否则需等服务端通过才移除
 /// </summary>
 public void RemoveShipBuildInfo(ShipPutInfo Info, ShipBuildType Type)
 {
     if (Info == null)
     {
         return;
     }
     if (Type == ShipBuildType.Soldier)
     {
         if (m_Soldiers.Contains(Info) == true)
         {
             m_Soldiers.Remove(Info);
         }
     }
     else if (Type == ShipBuildType.BuildRoom)
     {
         if (m_RoomBuildings.Contains(Info) == true)
         {
             m_RoomBuildings.Remove(Info);
         }
     }
     else if (Type == ShipBuildType.BuildStair)
     {
         if (m_StairBuildings.Contains(Info) == true)
         {
             m_StairBuildings.Remove(Info);
         }
     }
 }
Esempio n. 10
0
    void BtnSetTransGate_OnClickEventHandler(UIButton sender)
    {
        SetBuildParaStart();
        List <CanvasCore> childrenCore = PutCanvasM.GetChildByCore(m_Core);

        if (childrenCore.Count == 0)
        {
#if UNITY_EDITOR_LOG
            NGUIUtil.DebugLog("房间内未检测到传送门,请调查!!!");
#endif
            return;
        }
        ShipPlan P = ShipPlanDC.GetCurShipPlan();
        if (P == null)
        {
            return;
        }
        foreach (var childCore in childrenCore)
        {
            TouchMove     tm      = PutCanvasM.GetTouchMoveByCore(childCore);
            BuildProperty lifeobj = tm.GetComponent <BuildProperty>();
            if (lifeobj != null && lifeobj.GetModeType() == 1605)
            {
                Building1605 b = lifeobj.GetLife() as Building1605;
                if (b != null)
                {
                    ShipPutInfo Info = P.GetShipBuildInfo(m_Core);
                    b.ShowTranGate(new Int2(Info.shipput_data0, Info.shipput_data1));
                }
            }
        }
    }
Esempio n. 11
0
    public void CopyPlanShipPut(ShipPlan Info)
    {
        m_Canvans.Copy(Info.m_Canvans);

        m_Soldiers.Clear();
        foreach (ShipPutInfo item in Info.m_Soldiers)
        {
            ShipPutInfo newItem = new ShipPutInfo();
            newItem.Copy(item);
            m_Soldiers.Add(newItem);
        }
        m_RoomBuildings.Clear();
        foreach (ShipPutInfo item in Info.m_RoomBuildings)
        {
            ShipPutInfo newItem = new ShipPutInfo();
            newItem.Copy(item);
            m_RoomBuildings.Add(newItem);
        }

        m_StairBuildings.Clear();
        foreach (ShipPutInfo item in Info.m_StairBuildings)
        {
            ShipPutInfo newItem = new ShipPutInfo();
            newItem.Copy(item);
            m_StairBuildings.Add(newItem);
        }

        BlackScienceID = Info.BlackScienceID;
    }
Esempio n. 12
0
    /// <summary>
    /// 获取船上数据
    /// </summary>
    public void GetShipLifeObj(ref List <SoldierInfo> lSoldier, ref List <BuildInfo> lBuild, ref List <BuildInfo> lStair)
    {
        if (lSoldier == null)
        {
            lSoldier = new List <SoldierInfo>();
        }
        lSoldier.Clear();

        if (lBuild == null)
        {
            lBuild = new List <BuildInfo>();
        }
        lBuild.Clear();

        if (lStair == null)
        {
            lStair = new List <BuildInfo>();
        }
        lStair.Clear();

        if (m_RoomBuildings.Count == 0)   //当没有金库时,添加一个
        {
            BuildInfo info = BuildDC.SearchBuilding(1300);
            if (info != null)
            {
                ShipPutInfo Build = new ShipPutInfo(ShipPutInfo.GetNewShipPutId(), info);
                Build.cyMapGrid = 0;
                Build.cxMapGrid = 24;
                AddShipBuildInfo(Build, ShipBuildType.BuildRoom);
                lBuild.Add(info);
            }
        }
        else
        {
            //建筑
            foreach (ShipPutInfo r in m_RoomBuildings)
            {
                BuildInfo info = r.GetBuildInfo();
                if (info != null)
                {
                    lBuild.Add(r.GetBuildInfo());
                }
            }
            //炮弹兵
            foreach (ShipPutInfo r in m_Soldiers)
            {
                SoldierInfo s = new SoldierInfo();
                if (r.GetSoldier(ref s) == true)
                {
                    lSoldier.Add(s);
                }
            }
            //楼梯
            foreach (ShipPutInfo r in m_StairBuildings)
            {
                lStair.Add(r.GetBuildInfo());
            }
        }
    }
Esempio n. 13
0
    /// <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));
        }
    }
Esempio n. 14
0
 /// <summary>
 /// 添加 新建 建筑或炮弹兵 到船上。
 /// </summary>
 public void AddShipBuildInfo(ShipPutInfo Info, ShipBuildType Type)
 {
     if (Info == null)
     {
         return;
     }
     if (Type == ShipBuildType.Soldier)
     {
         bool b = false;
         for (int i = 0; i < m_Soldiers.Count; i++)
         {
             if (m_Soldiers[i].id == Info.id)
             {
                 b = true;
                 break;
             }
         }
         if (b == false)
         {
             m_Soldiers.Add(Info);
         }
     }
     else if (Type == ShipBuildType.BuildRoom)
     {
         bool b = false;
         for (int i = 0; i < m_RoomBuildings.Count; i++)
         {
             if (m_RoomBuildings[i].id == Info.id)
             {
                 b = true;
                 break;
             }
         }
         if (b == false)
         {
             m_RoomBuildings.Add(Info);
         }
     }
     else if (Type == ShipBuildType.BuildStair)
     {
         bool b = false;
         for (int i = 0; i < m_StairBuildings.Count; i++)
         {
             if (m_StairBuildings[i].id == Info.id)
             {
                 b = true;
                 break;
             }
         }
         if (b == false)
         {
             m_StairBuildings.Add(Info);
         }
     }
 }
Esempio n. 15
0
    /// <summary>
    /// 清理船只方案
    /// </summary>
    public void ClearShipPlan()
    {
        m_RoomBuildings.Clear();
        m_Soldiers.Clear();
        m_StairBuildings.Clear();

        m_BackupRoomBuildings.Clear();
        m_BackupStairBuildings.Clear();
        m_BackupSoldiers.Clear();
        ShipPutInfo.ClearNewShipPutId();
    }
Esempio n. 16
0
    /// <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);
    }
Esempio n. 17
0
    /// <summary>
    /// 移除一个房间
    /// </summary>
    public static void RemoveBuildRoom(CanvasCore Core)
    {
        if (Core == null)
        {
            return;
        }
        ShipPlan P = ShipPlanDC.GetCurShipPlan();

        if (P == null)
        {
            return;
        }
        ShipPutInfo Info = P.GetShipBuildInfo(Core);

        if (Info == null)
        {
            return;
        }

        if (Core.m_type == ShipBuildType.BuildRoom)
        {
            if (Core.IsDeckRoom == false)
            {
                if (Info.GetPutRoomShape() != null)
                {
                    List <CanvasCore> l = PutCanvasM.GetChildByCore(Core);
                    foreach (CanvasCore c in l)
                    {
                        ShipPutInfo II = P.GetShipBuildInfo(c);
                        if (II != null)
                        {
                            P.RemoveShipBuildInfo(II, c.m_type);
                        }
                    }
                    RoomMap.CloseCanvans(Core.GetPutRoomGridPos());
                    //设置甲板区域
                    RoomMap.UpdateDeckRoomGrid();
                }
            }
            else
            {
                List <Int2> l = Core.GetPutRoomGridPos();
                RoomMap.RemoveDeckBuild(l);
            }
        }
        else
        {
            RoomMap.RemoveMapPosition(Core, RoomMap.GetPutRoomGridPosition(Core));
        }
        P.RemoveShipBuildInfo(Info, Core.m_type);
    }
Esempio n. 18
0
    public static bool IsEqual(ShipPutInfo a, ShipPutInfo b)
    {
        if (a == null || b == null)
        {
            return(false);
        }
        bool isEqual = false;

        if (a.id == b.id && a.cxMapGrid == b.cxMapGrid && a.cyMapGrid == b.cyMapGrid)
        {
            isEqual = true;
        }
        return(isEqual);
    }
Esempio n. 19
0
    private static bool IsInShipPutInfoList(List <ShipPutInfo> a, ShipPutInfo b)
    {
        bool result = false;

        foreach (ShipPutInfo item in a)
        {
            if (ShipPutInfo.IsEqual(item, b))
            {
                result = true;
                break;
            }
        }
        return(result);
    }
Esempio n. 20
0
 /// <summary>
 /// 保持战斗建筑摆设数据
 /// </summary>
 public static void SaveShipBuildData(ShipPutInfo item,
                                      ref Dictionary <int, BuildInfo> lBuild)
 {
     if (item == null || lBuild == null)
     {
         return;
     }
     if (item.type == (int)ShipBuildType.BuildRoom || item.type == (int)ShipBuildType.BuildStair)
     {
         BuildInfo RoomBuild = item.GetBuildInfo( );
         if (RoomBuild != null)
         {
             int RoomBuildID = CmCarbon.GetDataID();
             lBuild.Add(RoomBuildID, RoomBuild);
         }
     }
 }
Esempio n. 21
0
 /// <summary>
 /// 设置方案摆设
 /// </summary>
 public void SetPlanShipPut(CanvasBuildResponse.CanvasBuildInfo item)
 {
     ClearShipPlan();
     if (item == null)
     {
         return;
     }
     foreach (canvasedit.ShipPutInfo shipputitem in item.shipput_info)
     {
         ShipPutInfo s = SaveShipBuildInfo(shipputitem);
         if (s == null)
         {
             continue;
         }
         AddShipCanvansFromSvr(s);
     }
 }
Esempio n. 22
0
    public void Init(bool isUpgrade, ShipPutInfo Info)
    {
        IsUpgrade = isUpgrade;
        BuildInfo = Info;

        /*NGUIUtil.SetLableText(LblTitle, BuildInfo.m_name);
         *
         * NGUIUtil.AddLableText(LblMaxCapacity, 1000);
         * NGUIUtil.AddLableText(LblBuildLife, BuildInfo.m_hp1);
         * NGUIUtil.AddLableText(LblWallMD, BuildInfo.m_magicdefend2);
         * NGUIUtil.AddLableText(LblBuildMD, BuildInfo.m_magicdefend1);
         * NGUIUtil.AddLableText(LblWallLife, BuildInfo.m_hp2);
         * NGUIUtil.AddLableText(LblWallPD, BuildInfo.m_physicaldefend2);
         * NGUIUtil.AddLableText(LblBuildPD, BuildInfo.m_physicaldefend1);*/

        NGUIUtil.SetLableText(MyHead.LblBuildInfo, NGUIUtil.GetStringByKey(88800099));
    }
Esempio n. 23
0
 /// <summary>
 /// 协议转换成本地结构数据
 /// </summary>
 private ShipPutInfo SaveShipBuildInfo(canvasedit.ShipPutInfo Info)
 {
     if (Info != null)
     {
         ShipPutInfo sbi = new ShipPutInfo();
         sbi.id = Info.id;
         //sbi.battlemode = Info.battlemode;
         sbi.objid         = Info.objid;
         sbi.type          = Info.type;
         sbi.cxMapGrid     = Info.cx;
         sbi.cyMapGrid     = Info.cy;
         sbi.shipput_data0 = Info.shipput_data0;
         sbi.shipput_data1 = Info.shipput_data1;
         return(sbi);
     }
     return(null);
 }
Esempio n. 24
0
    public void Copy(ShipPutInfo Info)
    {
        this.id         = Info.id;
        this.battlemode = Info.battlemode;
        this.objid      = Info.objid;
        this.type       = Info.type;

        this.cxMapGrid     = Info.cxMapGrid;
        this.cyMapGrid     = Info.cyMapGrid;
        this.shipput_data0 = Info.shipput_data0;
        this.shipput_data1 = Info.shipput_data1;

        this.LinkRoomID = Info.LinkRoomID;
        this.OffX       = Info.OffX;
        this.OffY       = Info.OffY;
        this.m_DeckRoom = Info.m_DeckRoom;
    }
Esempio n. 25
0
    /// <summary>
    /// 创建楼梯
    /// </summary>
    /// <param name="Core"></param>
    public static void CreateStair(CanvasCore Core)
    {
        ShipPlan P = ShipPlanDC.GetCurShipPlan();

        if (P == null)
        {
            return;
        }
        if (Core.m_type != ShipBuildType.BuildRoom && Core.IsDeckRoom)
        {
            return;
        }
        //只有房间变化楼梯才重新创建
        List <Int2> points = RoomMap.GetStairCreatePoint();

        if (points.Count > 0)
        {
            foreach (var grid in points)
            {
                ShipPutInfo Info = new ShipPutInfo();
                Info.id            = ShipPutInfo.GetNewShipPutId();
                Info.objid         = 1201;
                Info.type          = 3;
                Info.cxMapGrid     = grid.Unit;
                Info.cyMapGrid     = grid.Layer;
                Info.shipput_data0 = 0;
                Info.shipput_data1 = 0;
                P.AddShipBuildInfo(Info, ShipBuildType.BuildStair);
                BuildInfo stair = buildingM.GetStartBuildInfo(1201);
                ///// 临时修改,楼梯位置不正确的问题
                //stair.m_type = 1201;
                stair.m_cx           = grid.Unit;
                stair.m_cy           = grid.Layer;
                stair.m_ShipPutdata0 = 0;
                stair.m_ShipPutdata1 = 0;
                ///end
                if (stair != null)
                {
                    BattleEnvironmentM.LoadShipPutStairBuild(Info.id, Info.objid, stair);
                }
            }
        }
        RoomMap.RemoveExcessStair();
    }
Esempio n. 26
0
 /// <summary>
 /// 服务端摆放信息归类到到具体类型类型(房间,陷阱,炮弹兵)
 /// </summary>
 private void AddShipCanvansFromSvr(ShipPutInfo Info)
 {
     if (Info == null)
     {
         return;
     }
     if (Info.type == 1)
     {
         m_RoomBuildings.Add(Info);
     }
     else if (Info.type == 2)
     {
         m_Soldiers.Add(Info);
     }
     else if (Info.type == 3)
     {
         m_StairBuildings.Add(Info);
     }
 }
Esempio n. 27
0
    /// <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);
    }
Esempio n. 28
0
    /// <summary>
    /// 设置建筑参数
    /// </summary>
    public void SetBuildParam(CanvasCore core, int data0, int data1)
    {
        ShipPlan P = ShipPlanDC.GetCurShipPlan();

        if (P == null)
        {
            return;
        }
        if (!m_Core.IsNewCreate)
        {
            if (m_Core.m_type != ShipBuildType.Soldier)
            {
                ShipPutInfo Info = P.GetShipBuildInfo(m_Core);
                if (Info != null)
                {
                    Info.SetBuildPara(core, data0, data1);
                }
            }
        }
        SetBuildParaOver();
    }
Esempio n. 29
0
    /// <summary>
    /// 确认能否移除
    /// </summary>
    /// <returns>true 能被删除,false 不能被删除</returns>
    public static bool CheckCanRemove(CanvasCore Core, ref PutERR err)
    {
        if (Core == null)
        {
            return(false);
        }
        ShipPlan P = ShipPlanDC.GetCurShipPlan();

        if (P == null)
        {
            return(false);
        }
        ShipPutInfo Info = P.GetShipBuildInfo(Core);

        if (Info == null)
        {
            return(false);
        }

        if (Core.m_type == ShipBuildType.BuildRoom && !Core.IsNewCreate)
        {
            if (Core.IsDeckRoom == false)
            {
                /*
                 * List<Int2> SubList =  Core.GetPutRoomGridXY();
                 * List<Int2> AddList = new List<Int2>();
                 * if(RoomMap.CheckMapLinkOk(SubList ,AddList ,Core.m_style, true) == false)
                 * {
                 *      err = PutERR.ERR_NOLink;
                 *      return false;
                 * }*/
                return(true);
            }
            else
            {
                return(true);
            }
        }
        return(true);
    }
Esempio n. 30
0
    /// <summary>
    /// 计算地图形状
    /// </summary>
    private void CalcMapShapeWithout(ShipPutInfo info)
    {
        Int2 Start = Canvans.GetMapSize();
        List <List <int> > grid = new List <List <int> >();
        int RoomWidth           = Start.Unit;

        for (int i = 0; i < Start.Layer; i++)
        {
            List <int> row = new List <int>();
            for (int j = 0; j < RoomWidth; j++)
            {
                row.Add(0);
            }
            grid.Add(row);
        }
        //
        List <ShipPutInfo> l = GetShipBuildInfo(ShipBuildType.BuildRoom);

        for (int i = 0; i < l.Count; i++)
        {
            if (l[i] == info)
            {
                continue;
            }
            if (l[i].m_DeckRoom == true)
            {
                continue;
            }
            List <Int2> shape = l[i].GetPutRoomGridPos();

            foreach (Int2 Pos in shape)
            {
                grid[Pos.Layer][Pos.Unit] = 1;
            }
        }
        Canvans.SetShape(grid);
    }