예제 #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((269 + Level * 23 + BatchId.GetHashCode()) * 23 + CellId.GetHashCode());
     }
 }
예제 #2
0
 public Cell(CellId id, CellStatus cellStatus, Side side, CellId[] connections)
 {
     Id          = id;
     Connections = (CellId[])connections.Clone();
     this.Side   = side;
     this.Status = cellStatus;
 }
예제 #3
0
 /// <summary>Serves as a hash function for the CellInfo type.</summary>
 /// <returns>A hash code for the current CellInfo.</returns>
 public override int GetHashCode()
 {
     if (CellId != null)
     {
         return(CellId.GetHashCode());
     }
     return(base.GetHashCode());
 }
예제 #4
0
    void destroyCannotMoveDebugCube(int xIndex, int zIndex)
    {
        CellId[] cellsId = canNotMoveInst.GetComponentsInChildren <CellId>();
        CellId   first   = System.Array.Find(cellsId, c => c.CellX == xIndex && c.CellZ == zIndex);

        if (first != null)
        {
            Destroy(first.gameObject);
        }
    }
예제 #5
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hash = BatchId != null?BatchId.GetHashCode() : 0;

                hash = (hash * 397) ^ (CellId != null ? CellId.GetHashCode() : 0);
                hash = (hash * 397) ^ Level;
                return(hash);
            }
        }
예제 #6
0
    void drawCannotMoveDebugCube(CellData cell)
    {
        GameObject debugGo = Instantiate(CannotMovablePrefab);
        Vector3    pos     = mapController.GetCellPosition(cell.Xpos, cell.Zpos);

        debugGo.transform.parent     = canNotMoveInst.transform;
        debugGo.transform.localScale = new Vector3(MapSetting.CELL_UNIT_SIZE, cell.GetHeightest() * 0.5f, MapSetting.CELL_UNIT_SIZE);
        debugGo.transform.position   = new Vector3(pos.x, pos.y * 0.5f + 0.1f, pos.z);
        CellId cellId = debugGo.AddComponent <CellId>();

        cellId.CellX = cell.Xpos;
        cellId.CellZ = cell.Zpos;
    }
예제 #7
0
    void destroyPerson(int xIndex, int zIndex, bool playerOrEnemy)
    {
        bool isRemove = playerOrEnemy ? MapPositioningManager.instance.RemovePositioning(MapPositioningType.PLAYER, xIndex, zIndex) :
                        MapPositioningManager.instance.RemovePositioning(MapPositioningType.ENEMY, xIndex, zIndex);

        if (isRemove)
        {
            CellId[] cellsId = canNotMoveInst.GetComponentsInChildren <CellId>();
            CellId   first   = System.Array.Find(cellsId, c => c.CellX == xIndex && c.CellZ == zIndex && c.PlayerOrEnemy == playerOrEnemy);
            if (first != null)
            {
                Destroy(first.gameObject);
            }
        }
    }
예제 #8
0
            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj))
                {
                    return(false);
                }
                if (obj.GetType() != typeof(CellId))
                {
                    return(false);
                }

                CellId other = (CellId)obj;

                return(VoxelMap == other.VoxelMap && Pos == other.Pos);
            }
예제 #9
0
    void drawPeople(Object prefab, int order, Quaternion rotation, int x, int z, bool playerOrEnemy)
    {
        GameObject debugGo = Instantiate(prefab) as GameObject;

        debugGo.transform.Find("Num").GetComponent <TextMesh>().text = order.ToString();
        Vector3 pos = mapController.GetCellPosition(x, z) + new Vector3(0, 1, 0);

        debugGo.transform.parent   = canNotMoveInst.transform;
        debugGo.transform.position = pos;
        debugGo.transform.rotation = rotation;
        CellId cellId = debugGo.AddComponent <CellId>();

        cellId.CellX         = x;
        cellId.CellZ         = z;
        cellId.PlayerOrEnemy = playerOrEnemy;
    }
예제 #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CellId != 0)
            {
                hash ^= CellId.GetHashCode();
            }
            if (TrainerId != 0L)
            {
                hash ^= TrainerId.GetHashCode();
            }
            if (EnergyCost != 0)
            {
                hash ^= EnergyCost.GetHashCode();
            }
            if (OrbCost != 0)
            {
                hash ^= OrbCost.GetHashCode();
            }
            if (X != 0)
            {
                hash ^= X.GetHashCode();
            }
            if (Y != 0)
            {
                hash ^= Y.GetHashCode();
            }
            if (Z != 0)
            {
                hash ^= Z.GetHashCode();
            }
            if (AbilityId != 0L)
            {
                hash ^= AbilityId.GetHashCode();
            }
            hash ^= conditionIds_.GetHashCode();
            if (ScheduleId.Length != 0)
            {
                hash ^= ScheduleId.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
예제 #11
0
        internal CellKey(string database, CellId cellId)
        {
            if (String.IsNullOrEmpty(database))
            {
                throw new ArgumentNullException("database");
            }

            if (cellId.RowId.IsNull)
            {
                throw new ArgumentException("Null ROWID in key.", "cellId");
            }
            if (cellId.ColumnOffset < 0)
            {
                throw new ArgumentOutOfRangeException("cellId", "The column offset in the key is smaller than zero.");
            }

            this.database = database;
            this.cellId   = cellId;
        }
 protected override DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo HasItem(CellId id)
 {
     throw new NotImplementedException();
 }
예제 #13
0
        private WorldPoint PollGsmNetwork()
        {
            WorldPoint point = new WorldPoint();

            if (CountryCode == 0 || NetworkCode == 0 || CellId == 0)
            {
                return(point);
            }
            if (cellCache == null)
            {
                cellCache = new List <CellInfo>();
            }

            CellInfo info = new CellInfo()
            {
                MCC = CountryCode, MNC = NetworkCode, LAC = AreaCode, CID = CellId
            };

            Debug.WriteLine("ID: " + CellId.ToString());
            int index = cellCache.IndexOf(info);

            if (index > -1)
            {
                info = cellCache[index];
            }
            else
            {
                Exception ex = null;
                bool      ok = false;

                if (!ok)
                {
                    try
                    {
                        ok = TranslateCellIdWithGoogle(info, false);
                        if (ok)
                        {
                            info.Service = FixService.Google;
                        }
                    }
                    catch (Exception ext) { ex = ext; }
                }

                if (!ok)
                {
                    ok = TranslateCellIdWithOpenCellId(info);
                    if (ok)
                    {
                        info.Service = FixService.OpenCellOrg;
                    }
                }

                if (!ok)
                {
                    try
                    {
                        ok = TranslateCellIdWithCellDb(info);
                        if (ok)
                        {
                            info.Service = FixService.CellDbOrg;
                        }
                    }
                    catch (Exception ext) { ex = ext; }
                }

                if (ok)
                {
                    cellCache.Add(info);
                }
                else if (ex != null)
                {
                    throw ex;
                }
                else
                {
                    info = null;
                }
            }
            if (info != null &&
                info.Lat.HasValue &&
                info.Lng.HasValue &&
                info.Lat.Value != 0 &&
                info.Lng.Value != 0)
            {
                point.Latitude  = info.Lat.Value;
                point.Longitude = info.Lng.Value;
                point.FixTime   = DateTime.UtcNow;
                FixService      = info.Service;
            }

            return(point);
        }
예제 #14
0
    /// <summary>
    /// 获取路径点数组
    /// </summary>
    void GetCellDir()
    {
        int row    = currRow;
        int column = currColumn;
        int id     = currCellId;

        cellList.Clear();
        cellList.Add(id);
        while (targetRow != row || targetColumn != column)
        {
            #region  斜线移动(禁用)

//                if (targetRow > row && targetColumn < column) //左下
//                {
//                    cellDir = CellId.DownLeft;
//                }
//                else if (targetRow > row && targetColumn == column) //下
//                {
//                    cellDir = CellId.Down;
//                }
//                else if (targetRow > row && targetColumn > column) //右下
//                {
//                    cellDir = CellId.DownRight;
//                }
//                else if (targetRow == row && targetColumn < column) //左边
//                {
//                    cellDir = CellId.Left;
//                }
//                else if (targetRow == row && targetColumn > column) //右边
//                {
//                    cellDir = CellId.Right;
//                }
//                else if (targetRow < row && targetColumn == column) //上边
//                {
//                    cellDir = CellId.Up;
//                }
//                else if (targetRow < row && targetColumn < column) //左上
//                {
//                    cellDir = CellId.UpLeft;
//                }
//                else if (targetRow < row && targetColumn > column) //右上
//                {
//                    cellDir = CellId.UpRight;
//                }

            #endregion

            #region 直线移动(只判断上下左右四个方向)

            //判断下一步的方向。(必须结合判断相应的障碍问题。)
            if (targetColumn < column)      //左
            {
                cellDir = CellId.Left;
            }
            else if (targetColumn > column)      //右
            {
                cellDir = CellId.Right;
            }
            else if (targetRow > row)      //上(在当前cell点的下面)
            {
                cellDir = CellId.Down;
            }
            else if (targetRow < row)      //下
            {
                cellDir = CellId.Up;
            }

            #endregion



            //进行id+row+column的处理,
            switch (cellDir)
            {
            case CellId.Up:
                id  -= mapGrid.y;
                row -= 1;
                break;

            case CellId.Right:
                id     += 1;
                column += 1;

                break;

            case CellId.Left:
                id     -= 1;
                column -= 1;

                break;

            case CellId.Down:
                id  += mapGrid.y;
                row += 1;
                break;

                #region 斜线处理(禁用)
//                    case CellId.DownLeft:
                //                        id +=mapGrid.y-1;
                //                        column -= 1;
                //                        row += 1;
                //                        break;
                //                    case CellId.DownRight:
                //                        id +=mapGrid.y+1;
                //                        column += 1;
                //                        row += 1;
                //                        break;
                //
                //                    case CellId.UpLeft:
                //                        id -= mapGrid.y+1;
                //                        column -= 1;
                //                        row -= 1;
                //                        break;
                //                    case CellId.UpRight:
                //                        id -= mapGrid.y-1;
                //                        column += 1;
                //                        row -= 1;
                //                        break;
                #endregion
            }

            //将id加入路径表。
            cellList.Add(id);
        }
    }
 public override string ToString()
 {
     return(CellId.ToString());
 }
 public override int GetHashCode()
 {
     return(CellId.GetHashCode());
 }
예제 #17
0
 public bool Equals(CellId other)
 {
     if (ReferenceEquals(this, other)) return true;
     return other._ninerId == _ninerId && other._withinNinerId == _withinNinerId;
 }
예제 #18
0
    void Start()
    {
        // create all cell-ids
        var maze = new HashSet <CellId>();

        for (int i = 0; i < w; ++i)
        {
            for (int j = 0; j < h; ++j)
            {
                maze.Add(new CellId(i, j));
            }
        }

        // start here
        var start = new CellId(0, 0);

        // seen these
        var seen = new HashSet <CellId>();

        seen.Add(start);
        var todo = new HashSet <CellId>(seen);

        var random = new System.Random(seed);

        // make the connections
        var links = new List <CellId[]>();

        while (seen.Count < maze.Count)         // while there are unvisited cells
        {
            var next = random.SelectRandom(todo);

            var neighbors = next.Neighbors;
            neighbors.RemoveWhere(e => seen.Contains(e));
            neighbors.RemoveWhere(e => !maze.Contains(e));

            if (0 == neighbors.Count)
            {
                todo.Remove(next);
                continue;
            }

            var link = random.SelectRandom(neighbors);

            links.Add(new CellId[] { next, link });
            seen.Add(link);
            todo.Add(link);
        }

        // create cell floors
        foreach (var next in seen)
        {
            var floor = Instantiate <GameObject>(random.SelectRandom(cells));

            floor.transform.parent        = transform;
            floor.transform.localPosition = next.ToVector3(span);

            floor.name = next.ToString();
        }

        // create cell bridges
        foreach (var next in links)
        {
            var where = 0.5f * (next[0].ToVector3(span) + next[1].ToVector3(span));

            var bridge = Instantiate <GameObject>(random.SelectRandom(this.links));

            bridge.transform.parent        = transform;
            bridge.transform.localPosition = where;

            bridge.name = next[0] + "<=>" + next[1];
        }
    }
예제 #19
0
 public override int GetHashCode()
 {
     return(CellId.GetHashCode() * SellItem.GetHashCode() * SellItemQty.GetHashCode());
 }