Пример #1
0
    /// <summary>
    /// 获取可放置区域
    /// </summary>
    public static List <Int2> GetCanPutArea(ShipBuildType type, bool bDeckRoom)
    {
        List <Int2> l = new List <Int2>();

        if (m_PutRoom.Count == 0)         //一个都未摆设,则所有区域都可以摆设了。
        {
            List <RoomGrid> ll = GetAllRoomGrid();
            foreach (RoomGrid g in ll)
            {
                l.Add(g.mPosRoomGrid);
            }
        }
        else          //根据现有的设置摆设区域。
        {
            if (type == ShipBuildType.Soldier)
            {
                List <RoomGrid> lAll = GetAllRoomGrid();
                foreach (RoomGrid r in lAll)
                {
                    if (r.CheckPosition((int)PutPosition.Soldier))
                    {
                        l.Add(r.mPosRoomGrid);
                    }
                }
                //List<RoomGrid>listRoomGrid = RoomMap.GetPutRoomGrid();
            }
            else if (type == ShipBuildType.BuildRoom)
            {
                if (bDeckRoom)
                {
                    foreach (RoomGrid r in m_DeckRoom)
                    {
                        if (r.CheckPosition((int)PutPosition.Floor))
                        {
                            l.Add(r.mPosRoomGrid);
                        }
                    }
                }
                else
                {
                    List <Int2>     listOld            = new List <Int2>();
                    List <Int2>     listNew            = new List <Int2>();
                    List <RoomGrid> listNoLinRoomGrid  = GetNoLinkRoom(listOld, listNew);
                    List <RoomGrid> listCanPutRoomGrid = new List <RoomGrid>();;
                    int             nCount             = m_PutRoom.Count;
                    for (int nCnt = 0; nCnt < nCount; nCnt++)
                    {
                        RoomGrid roolGrid = m_PutRoom[nCnt];
                        if (!listNoLinRoomGrid.Contains(roolGrid) && roolGrid.mPosRoomGrid.Layer < 4)
                        {
                            listCanPutRoomGrid.Add(roolGrid);
                        }
                    }
                    NDLink.JoinLink(new List <Int2>(), new List <Int2>(), listCanPutRoomGrid, m_RealMapSize);
                    l.AddRange(NDLink.GetCanPutArea());
                }
            }
        }
        return(l);
    }
Пример #2
0
 /// <summary>
 /// 获取移动到目标位置所占领的房间
 /// </summary>
 /// <param name="TargetPos">目的位置</param>
 public static List <RoomGrid> GetMovetoRoomGrid(CanvasCore core, Int2 TargetPos)
 {
     if (core.Data != null)
     {
         List <RoomGrid> l     = new List <RoomGrid>();
         ShapeType       shape = core.GetPutRoomShape();
         if (shape != null)
         {
             Dictionary <Int2, ShapeValue> lshape = shape.GetShapeData(TargetPos);
             foreach (Int2 Pos in lshape.Keys)
             {
                 RoomGrid r = RoomMap.FindRoomGrid(Pos, XYSYS.RoomGrid);
                 if (r != null)
                 {
                     l.Add(r);
                 }
             }
         }
         else
         {
             RoomGrid r = RoomMap.FindRoomGrid(TargetPos, XYSYS.MapGrid);
             if (r != null)
             {
                 l.Add(r);
             }
         }
         return(l);
     }
     return(new List <RoomGrid>());
 }
Пример #3
0
        public Room(MySqlDataReader reader)
        {
            Id              = reader.GetInt32("id");
            OwnerId         = reader.IsDBNull(reader.GetOrdinal("owner_id")) ? 0 : reader.GetInt32("owner_id");
            Name            = reader.GetString("name");
            Description     = reader.GetString("description");
            State           = (RoomState)Enum.Parse(typeof(RoomState), reader.GetString("state"));
            PlayersIn       = reader.GetInt32("players_in");
            PlayersMax      = reader.GetInt32("players_max");
            CategoryId      = reader.GetInt32("category_id");
            Model           = reader.GetString("model");
            CCTs            = reader.GetString("ccts");
            ShowOwner       = reader.GetBoolean("show_owner");
            AllPlayerRights = reader.GetBoolean("all_player_rights");
            Icon            = reader.GetString("icon");
            Floor           = reader.GetInt32("floor");
            Wallpaper       = reader.GetInt32("wallpaper");
            Landscape       = reader.GetDouble("landscape");
            UserRights      = new List <int>(JsonConvert.DeserializeObject <List <int> >(reader.GetString("user_rights")));
            if (Engine.Locator.RoomController.RoomMaps.TryGetValue(Model, out RoomMap map))
            {
                Map = map;
            }

            Actors = new ConcurrentDictionary <int, RoomActor>();

            ProcessComponent = new ProcessComponent(this);
            ProcessComponent.SetupRoomLoop();
            Grid = new RoomGrid(this);
        }
Пример #4
0
    /// <summary>
    /// 获取相邻区域的房间
    /// </summary>
    public static RoomGrid FindNeighbourRoomGrid(RoomGrid R, DIR dir)
    {
        if (R == null)
        {
            return(null);
        }
        Int2 Pos = R.mPosRoomGrid;

        if (dir == DIR.LEFT)
        {
            Pos.Unit -= 1;
            return(FindRoomGrid(Pos, XYSYS.RoomGrid));
        }
        else if (dir == DIR.RIGHT)
        {
            Pos.Unit += 1;
            return(FindRoomGrid(Pos, XYSYS.RoomGrid));
        }
        else if (dir == DIR.UP)
        {
            Pos.Layer += 1;
            return(FindRoomGrid(Pos, XYSYS.RoomGrid));
        }
        else if (dir == DIR.DOWN)
        {
            Pos.Layer -= 1;
            return(FindRoomGrid(Pos, XYSYS.RoomGrid));
        }
        return(null);
    }
Пример #5
0
    /// <summary>
    /// 获取每列最顶层连接房
    /// </summary>
    public static List <RoomGrid> GetTopmostLayerPutRoom()
    {
        List <RoomGrid>       l  = new List <RoomGrid>();
        Dictionary <int, int> ll = new Dictionary <int, int>();

        foreach (RoomGrid m in m_PutRoom)
        {
            Int2 Pos = m.mPosRoomGrid;
            if (ll.ContainsKey(Pos.Unit) == false)
            {
                ll.Add(Pos.Unit, Pos.Layer);
            }
            else
            {
                if (Pos.Layer > ll[Pos.Unit])
                {
                    ll[Pos.Unit] = Pos.Layer;
                }
            }
        }
        foreach (int unit in ll.Keys)
        {
            RoomGrid m = FindRoomGrid(new Int2(unit, ll[unit]), XYSYS.RoomGrid);
            if (m != null)
            {
                l.Add(m);
            }
        }
        return(l);
    }
Пример #6
0
    /// <summary>
    /// 获取未连接的兵
    /// </summary>
    public static List <CanvasCore> GetUnLinkSoldiers()
    {
        List <CanvasCore> lNoLinkCore = new List <CanvasCore>();
        List <Int2>       lGold       = new List <Int2>();
        int nRoomCount = m_Room.Count;
        int nRoomCnt   = 0;

        for (nRoomCnt = 0; nRoomCnt < nRoomCount; nRoomCnt++)
        {
            RoomGrid rRoomGrid = m_Room[nRoomCnt];
            if (rRoomGrid != null && !CheckDeckRoom(rRoomGrid))
            {
                CanvasCore cavasCore = rRoomGrid.GetBuildRoom();
                if (cavasCore != null && cavasCore.m_ID == RoomGrid.EMPTYGRIDID)
                {
                    List <CanvasCore> listOther = rRoomGrid.GetOtherBuild();
                    int nCanvasCoreCount        = listOther.Count;
                    int nCanvasCoreCnt          = 0;
                    for (nCanvasCoreCnt = 0; nCanvasCoreCnt < nCanvasCoreCount; nCanvasCoreCnt++)
                    {
                        CanvasCore coreOther = listOther[nCanvasCoreCnt];
                        if (coreOther != null && coreOther.m_type == ShipBuildType.Soldier)
                        {
                            lNoLinkCore.Add(coreOther);
                        }
                    }
                }
            }
        }
        return(lNoLinkCore);
    }
Пример #7
0
 public static void AddPutRoomGrid(RoomGrid r)
 {
     if (m_PutRoom.Contains(r) == false)
     {
         m_PutRoom.Add(r);
     }
 }
Пример #8
0
 /*
  * /// <summary>
  * /// 获取传送点
  * /// </summary>
  * private static bool GetTransPoint(Vector3 LocalPos,ref Int2 TransPointPoint)
  * {
  *      TransPointPoint = Int2.zero;
  *      //已摆设房间
  *      foreach (RoomGrid r in m_PutRoom)
  *      {
  *              if(r.CheckInArea (LocalPos ) == true)
  *              {
  *                      TransPointPoint = r.SoldierPos;
  *                      return true;
  *              }
  *      }
  *      //甲板房间
  *      foreach (RoomGrid r in m_DeckRoom)
  *      {
  *              if(r.CheckInArea (LocalPos ) == true)
  *              {
  *                      TransPointPoint = r.SoldierPos;
  *                      return true;
  *              }
  *      }
  *      return false;
  * }
  */
 /// <summary>
 /// 检查甲板房间,能放放置
 /// </summary>
 public static bool CheckCanPutDeckBuild(int buildingid, List <Int2> lPos)
 {
     //判断放置在甲板上面
     foreach (Int2 Pos in lPos)
     {
         RoomGrid R = FindRoomGrid(Pos, XYSYS.RoomGrid);
         if (R == null)
         {
             return(false);
         }
         if (CheckDeckRoom(R) == false)
         {
             return(false);
         }
     }
     //判断是否被占领
     foreach (Int2 Pos in lPos)
     {
         RoomGrid R = FindRoomGrid(Pos, XYSYS.RoomGrid);
         if (R == null)
         {
             return(false);
         }
         if (m_PutDeckRoom.Contains(R) == true)
         {
             if (R.buildingid != buildingid)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #9
0
    /// <summary>
    /// 设置参数(如传送门的传送点)
    /// </summary>
    void SetPara()
    {
        if (RoomMap.CheckRoomGridInBoat(m_roomGridTouchDown))
        {
            TouchMove tm = TouchMoveManager.GetCurTouchMove();
            if (tm)
            {
                Int2       paramPos = m_roomGridTouchDown.SoldierPos;
                CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom();
                tm.SetBuildParam(buildRoomCoreTouchDown, paramPos.Unit, paramPos.Layer);
                tm.SetBuildParaOver();
                //传送门 这里没获取到

                BuildProperty lifeobj = tm.GetComponent <BuildProperty>();
                if (lifeobj != null && lifeobj.GetModeType() == 1605)
                {
                    Building1605 b1605 = lifeobj.GetLife() as Building1605;
                    if (b1605 != null)
                    {
                        b1605.SetTransGate(paramPos);
                    }
                }
            }
        }
        else
        {
            NGUIUtil.ShowTipWndByKey("88800013");
        }
        m_roomGridTouchDown = null;
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        RoomGrid myScript = (RoomGrid)target;

        if (GUILayout.Button("CLEAR ROOM"))
        {
            myScript.ClearRoom();
        }

        newW = EditorGUILayout.IntField("New Width : ", newW);
        newH = EditorGUILayout.IntField("Nwe Height : ", newH);
        if (GUILayout.Button("RESIZE ROOM"))
        {
            myScript.ResizeRoom(newH, newW);
        }
        if (GUILayout.Button(" <-- UNDO "))
        {
            myScript.Undo();
        }
        if (GUILayout.Button(" REDO --> "))
        {
            myScript.Redo();
        }
        if (GUILayout.Button(" UPDATE REFERENCES "))
        {
            myScript.UpdateGridReferences();
        }

        if (GUILayout.Button("SHOW OCCUPIED BLOCKS"))
        {
            myScript.MarkAllOccupiedBlocks();
        }
    }
Пример #11
0
    /// <summary>
    /// 获取未连接的连接房
    /// </summary>
    public static List <RoomGrid> GetNoLinkRoom(List <Int2> lOld, List <Int2> lNew)
    {
        List <Int2> lGold      = new List <Int2>();
        int         nRoomCount = m_GoldRoom.Count;
        int         nRoomCnt   = 0;

        for (nRoomCnt = 0; nRoomCnt < nRoomCount; nRoomCnt++)
        {
            RoomGrid rRoomGrid = m_GoldRoom[nRoomCnt];
            if (rRoomGrid != null)
            {
                lGold.Add(rRoomGrid.mPosRoomGrid);
            }
        }

        List <Int2>     lGrid   = new List <Int2>();
        List <RoomGrid> lNoLink = new List <RoomGrid>();

        lGrid = NDLink.GetNoLinkGrid(lOld, lNew, lGold, m_PutRoom, m_RealMapSize);
        foreach (Int2 Pos in lGrid)
        {
            RoomGrid R = FindRoomGrid(Pos, XYSYS.RoomGrid);
            if (R != null)
            {
                lNoLink.Add(R);
            }
        }
        return(lNoLink);
    }
Пример #12
0
    void AddTileToScene(Vector2 createPosition, RoomGrid rg)
    {
        GameObject metaTile = (GameObject)Instantiate(currentTabList[tileSelectedID]);

        metaTile.transform.position = createPosition;
        rg.AddReferenceToBlock(metaTile, selectedItemTab);
    }
Пример #13
0
 public static void RemovePutRoomGrid(RoomGrid R)
 {
     if (m_PutRoom.Contains(R))
     {
         m_PutRoom.Remove(R);
     }
 }
Пример #14
0
    /// <summary>
    /// 删除一个楼梯区间的楼梯
    /// </summary>
    private static void DeleteStairAreaStair(int Layer, int Start, int End)
    {
        bool     haveStair           = false;
        int      distance            = 0;
        RoomGrid deleteStairRoomGrid = null;

        for (int unit = Start; unit <= End; unit++)
        {
            RoomGrid R = FindRoomGrid(new Int2(unit, Layer), XYSYS.RoomGrid);
            if (R != null && R.HaveStair())
            {
                if (haveStair == false)
                {
                    distance            = DistanceGold(R);
                    haveStair           = true;
                    deleteStairRoomGrid = R;
                }
                else if (deleteStairRoomGrid != null)
                {
                    int d = DistanceGold(R);
                    //删除距离近的楼梯
                    if (d <= distance)
                    {
                        R.RemovStair();
                    }
                    else
                    {
                        deleteStairRoomGrid.RemovStair();
                        deleteStairRoomGrid = R;
                        distance            = d;
                    }
                }
            }
        }
    }
Пример #15
0
 public static bool CheckRoomGridInBoat(RoomGrid roomGrid)
 {
     if (RoomMap.IsDeckRoom(roomGrid) || RoomMap.IsPutRoom(roomGrid))
     {
         return(true);
     }
     return(false);
 }
Пример #16
0
 public static bool IsPutDeckRoom(RoomGrid roomGrid)
 {
     if (roomGrid != null)
     {
         return(m_PutDeckRoom.Contains(roomGrid));
     }
     return(false);
 }
 public void SetBlockReferencePlayer(List <Coordinate> blocks, int tab, RoomGrid rg, int blockCount, float xdimen, float ydimen)
 {
     currentBlockGroup = blocks;
     type     = tab;
     roomGrid = rg;
     count    = blockCount;
     xDim     = xdimen;
     yDim     = ydimen;
 }
Пример #18
0
 //继承地图数据,
 public void InheritanceRoomGrid(RoomGrid R)
 {
     this.upMap         = R.upMap;
     this.downMap       = R.downMap;
     this.buildingid    = R.buildingid;
     this.m_CanPosition = GetCanPosition();
     this.m_Position    = (this.m_Position | R.m_Position);
     this.m_Child.AddRange(R.GetOtherBuild());
 }
 public void SetBlockReference(List <Coordinate> blocks, int tab, RoomGrid rg, int blockCount)
 {
     currentBlockGroup = blocks;
     type     = tab;
     roomGrid = rg;
     count    = blockCount;
     xDim     = (transform.Find("EditorHitbox").GetComponent <BoxCollider2D>().size.x / GameConstants.gridBlockWidth);
     yDim     = (transform.Find("EditorHitbox").GetComponent <BoxCollider2D>().size.y / GameConstants.gridBlockHeight);
 }
Пример #20
0
        internal Room(IRoomData roomData, IRoomModel model)
        {
            RoomData  = roomData;
            RoomModel = model;

            _cancellationToken = new CancellationTokenSource();
            RoomGrid           = new RoomGrid(RoomModel);
            _entityHandler     = new EntityHandler(this);
        }
Пример #21
0
 /// <summary>
 /// 拷贝摆设数据
 /// </summary>
 public void CopyPutData(RoomGrid R)
 {
     this.upMap         = R.upMap;
     this.downMap       = R.downMap;
     this.buildingid    = R.buildingid;
     this.m_CanPosition = GetCanPosition();
     this.m_Position    = R.m_Position;
     this.m_Child.Clear();
     this.m_Child.AddRange(R.GetOtherBuild());
 }
Пример #22
0
    public bool IsContainsRoomGrid(RoomGrid roomGrid)
    {
        List <RoomGrid> roomGrids = RoomMap.GetMovetoRoomGrid(m_Core, m_posMapGrid);

        if (roomGrids == null)
        {
            return(false);
        }
        return(roomGrids.Contains(roomGrid));
    }
Пример #23
0
 /// <summary>
 /// 判定点击格子区域是楼梯还是兵 (楼梯是格子上部1/3) UE已经确认
 /// </summary>
 public static ShipBuildType PickupShipBuildType(RoomGrid rGrid, Vector3 v3LocalPos, int layer)
 {
     if (v3LocalPos.y >= rGrid.LocalPos.y + RoomGrid.m_heigth * 0.667f)
     {
         return(ShipBuildType.BuildStair);
     }
     else
     {
         return(ShipBuildType.Soldier);
     }
 }
Пример #24
0
    void CheckTileRemoval()
    {
        Collider2D col;

        if (col = Physics2D.OverlapPoint(mousePos, roomLayer))
        {
            Vector2  center    = col.gameObject.transform.position;
            RoomGrid rg        = col.gameObject.GetComponent <RoomGrid>();
            Rect     eraseRect = new Rect(mousePos.x, mousePos.y, 25, 25);
            rg.EraseBlock(eraseRect, selectedItemTab, center);
        }
    }
Пример #25
0
 /// <summary>
 /// 更新金库数据
 /// </summary>
 public static void UpdateGoldRoomGrid(List <Int2> GoldPosList)
 {
     m_GoldRoom.Clear();
     foreach (Int2 P in GoldPosList)
     {
         RoomGrid r = FindRoomGrid(P, XYSYS.RoomGrid);
         if (r != null)
         {
             m_GoldRoom.Add(r);
         }
     }
 }
Пример #26
0
    public Int2 GetMousePosGrid()
    {
        Vector3  v3TouchScreenPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z);
        Vector3  v3TouchWorldPos  = Camera.main.ScreenToWorldPoint(v3TouchScreenPos);
        Vector3  v3Local          = BattleEnvironmentM.World2LocalPos(v3TouchWorldPos);
        RoomGrid roomGrid         = RoomMap.FindRoomGrid(v3Local);

        if (roomGrid == null)
        {
            return(new Int2(-1, -1));
        }
        return(roomGrid.mPosRoomGrid);
    }
Пример #27
0
    /// <summary>
    /// 距离金库的距离
    /// </summary>
    private static int DistanceGold(RoomGrid R)
    {
        int distance = 10000;

        foreach (RoomGrid r in m_GoldRoom)
        {
            int d = Mathf.Abs(R.mPosRoomGrid.Layer - r.mPosRoomGrid.Layer) + Mathf.Abs(R.mPosRoomGrid.Unit - r.mPosRoomGrid.Unit);
            if (d < distance)
            {
                distance = d;
            }
        }
        return(distance);
    }
Пример #28
0
    /// <summary>
    /// 获取局部坐标
    /// </summary>
    public static Vector3 GetRoomGridLocalPos(Int2 posMapGrid)
    {
        RoomGrid r = RoomMap.FindRoomGrid(posMapGrid, XYSYS.MapGrid);

        if (r != null)
        {
            Vector3 v = r.LocalPos;
            v.x += (posMapGrid.Unit % MapGrid.m_UnitRoomGridNum) * MapGrid.m_width;
            return(v);
        }
        else
        {
            return(Vector3.zero);
        }
    }
Пример #29
0
 /// <summary>
 /// 确认该区间是否需要楼梯,需要则计算楼梯的位置
 /// </summary>
 public static bool CheckStairPoint(int Layer, int Start, int End, ref Int2 StairPoint)
 {
     StairPoint = Int2.zero;
     for (int unit = Start; unit <= End; unit++)
     {
         RoomGrid R = FindRoomGrid(new Int2(unit, Layer), XYSYS.RoomGrid);
         if (R != null && R.HaveStair())
         {
             return(false);
         }
     }
     //计算需要楼梯的位置
     StairPoint = GetBestStairPoint(Layer, Start, End);
     return(true);
 }
Пример #30
0
 /// <summary>
 /// 移除甲板房间
 /// </summary>
 public static void RemoveDeckBuild(List <Int2> lPos)
 {
     foreach (Int2 Pos in lPos)
     {
         RoomGrid R = FindRoomGrid(Pos, XYSYS.RoomGrid);
         if (R != null)
         {
             if (m_PutDeckRoom.Contains(R) == true)
             {
                 R.buildingid = RoomGrid.EMPTYGRIDID;
                 m_PutDeckRoom.Remove(R);
             }
         }
     }
 }