public static void Deallocate(CellData cell)
 {
     using (m_lock.AcquireExclusiveUsing())
     {
         m_pool.Deallocate(cell);
     }
 }
        // Public Methods (1)
        /// <summary>
        /// The data to render.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<IList<CellData>> Rows()
        {
            using (var sqlConnection = new SqlConnection(_connectionString))
            {
                using (var sqlCommand = new SqlCommand(_sql, sqlConnection) { CommandTimeout = 1200 })
                {
                    SqlParametersParser.ApplySafeParameters(sqlCommand, _sql, _paramValues);
                    sqlCommand.Connection.Open();

                    using (var sqlReader = sqlCommand.ExecuteReader())
                    {
                        while (sqlReader.Read())
                        {
                            var result = new List<CellData>();
                            for (var i = 0; i < sqlReader.FieldCount; i++)
                            {
                                var value = sqlReader.GetValue(i);
                                var pdfCellData = new CellData
                                {
                                    PropertyName = sqlReader.GetName(i),
                                    PropertyValue = value == DBNull.Value ? null : value,
                                    PropertyIndex = i
                                };
                                result.Add(pdfCellData);
                            }
                            sqlReader.Close();
                            yield return result;
                        }
                    }
                }
            }
        }
 public void AddRequest(UInt64 cellId, CellData data, bool highPriority)
 {
     var cellRequest = new CellRequest() { CellId = cellId, Data = data };
     m_unsentRequests.Enqueue(cellRequest);
     
     data.State = CellState.Invalid;
     data.HighPriority = highPriority;
 }
示例#4
0
    public void Swap(CellData cellData, bool bSwapColor)
    {
        if (bSwapColor)
        {
            Utils.Swap(ref m_color, ref cellData.m_color);
        }

        Utils.Swap(ref m_rowNum, ref cellData.m_rowNum);
        Utils.Swap(ref m_colNum, ref cellData.m_colNum);
    }
示例#5
0
    public Grid(int rowses, int colsNum, CellData[,] initDatas)
    {
        m_rows = rowses;
        m_cols = colsNum;
        m_cellDatas = new CellData[rowses, colsNum];

        for (int row = 0; row < rowses; row++)
        {
            for (int col = 0; col < colsNum; col++)
            {
                m_cellDatas[row, col] = initDatas[row, col];
            }
        }
    }
示例#6
0
        // Public Methods (1)
        /// <summary>
        /// The data to render.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<IList<CellData>> Rows()
        {
            if (_dataTable == null) yield break;

            foreach (DataRow row in _dataTable.Rows)
            {
                var list = new List<CellData>();
                for (var i = 0; i < _columnsCount; i++)
                {
                    var pdfCellData = new CellData
                    {
                        PropertyName = _dataTable.Columns[i].ColumnName,
                        PropertyValue = row[i],
                        PropertyIndex = i
                    };
                    list.Add(pdfCellData);
                }
                yield return list;
            }
        }
        // Public Methods (1)
        /// <summary>
        /// The data to render.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<IList<CellData>> Rows()
        {
            if (!File.Exists(_filePath))
                throw new FileNotFoundException(_filePath + " file not found.");

            var connectionString = getConnectionString();

            using (var oleDbConnection = new OleDbConnection(connectionString))
            {
                using (var oleDbCommand = new OleDbCommand(_sql, oleDbConnection) { CommandTimeout = 1200 })
                {
                    SqlParametersParser.ApplySafeParameters(oleDbCommand, _sql, _paramValues);
                    oleDbCommand.Connection.Open();

                    using (var oleDbReader = oleDbCommand.ExecuteReader())
                    {
                        while (oleDbReader != null && oleDbReader.Read())
                        {
                            var result = new List<CellData>();
                            for (var i = 0; i < oleDbReader.FieldCount; i++)
                            {
                                var value = oleDbReader.GetValue(i);
                                var pdfCellData = new CellData
                                {
                                    PropertyName = oleDbReader.GetName(i),
                                    PropertyValue = (value == DBNull.Value) ? null : value,
                                    PropertyIndex = i
                                };
                                result.Add(pdfCellData);
                            }
                            oleDbReader.Close();
                            yield return result;
                        }

                    }
                }
            }
        }
        // Public Methods (1)
        /// <summary>
        /// The data to render.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<IList<CellData>> Rows()
        {
            var factory = DbProviderFactories.GetFactory(_providerName);
            using (var connection = factory.CreateConnection())
            {
                connection.ConnectionString = _connectionString;
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = _sql;
                    command.CommandType = CommandType.Text;

                    SqlParametersParser.ApplySafeParameters(command, _sql, _paramValues);

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var result = new List<CellData>();
                            for (var i = 0; i < reader.FieldCount; i++)
                            {
                                var value = reader.GetValue(i);
                                var pdfCellData = new CellData
                                {
                                    PropertyName = reader.GetName(i),
                                    PropertyValue = value == DBNull.Value ? null : value,
                                    PropertyIndex = i
                                };
                                result.Add(pdfCellData);
                            }
                            reader.Close();
                            yield return result;
                        }
                    }
                }
            }
        }
示例#9
0
    public void Init(int rowNum, int colNum, CellData[,] cellDatas)
    {

        if (cellDatas != null)
        {
            m_grid = new Grid(rowNum, colNum, cellDatas);
        }
        else
        {
            CellData[,] initDatas = new CellData[rowNum, colNum];

            // BgImage.sprite = createSprite("map");
            for (int row = 0; row < rowNum; row++)
            {
                for (int col = 0; col < colNum; col++)
                {
                    //create cellData
                    initDatas[row, col].Reset(row, col, CandyColor.None, CandyEffect.Normal);
                }
            }

            m_grid = new Grid(rowNum, colNum, initDatas);
        }
    }
示例#10
0
文件: Map.cs 项目: Sadikk/BlueSheep
 internal void Init(BigEndianReader reader)
 {
     reader.ReadByte();
     this.MapVersion = reader.ReadByte();
     this.Id = (int)reader.ReadUInt();
     if (this.MapVersion >= 7)
     {
         this.Encrypted = reader.ReadBoolean();
         this.EncryptedVersion = reader.ReadByte();
         int count = reader.ReadInt();
         if (this.Encrypted)
         {
             byte[] buffer = CustomHex.ToArray(CustomHex.FromString("649ae451ca33ec53bbcbcc33becf15f4", false));
             byte[] buffer2 = reader.ReadBytes(count);
             int num7 = (buffer2.Length - 1);
             int n = 0;
             while (n <= num7)
             {
                 buffer2[n] = Convert.ToByte((buffer2[n] ^ buffer[(n % buffer.Length)]));
                 n += 1;
             }
             reader = new BigEndianReader(buffer2);
         }
     }
     this.RelativeId = (int)reader.ReadUInt();
     this.MapType = reader.ReadByte();
     this.SubAreaId = reader.ReadInt();
     this.TopNeighbourId = reader.ReadInt();
     this.BottomNeighbourId = reader.ReadInt();
     this.LeftNeighbourId = reader.ReadInt();
     this.RightNeighbourId = reader.ReadInt();
     this.ShadowBonusOnEntities = reader.ReadInt();
     if (this.MapVersion >= 3)
     {
         this.BackgroundRed = reader.ReadByte();
         this.BackgroundGreen = reader.ReadByte();
         this.BackgroundBlue = reader.ReadByte();
     }
     if (this.MapVersion >= 4)
     {
         this.ZoomScale = (Convert.ToDouble(reader.ReadUShort()) / 100);
         this.ZoomOffsetX = reader.ReadShort();
         this.ZoomOffsetY = reader.ReadShort();
     }
     this.UseLowPassFilter = reader.ReadBoolean();
     this.UseReverb = reader.ReadBoolean();
     if (this.UseReverb)
     {
         this.PresetId = reader.ReadInt();
     }
     this.BackgroundsCount = reader.ReadByte();
     int backgroundsCount = this.BackgroundsCount;
     int i = 1;
     while (i <= backgroundsCount)
     {
         Fixture item = new Fixture();
         item.Init(reader);
         this.BackgroundFixtures.Add(item);
         i += 1;
     }
     this.ForegroundsCount = reader.ReadByte();
     int foregroundsCount = this.ForegroundsCount;
     int j = 1;
     while (j <= foregroundsCount)
     {
         Fixture fixture2 = new Fixture();
         fixture2.Init(reader);
         this.ForegroundFixtures.Add(fixture2);
         j += 1;
     }
     this.CellsCount = 560;
     reader.ReadInt();
     this.GroundCRC = reader.ReadInt().ToString();
     this.LayersCount = reader.ReadByte();
     int layersCount = this.LayersCount;
     int k = 1;
     while (k <= layersCount)
     {
         Layer layer = new Layer();
         layer.Init(reader, this.MapVersion);
         this.Layers.Add(layer);
         k += 1;
     }
     int cellsCount = this.CellsCount;
     int m = 1;
     uint oldMvtSys = 0;
     while (m <= cellsCount)
     {
         CellData data = new CellData();
         data.Init(reader, this.MapVersion);
         if (oldMvtSys == 0)
         {
             oldMvtSys = (uint)data.MoveZone;
         }
         if (data.MoveZone != oldMvtSys)
         {
             IsUsingNewMovementSystem = true;
         }
         this.Cells.Add(data);
         m += 1;
     }
 }
示例#11
0
        private void GetCellLineIntersectionOctree(ref VRage.Game.Models.MyIntersectionResultLineTriangle?result, ref Line modelSpaceLine, ref float?minDistanceUntilNow, CellData cachedDataCell, IntersectionFlags flags)
        {
            m_overlapElementCache.Clear();
            if (cachedDataCell.Octree != null)
            {
                Vector3 packedStart, packedEnd;
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.From, out packedStart);
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.To, out packedEnd);
                var ray = new Ray(packedStart, packedEnd - packedStart);
                cachedDataCell.Octree.GetIntersectionWithLine(ref ray, m_overlapElementCache);
            }

            for (int j = 0; j < m_overlapElementCache.Count; j++)
            {
                var i = m_overlapElementCache[j];

                if (cachedDataCell.VoxelTriangles == null) //probably not calculated yet
                {
                    continue;
                }

                // this should never happen
                if (i >= cachedDataCell.VoxelTriangles.Length)
                {
                    Debug.Assert(i < cachedDataCell.VoxelTriangles.Length);
                    continue;
                }

                MyVoxelTriangle voxelTriangle = cachedDataCell.VoxelTriangles[i];

                MyTriangle_Vertices triangleVertices;
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex0, out triangleVertices.Vertex0);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex1, out triangleVertices.Vertex1);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex2, out triangleVertices.Vertex2);

                Vector3 calculatedTriangleNormal = MyUtils.GetNormalVectorFromTriangle(ref triangleVertices);
                if (!calculatedTriangleNormal.IsValid())
                {
                    continue;
                }
                //We dont want backside intersections
                if (((int)(flags & IntersectionFlags.FLIPPED_TRIANGLES) == 0) &&
                    Vector3.Dot(modelSpaceLine.Direction, calculatedTriangleNormal) > 0)
                {
                    continue;
                }

                // AABB intersection test removed, AABB is tested inside BVH
                float?distance = MyUtils.GetLineTriangleIntersection(ref modelSpaceLine, ref triangleVertices);

                //  If intersection occured and if distance to intersection is closer to origin than any previous intersection
                if ((distance != null) && ((result == null) || (distance.Value < result.Value.Distance)))
                {
                    minDistanceUntilNow = distance.Value;
                    result = new VRage.Game.Models.MyIntersectionResultLineTriangle(ref triangleVertices, ref calculatedTriangleNormal, distance.Value);
                }
            }
        }
    /// <summary>ターゲットセルの周辺8マスを見て思考する</summary>
    private void シンプルに考える(CellData d)
    {
      d.Update();
      if (d.Val == 0 || d.Val == Opened) return;

      // 周囲の開いていないセル、旗が立っているセルを数える
      int cntNotYetOpen = 0;
      int cntFlag = 0;

      for (int i = 0; i < 8; i++)
      {
        int idx = d.Index + kinbo[i];
        int val = data[idx].Val;
        if (val == NotYetOpen) cntNotOpenBlockBuf[cntNotYetOpen++] = idx;
        else if (val == BombFlag) cntFlagBlockBuf[cntFlag++] = idx;
      }

      //周囲に十分な旗が立っているなら、周辺の開いていないセルを開く
      if (d.Val == cntFlag)
      {
        for (int i = 0; i < 8; i++)
        {
          int idx = d.Index + kinbo[i];
          if (data[idx].Val == NotYetOpen)
          {
            data[idx].Val = Opened;
            Move_Click(idx % BoardWidth - 1, idx / BoardWidth - 1, MouseButtons.Left);
            Thread.Sleep(SleepCnt);
            isUpdatedNowFrame = true;
          }
        }
      }

      // 旗が確定するなら、周辺に旗を立てる
      else if (d.Val == cntNotYetOpen + cntFlag)
      {
        for (int i = 0; i < cntNotYetOpen; i++)
        {
          int idx = cntNotOpenBlockBuf[i];
          data[idx].Val = BombFlag;
          data[idx].IsFix = true;
          for (int j = 0; j < 8; j++)
          {
            int hoge = idx + kinbo[j];
            if (data[hoge].Val > 0)
            {
              data[hoge].ChangedMawari();
            }
          }
          Move_Click(idx % BoardWidth - 1, idx / BoardWidth - 1, MouseButtons.Right);
          isUpdatedNowFrame = true;
          Thread.Sleep(SleepCnt);
        }
      }
    }
 void Start()
 {
     direction = new Vector2Int((int)transform.forward.x, (int)transform.forward.z);
     cellData  = new CellData(this.gameObject, 1);
     gameGrid.PlaceGameObjectOnCell(cellData, position.x, position.y);
 }
示例#14
0
 public static void InstantiateStructure(StructureData prototype, CellData cell)
 {
     StructureData.Instantiate(prototype, cell);
     PathGrid.Invalidate();
 }
示例#15
0
文件: ViewStatus.cs 项目: xqy/game
    /// <summary>
    /// 获取细胞下回动作
    /// </summary>
    /// <returns></returns>
    private int getCellNextTime()
    {
        int nextTime = int.MaxValue;
        outCellData = null;
        outCellStatus = CellStatus.NONE;
        int tentacleCount;
        int _time;

        foreach (CellData data in cellDataList)
        {
            _time = data.addTime + data.vo.addTime;
            if (nextTime > _time)
            {
                outCellStatus = CellStatus.ADD_HP;  //自然增长
                outCellData = data;
                nextTime = _time;
            }

            tentacleCount = data.tentacleList.Count;
            _time = (int)(data.outTime + data.vo.attackTime * tentacleCount * Mathf.Pow(CellConstant.ATTACK_COEFF, tentacleCount - 1));
            if (nextTime > _time && data.hp > tentacleCount && tentacleCount > 0)
            {
                outCellStatus = CellStatus.OUT_HP;  //往外输出
                outCellData = data;
                nextTime = _time;
            }
        }
        return nextTime;
    }
示例#16
0
        internal CellData GetCell(ref MyCellCoord cell)
        {
            MyPrecalcComponent.AssertUpdateThread();

            bool     isEmpty;
            CellData data;

            if (TryGetCell(cell, out isEmpty, out data))
            {
                return(data);
            }

            MyIsoMesh mesh;

            if (!TryGetMesh(cell, out isEmpty, out mesh))
            {
                ProfilerShort.Begin("Cell precalc");
                if (true)
                {
                    var min = cell.CoordInLod << MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
                    var max = min + MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS;
                    // overlap to neighbor; introduces extra data but it makes logic for raycasts simpler (no need to check neighbor cells)
                    min -= 1;
                    max += 2;
                    mesh = MyPrecalcComponent.IsoMesher.Precalc(m_storage, 0, min, max, false, MyFakes.ENABLE_VOXEL_COMPUTED_OCCLUSION, true);
                }
                else
                {
                    mesh = MyPrecalcComponent.IsoMesher.Precalc(new MyIsoMesherArgs()
                    {
                        Storage      = m_storage,
                        GeometryCell = cell,
                    });
                }
                ProfilerShort.End();
            }

            if (mesh != null)
            {
                data = new CellData();
                data.Init(
                    mesh.PositionOffset, mesh.PositionScale,
                    mesh.Positions.GetInternalArray(), mesh.VerticesCount,
                    mesh.Triangles.GetInternalArray(), mesh.TrianglesCount);
            }

            if (cell.Lod == 0)
            {
                using (m_lock.AcquireExclusiveUsing())
                {
                    if (data != null)
                    {
                        var key = cell.PackId64();
                        m_cellsByCoordinate[key] = data;
                    }
                    else
                    {
                        SetEmpty(ref cell, true);
                    }
                }
            }

            return(data);
        }
示例#17
0
    public static void SaveCurrentMapData()
    {
        GameObject go = GameObject.Find("HexGrid");

        if (go)
        {
            HexGrid hexGrid = go.GetComponent <HexGrid>();
            MapData mapData = ScriptableObject.CreateInstance <MapData>();
            mapData.width  = hexGrid.width;
            mapData.height = hexGrid.height;

            //analysis cell data
            HexCell[] results = hexGrid.transform.GetComponentsInChildren <HexCell>();
            if (results.Length > 0)
            {
                mapData.cellDatas = new List <CellData>(mapData.width * mapData.height);
                foreach (HexCell hexCell in results)
                {
                    CellData cellData = new CellData();
                    cellData.x           = hexCell.coordinates.X;
                    cellData.y           = hexCell.coordinates.Z;
                    cellData.waterLevel  = hexCell.WaterLevel;
                    cellData.elevation   = hexCell.Elevation;
                    cellData.terrainType = hexCell.terrainType;

                    mapData.cellDatas.Add(cellData);
                }
            }

            //analysis environment
            Transform env   = go.transform.Find("Environment");
            int       count = env.childCount;
            if (count > 0)
            {
                mapData.mapObjs = new List <MapObj>(count);
                for (int i = 0; i < count; i++)
                {
                    Transform child  = env.GetChild(i);
                    MapObj    mapObj = new MapObj();
                    mapObj.prefabName = "Prefabs/Tree01";
                    SimpleTransform simpleTransform = new SimpleTransform();
                    simpleTransform.position = child.localPosition;
                    simpleTransform.scale    = child.localScale;
                    simpleTransform.rotation = child.localRotation;
                    mapObj.transform         = simpleTransform;

                    mapData.mapObjs.Add(mapObj);
                }
            }

            //save mapData
#if UNITY_EDITOR
            string path = EditorUtility.SaveFilePanel("Save Map Data", Application.dataPath, "", "asset");
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            path = path.Replace(Application.dataPath, "Assets");

            AssetDatabase.CreateAsset(mapData, path);
#endif
        }
    }
示例#18
0
        /// <summary>
        /// 重新生成移动消耗
        /// </summary>
        //public void RecreateMoveConsumption()
        //{
        //    // 在构造函数内部用的Random初始化,
        //    // 有了数据后,这个地方将进行修改
        //    // m_MoveConsumption = new MoveConsumption(ClassType.Foot);
        //    MoveConsumptionInfoConfig config = MoveConsumptionInfoConfig.Get<MoveConsumptionInfoConfig>();
        //    MoveConsumptionInfo info = config[ClassType.Foot];
        //    m_MoveConsumption = new MoveConsumption(info);

        //    //Debug.LogFormat("{0}={1}, {2}={3}",
        //    //    TerrainType.Plain.ToString(),
        //    //    m_MoveConsumption[TerrainType.Plain].ToString(),
        //    //    TerrainType.Road.ToString(),
        //    //    m_MoveConsumption[TerrainType.Road].ToString());
        //}

        /// <summary>
        /// 当左键按下时,Move类型的活动
        /// </summary>
        /// <param name="selectedCell"></param>
        /// <returns></returns>
        public List <CellData> ShowMoveRangeCells(CellData selectedCell)
        {
            //List<CellData> cells = null;
            ClearTestCursors();

            //if (m_CursorCells.Count == 0 || !m_CursorCells.Contains(selectedCell))
            if (!selectedCell.hasMoveCursor)
            {
                if (m_DebugInfo)
                {
                    Debug.LogFormat("MoveRange: start {0}, move point {1}, status ({2})",
                                    selectedCell.position.ToString(),
                                    m_MovePoint.ToString(),
                                    selectedCell.GetStatus().ToString());
                }

                //ClearTestCursors();

                //m_CursorCells.Clear();
                m_TestClass.UpdatePosition(selectedCell.position);

                m_Map.SearchAndShowMoveRange(m_TestClass, m_PathfindingType == TestPathfindingType.MoveAndAttack);

                //cells = m_Map.SearchMoveRange(selectedCell, m_MovePoint, m_MoveConsumption);
                ////m_CursorCells.AddRange(cells);
                //CreateTestCursors(cells, false);

                //if (m_PathfindingType == TestPathfindingType.MoveAndAttack)
                //{
                //    // 移动范围后,进行查找攻击范围
                //    HashSet<CellData> attackCells = new HashSet<CellData>();
                //    foreach (var cell in cells.ToArray())
                //    {
                //        //foreach (var c in m_Map.SearchAttackRange(cell, m_AttackRange.x, m_AttackRange.y, true))
                //        //{
                //        //    //if (!cells.Contains(c) && !attackCells.Contains(c))
                //        //    if (!c.hasCursor)
                //        //    {
                //        //        attackCells.Add(c);
                //        //    }
                //        //}
                //        attackCells.UnionWith(
                //            m_Map.SearchAttackRange(cell, m_AttackRange.x, m_AttackRange.y, true)
                //            .Where(c => !c.hasCursor));
                //    }
                //    CreateTestCursors(attackCells, true);
                //}
            }
            else
            {
                if (m_DebugInfo)
                {
                    Debug.LogFormat("Selected end {0} status ({1})",
                                    selectedCell.position.ToString(),
                                    selectedCell.GetStatus().ToString());
                }
                //ClearTestCursors();
                //m_CursorCells.Clear();
                Stack <CellData> pathCells = m_Map.searchPath.BuildPath(selectedCell);
                //cells = new List<CellData>(pathCells);
                m_TestClass.animatorController.PlayMove();
                m_TestClass.StartMove(pathCells);

                //CreateTestCursors(cells, false);
                CreateTestCursors(pathCells, false);
            }

            //return cells;
            return(null);
        }
示例#19
0
        private void Update()
        {
            if (m_Map == null /*|| m_TestCursorPrefab == null*/)
            {
                return;
            }

            if (Input.anyKeyDown && m_TestClass.moving)
            {
                Debug.Log("Wait for moving.");
                return;
            }

            Vector3    mousePos     = Input.mousePosition;
            Vector3    world        = Camera.main.ScreenToWorldPoint(mousePos);
            Vector3Int cellPosition = m_Map.grid.WorldToCell(world);
            CellData   selectedCell = m_Map.GetCellData(cellPosition);

            // 左键建立范围
            if (Input.GetMouseButtonDown(0) && selectedCell != null && selectedCell.canMove)
            {
                if (m_AttackRange.x < 1 || m_AttackRange.y < m_AttackRange.x)
                {
                    Debug.LogError("EditorTestPathFinding -> Check the attack range.");
                    return;
                }

                if (selectedCell != null)
                {
                    switch (m_PathfindingType)
                    {
                    case TestPathfindingType.Move:
                    case TestPathfindingType.MoveAndAttack:
                        ShowMoveRangeCells(selectedCell);
                        break;

                    case TestPathfindingType.Path:
                        ClearTestCursors();
                        if (!ShowPathCells(selectedCell))
                        {
                            return;
                        }
                        break;

                    default:
                        ClearTestCursors();
                        ShowAttackRangeCells(selectedCell);
                        break;
                    }
                }
            }

            // 右键删除建立的cursor
            if (Input.GetMouseButtonDown(1))
            {
                ClearTestCursors();
                ClearMoveRangeAndPath();
            }

            // 中建重新生成移动消耗
            if (Input.GetMouseButtonDown(2))
            {
                //RecreateMoveConsumption();
            }

            // 刷新鼠标位置
            m_Map.mouseCursor.UpdatePosition(cellPosition);
        }
示例#20
0
 private void M_TestClass_onMovingEnd(CellData endCell)
 {
     m_TestClass.animatorController.StopMove();
 }
示例#21
0
            public Request ToGoogleSheetUpdateRequest()
            {
                GoogleSheetConnector gsc  = GoogleSheetConnector.GetInstance();
                string  talkSpreadsheetId = gsc.SpreadsheetIDs["Talk"];
                Request updateRequest     = new Request();

                var TextCellData = new CellData()
                {
                    UserEnteredValue = new ExtendedValue()
                    {
                        StringValue = Text
                    },
                    UserEnteredFormat = null
                };
                var Fields = "userEnteredValue";

                if (TextChanged)
                {
                    Fields = "userEnteredValue,userEnteredFormat";
                    if (TextMLTranslated)
                    {
                        TextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 1.0f,
                                Green = 0.66f,
                                Blue  = 0.0f
                            }
                        };
                    }
                    else
                    {
                        TextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 0.8f,
                                Green = 0.8f,
                                Blue  = 0.02f
                            }
                        };
                    }
                }

                var Rows = new List <RowData>
                {
                    new RowData()
                    {
                        Values = new List <CellData>()
                        {
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = DialogID
                                },
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = TalkerID
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = C
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = D
                                }
                            },

                            TextCellData,

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = OriginalText
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = PreviousOriginalText
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = NextDialogID
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = I
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = AlternativeNextDialogID
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = K
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = Script
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = SecondScript
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = TranslatorNotes
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = StandardizedTermLocator
                                }
                            },
                        },
                    },
                };

                if (row >= 1)
                {
                    updateRequest.UpdateCells = new UpdateCellsRequest
                    {
                        Range = new GridRange()
                        {
                            SheetId       = 0,
                            StartRowIndex = row,
                            EndRowIndex   = row + 1,
                        },
                        Rows   = Rows,
                        Fields = Fields
                    };
                }
                else
                {
                    updateRequest.AppendCells = new AppendCellsRequest
                    {
                        Rows    = Rows,
                        SheetId = 0,
                        Fields  = Fields
                    };
                }

                return(updateRequest);
            }
示例#22
0
    public List <CellData> GetCellInfo(CellData _data)
    {
        List <CellData> returnlist = new List <CellData>();

        return(returnlist);
    }
示例#23
0
 public static void InstantiateCeiling(CeilingData prototype, CellData cell)
 {
     CeilingData.Instantiate(prototype, cell);
     PathGrid.Invalidate();
 }
示例#24
0
        static CellData getCellDataForDetail(DoneDoneDetail detail)
        {
            var cellData = new CellData ();

            switch (detail) {
            case DoneDoneDetail.Images:
                cellData.BugDetailType = BugDetails.DetailType.Images;
                break;
            case DoneDoneDetail.Project:
                cellData.BugDetailType = BugDetails.DetailType.Selection;
                cellData.Set(DataKeys.Auxiliary, "Project *");
                cellData.Set(DataKeys.Title, "Project");
                break;
            case DoneDoneDetail.Title:
                cellData.BugDetailType = BugDetails.DetailType.TextField;
                cellData.Set(DataKeys.Auxiliary, "Title of Issue *");
                cellData.Set(DataKeys.Title, "Title");
                break;
            case DoneDoneDetail.Description:
                cellData.BugDetailType = BugDetails.DetailType.TextView;
                cellData.Set(DataKeys.Auxiliary, "Description of Issue *");
                cellData.Set(DataKeys.Title, "Description");
                break;
            case DoneDoneDetail.Priority:
                cellData.BugDetailType = BugDetails.DetailType.Selection;
                cellData.Set(DataKeys.Auxiliary, "Priority *");
                cellData.Set(DataKeys.Title, "Priority");
                break;
            case DoneDoneDetail.Fixer:
                cellData.BugDetailType = BugDetails.DetailType.Selection;
                cellData.Set(DataKeys.Auxiliary, "Who Will Fix the Issue?");
                cellData.Set(DataKeys.Title, "Fixer");
                break;
            case DoneDoneDetail.Tester:
                cellData.BugDetailType = BugDetails.DetailType.Selection;
                cellData.Set(DataKeys.Auxiliary, "Who Will Verify the Fix?");
                cellData.Set(DataKeys.Title, "Tester");
                break;
            case DoneDoneDetail.DueDate:
                cellData.BugDetailType = BugDetails.DetailType.DateDisplay;
                cellData.Set(DataKeys.Auxiliary, "Due Date");
                cellData.Set(DataKeys.Title, "Due Date");
                break;
            case DoneDoneDetail.Tags:
                cellData.BugDetailType = BugDetails.DetailType.Selection;
                cellData.Set(DataKeys.Auxiliary, "Tags");
                cellData.Set(DataKeys.Title, "Tags");
                break;
            case DoneDoneDetail.Notify:
                cellData.BugDetailType = BugDetails.DetailType.Selection;
                cellData.Set(DataKeys.Auxiliary, "Notify People of Updates");
                cellData.Set(DataKeys.Title, "Notify");
                break;
            }

            // cellData.Set(DataKeys.Detail, GetValueForDetail(detailIndex));

            return cellData;
        }
        private void GetCellLineIntersectionOctree(ref VRage.Game.Models.MyIntersectionResultLineTriangle? result, ref Line modelSpaceLine, ref float? minDistanceUntilNow, CellData cachedDataCell, IntersectionFlags flags)
        {
            m_overlapElementCache.Clear();
            if (cachedDataCell.Octree != null)
            {
                Vector3 packedStart, packedEnd;
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.From, out packedStart);
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.To, out packedEnd);
                var ray = new Ray(packedStart, packedEnd - packedStart);
                cachedDataCell.Octree.GetIntersectionWithLine(ref ray, m_overlapElementCache);
            }

            for (int j = 0; j < m_overlapElementCache.Count; j++)
            {
                var i = m_overlapElementCache[j];

                if (cachedDataCell.VoxelTriangles == null) //probably not calculated yet
                    continue;

                // this should never happen
                if (i >= cachedDataCell.VoxelTriangles.Length)
                {
                    Debug.Assert(i < cachedDataCell.VoxelTriangles.Length);
                    continue;
                }

                MyVoxelTriangle voxelTriangle = cachedDataCell.VoxelTriangles[i];

                MyTriangle_Vertexes triangleVertices;
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex0, out triangleVertices.Vertex0);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex1, out triangleVertices.Vertex1);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex2, out triangleVertices.Vertex2);

                Vector3 calculatedTriangleNormal = MyUtils.GetNormalVectorFromTriangle(ref triangleVertices);
                if (!calculatedTriangleNormal.IsValid())
                    continue;
                //We dont want backside intersections
                if (((int)(flags & IntersectionFlags.FLIPPED_TRIANGLES) == 0) &&
                    Vector3.Dot(modelSpaceLine.Direction, calculatedTriangleNormal) > 0)
                    continue;

                // AABB intersection test removed, AABB is tested inside BVH
                float? distance = MyUtils.GetLineTriangleIntersection(ref modelSpaceLine, ref triangleVertices);

                //  If intersection occured and if distance to intersection is closer to origin than any previous intersection
                if ((distance != null) && ((result == null) || (distance.Value < result.Value.Distance)))
                {
                    minDistanceUntilNow = distance.Value;
                    result = new VRage.Game.Models.MyIntersectionResultLineTriangle(ref triangleVertices, ref calculatedTriangleNormal, distance.Value);
                }
            }
        }
示例#26
0
        public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
        {
            CellData cell = (CellData)this.serializedObject.targetObject;

            if (cell == null)
            {
                return(null);
            }

            Texture2D tex = new Texture2D(width, height);

            Texture2D[] textures = new Texture2D[] {
                this.func(cell._floorOverlayTile),
                this.func(cell._objectTile),
                this.func(cell._objectOverlayTile),
            };
            Vector2Int texSize = Vector2Int.zero;

            Color[] rootCols = null;
            for (int i = 0; i < textures.Length; i++)
            {
                if (textures[i] == null)
                {
                    continue;
                }

                if (rootCols == null)
                {
                    rootCols = textures[i].GetPixels();
                    texSize  = new Vector2Int(textures[i].width, textures[i].height);
                }
                else
                {
                    // Add texture to the base
                    Color[] cols1 = textures[i].GetPixels();

                    if (rootCols.Length != cols1.Length)
                    {
                        Debug.LogWarning("[" + this.name + "] Can't make preview, tile sizes do not match.");
                        Debug.LogWarning(rootCols.Length + "    " + cols1.Length);
                        return(tex);
                    }

                    for (int j = 0; j < cols1.Length; ++j)
                    {
                        if (cols1[j].a != 0)
                        {
                            rootCols[j] = cols1[j];
                        }
                    }
                }
            }

            if (rootCols != null)
            {
                Texture2D root = new Texture2D(texSize.x, texSize.y);
                root.SetPixels(rootCols);
                root.Apply();

                EditorUtility.CopySerialized(root, tex);
                return(tex);
            }
            else
            {
                return(null);
            }
        }
示例#27
0
 public void SetCellData(CellData newData)
 {
     m_cellDatas[newData.RowNum, newData.ColNum] = newData;
 }
示例#28
0
 private bool ValidatePoolGrate(CellData cell)
 {
     return(true);
 }
示例#29
0
文件: ViewStatus.cs 项目: xqy/game
 /// <summary>
 /// 开始输出
 /// </summary>
 /// <param name="data"></param>
 private void outHp(CellData data)
 {
     TentacleData tentacleData;
     string key;
     foreach(int index in data.tentacleList)
     {
         if (data.index < index)
         {
             key = data.index + ":" + index;
             tentacleData = tentacleDataDic[key];
             if (tentacleData.nodeListA.Count > 0 && !tentacleData.nodeListA[0])
             {
                 tentacleData.nodeListA[0] = true;
                 data.hp--;
             }
         }
         else
         {
             key = index + ":" + data.index;
             tentacleData = tentacleDataDic[key];
             if (tentacleData.nodeListB.Count > 0 && !tentacleData.nodeListB[0])
             {
                 tentacleData.nodeListB[0] = true;
                 data.hp--;
             }
         }
     }
 }
示例#30
0
 public static void InstantiateFoundation(FoundationData prototype, CellData cell)
 {
     FoundationData.Instantiate(prototype, cell);
     PathGrid.Invalidate();
 }
 private static IntVector2?GetRandomAvailableCell(Dungeon dungeon, RoomHandler currentRoom, List <IntVector2> validCellsCached, int Clearence = 1, int ExitClearence = 10, bool avoidExits = false, bool avoidPits = true, bool PositionRelativeToRoom = false, bool isCactusDecoration = false)
 {
     if (dungeon == null | currentRoom == null | validCellsCached == null)
     {
         return(null);
     }
     try {
         if (validCellsCached.Count == 0)
         {
             for (int X = 0; X < currentRoom.area.dimensions.x; X++)
             {
                 for (int Y = 0; Y < currentRoom.area.dimensions.y; Y++)
                 {
                     bool       isInvalid      = false;
                     IntVector2 TargetPosition = new IntVector2(currentRoom.area.basePosition.x + X, currentRoom.area.basePosition.y + Y);
                     if (!validCellsCached.Contains(TargetPosition))
                     {
                         RoomHandler ActualRoom = dungeon.data.GetAbsoluteRoomFromPosition(TargetPosition);
                         for (int x = 0; x < Clearence; x++)
                         {
                             for (int y = 0; y < Clearence; y++)
                             {
                                 IntVector2 intVector = (TargetPosition + new IntVector2(x, y));
                                 if (dungeon.data.CheckInBoundsAndValid(intVector))
                                 {
                                     CellData cellData = dungeon.data[intVector];
                                     if (cellData.parentRoom == null | cellData.type != CellType.FLOOR | cellData.isOccupied | !cellData.IsPassable)
                                     {
                                         isInvalid = true;
                                     }
                                     if (ActualRoom != currentRoom | cellData.HasPitNeighbor(dungeon.data))
                                     {
                                         isInvalid = true;
                                     }
                                     if (cellData.cellVisualData.floorType == CellVisualData.CellFloorType.Water /*| cellData.cellVisualData.floorTileOverridden*/)
                                     {
                                         isInvalid = true;
                                     }
                                     if (cellData.HasWallNeighbor())
                                     {
                                         isInvalid = true;
                                     }
                                 }
                                 else
                                 {
                                     isInvalid = true;
                                 }
                             }
                         }
                         for (int x = 0; x < ExitClearence; x++)
                         {
                             for (int y = 0; y < ExitClearence; y++)
                             {
                                 IntVector2 intVector = (TargetPosition + new IntVector2(x, y));
                                 if (dungeon.data.CheckInBoundsAndValid(intVector))
                                 {
                                     CellData cellData = dungeon.data[intVector];
                                     if (cellData.isExitCell)
                                     {
                                         isInvalid = true;
                                     }
                                 }
                                 else
                                 {
                                     isInvalid = true;
                                 }
                             }
                         }
                         if (!isInvalid)
                         {
                             validCellsCached.Add(TargetPosition);
                         }
                     }
                 }
             }
         }
     } catch (System.Exception) {
         if (DebugMode)
         {
             Debug.Log("GetRandomAvailableCell Exception while looking for valid cells in current room.");
         }
     }
     if (validCellsCached.Count > 0)
     {
         IntVector2 SelectedCell = BraveUtility.RandomElement(validCellsCached);
         validCellsCached.Remove(SelectedCell);
         if (PositionRelativeToRoom)
         {
             SelectedCell -= currentRoom.area.basePosition;
         }
         return(SelectedCell);
     }
     else
     {
         return(null);
     }
 }
示例#32
0
 private void GenerateCellData()
 {
     for (int i = 0; i < 100; i++)
     {
         CellData _data = new CellData();
         _data.index = i;
         _listCellData.Add(_data);
     }
     CellCount = _listCellData.Count;
 }
示例#33
0
    private void ConvertCollectionToGameObject(CellData cellData)
    {
        GameObject        go           = new GameObject(cellData.roomName);
        CellManager       cm           = go.AddComponent <CellManager>();
        BoxCollider2D     backCollider = new BoxCollider2D();
        List <CellDoor>   doors        = new List <CellDoor>();
        List <GameObject> layers       = new List <GameObject>();

        for (int i = 0; i < cellData.textures.Length; i++)
        {
            //Create Layer and center it with parent
            GameObject layerObject = new GameObject("Layer:" + i.ToString());
            layerObject.transform.parent   = go.transform;
            layerObject.transform.position = Vector2.zero;

            //Add spriteRenderer Add sprite from texture
            SpriteRenderer spriteRenderer = layerObject.AddComponent <SpriteRenderer>();
            spriteRenderer.sprite = Sprite.Create(cellData.textures[i], new Rect(0, 0, cellData.textures[i].width, cellData.textures[i].height), new Vector2(0.5f, 0.5f), 100, 0, SpriteMeshType.Tight);

            //Sort DrawLayer
            if (cellData.layer[i] == 0)
            {
                spriteRenderer.sortingLayerName = "Background";
                layerObject.tag = "BackWall";
                layerObject.AddComponent <Rigidbody2D>().gravityScale = 0;
                backCollider           = layerObject.AddComponent <BoxCollider2D>();
                backCollider.isTrigger = true;
            }
            if (cellData.layer[i] == 1)
            {
                spriteRenderer.sortingLayerName = "Midground";
            }
            if (cellData.layer[i] == 2)
            {
                spriteRenderer.sortingLayerName = "Foreground";
            }
            //Add Collision
            if (cellData.collision[i])
            {
                PolygonCollider2D pc2d = layerObject.AddComponent <PolygonCollider2D>();
                if (cellData.points != null)
                {
                    pc2d.points = cellData.points;
                }
            }

            layers.Add(layerObject);
        }

        for (int i = 0; i < cellData.EntranceDir.Length; i++)
        {
            GameObject cellDoor = new GameObject("Cell Door " + cellData.EntranceDir[i]);
            CellDoor   cd       = cellDoor.AddComponent <CellDoor>();
            cellDoor.transform.parent        = go.transform;
            cellDoor.transform.localPosition = cellData.EntrancePos[i];
            cellDoor.AddComponent <BoxCollider2D>();
            cd.Dir      = cellData.EntranceDir[i];
            cd.backWall = backCollider;
            doors.Add(cd);
        }

        //Add and fill CellManager

        cm.cellData  = cellData;
        cm.Layers    = layers.ToArray();
        cm.CellDoors = doors.ToArray();
    }
示例#34
0
        public bool Intersects(ref BoundingSphereD localSphere)
        {
            MyPrecalcComponent.AssertUpdateThread();

            //  Get min and max cell coordinate where boundingBox can fit
            BoundingBoxD sphereBoundingBox = BoundingBoxD.CreateInvalid();

            sphereBoundingBox.Include(ref localSphere);
            Vector3I cellCoordMin, cellCoordMax;

            {
                Vector3D minD = sphereBoundingBox.Min;
                Vector3D maxD = sphereBoundingBox.Max;
                MyVoxelCoordSystems.LocalPositionToGeometryCellCoord(ref minD, out cellCoordMin);
                MyVoxelCoordSystems.LocalPositionToGeometryCellCoord(ref maxD, out cellCoordMax);
            }

            //  Fix min and max cell coordinates so they don't overlap the voxelmap
            ClampCellCoord(ref cellCoordMin);
            ClampCellCoord(ref cellCoordMax);

            MyCellCoord cell = new MyCellCoord();

            for (cell.CoordInLod.X = cellCoordMin.X; cell.CoordInLod.X <= cellCoordMax.X; cell.CoordInLod.X++)
            {
                for (cell.CoordInLod.Y = cellCoordMin.Y; cell.CoordInLod.Y <= cellCoordMax.Y; cell.CoordInLod.Y++)
                {
                    for (cell.CoordInLod.Z = cellCoordMin.Z; cell.CoordInLod.Z <= cellCoordMax.Z; cell.CoordInLod.Z++)
                    {
                        //  If no overlap between bounding box of data cell and the sphere
                        BoundingBox cellBoundingBox;
                        MyVoxelCoordSystems.GeometryCellCoordToLocalAABB(ref cell.CoordInLod, out cellBoundingBox);
                        if (cellBoundingBox.Intersects(ref localSphere) == false)
                        {
                            continue;
                        }

                        //  Get cell from cache. If not there, precalc it and store in the cache.
                        //  If null is returned, we know that cell doesn't contain any triangleVertexes so we don't need to do intersections.
                        CellData cachedData = GetCell(ref cell);

                        if (cachedData == null)
                        {
                            continue;
                        }

                        for (int i = 0; i < cachedData.VoxelTrianglesCount; i++)
                        {
                            MyVoxelTriangle voxelTriangle = cachedData.VoxelTriangles[i];

                            MyTriangle_Vertices triangle;
                            cachedData.GetUnpackedPosition(voxelTriangle.VertexIndex0, out triangle.Vertex0);
                            cachedData.GetUnpackedPosition(voxelTriangle.VertexIndex1, out triangle.Vertex1);
                            cachedData.GetUnpackedPosition(voxelTriangle.VertexIndex2, out triangle.Vertex2);

                            BoundingBox localTriangleAABB = BoundingBox.CreateInvalid();
                            localTriangleAABB.Include(ref triangle.Vertex0);
                            localTriangleAABB.Include(ref triangle.Vertex1);
                            localTriangleAABB.Include(ref triangle.Vertex2);

                            //  First test intersection of triangle's bounding box with line's bounding box. And only if they overlap or intersect, do further intersection tests.
                            if (localTriangleAABB.Intersects(ref localSphere))
                            {
                                PlaneD trianglePlane = new PlaneD(triangle.Vertex0, triangle.Vertex1, triangle.Vertex2);

                                if (MyUtils.GetSphereTriangleIntersection(ref localSphere, ref trianglePlane, ref triangle) != null)
                                {
                                    //  If intersection found - we are finished. We don't need to look for more.
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }
示例#35
0
 public void Initialize(CellData cellData)
 {
     _cellData = cellData;
 }
示例#36
0
            internal void DoClipping(Vector3D localPosition, float farPlaneDistance, RequestCollector collector)
            {
                MyClipmap.ComputeLodViewBounds(m_parent.m_scaleGroup, m_lodIndex, out m_nearDistance, out m_farDistance);

                m_fitsInFrustum = (farPlaneDistance * 1.25f) > m_nearDistance;

                if (!m_fitsInFrustum)
                    return;

                Vector3I min, max;
                {
                    var minD = localPosition - m_farDistance;
                    var maxD = localPosition + m_farDistance;
                    MyVoxelCoordSystems.LocalPositionToRenderCellCoord(ref minD, out min);
                    MyVoxelCoordSystems.LocalPositionToRenderCellCoord(ref maxD, out max);
                    Vector3I.Max(ref min, ref Vector3I.Zero, out min);
                    Vector3I.Max(ref max, ref Vector3I.Zero, out max);
                    min >>= m_lodIndex;
                    max >>= m_lodIndex;

                    Vector3I.Min(ref min, ref m_lodSizeMinusOne, out min);
                    Vector3I.Min(ref max, ref m_lodSizeMinusOne, out max);
                }

                if (m_lastMin == min && m_lastMax == max && !m_parent.m_updateClipping)
                    return;

                m_lastMin = min;
                m_lastMax = max;

                LodLevel parentLod, childLod;
                GetNearbyLodLevels(out parentLod, out childLod);

                // Moves cells which are still needed from one collection to another.
                // All that is left behind is unloaded as no longer needed.

                // Move everything in range to collection of next stored cells.
                MyUtils.Swap(ref m_storedCellData, ref m_clippedCells);
                m_storedCellData.Clear();
                MyCellCoord cell = new MyCellCoord(m_lodIndex, ref min);
                for (var it = new Vector3I.RangeIterator(ref min, ref max);
                    it.IsValid(); it.GetNext(out cell.CoordInLod))
                {
                    if (!WasAncestorCellLoaded(parentLod, ref cell))
                        continue;

                    var cellId = cell.PackId64();
                    CellData data;
                    if (m_clippedCells.TryGetValue(cellId, out data))
                        m_clippedCells.Remove(cellId);
                    else
                        data = new CellData();

                    if (data.State == CellState.Invalid)
                    {
                        collector.AddRequest(cellId, data.WasLoaded);
                        data.State = CellState.Pending;
                    }
                    m_storedCellData.Add(cellId, data);
                }
            }
示例#37
0
        // METHOD WHILE BUILDING
        #region Go to Cell
        /// <summary>
        /// Go to x position, so that it will reserve cell for further using
        /// </summary>
        /// <param name="x">x position that move current cell to</param>
        /// <returns>
        /// Current Row
        /// </returns>
        public CellData GoToCell(int x)
        {
            if (CurrentCell == null)
            {
                CurrentCell = new CellData(x);
                First = CurrentCell;
            }
            else if (CurrentCell.X < x)
            {
                #region When looking forward

                if (CurrentCell.Next == null)
                {
                    // when current cell is last
                    CurrentCell.Next = new CellData(x);
                    CurrentCell = CurrentCell.Next;
                }
                else
                {
                    #region current cell is not last, seek next
                    // sure that all cell have Next already (except the last)
                    do
                    {
                        // move next
                        TempCell = CurrentCell;
                        CurrentCell = CurrentCell.Next;
                        if (CurrentCell.X == x)
                        {
                            // if this exactly the cell that we finding
                            // exit the loop
                            break;
                        }
                        else if (CurrentCell.X > x)
                        {
                            // if this cell is not the last
                            // but next cell is greater than input value
                            // insert a new cell between
                            TempCell.Next = new CellData(x);
                            TempCell.Next.Next = CurrentCell;
                            CurrentCell = TempCell.Next;
                            break;
                        }
                        else if (CurrentCell.Next == null)
                        {
                            // if this cell is the last
                            // construct and return
                            CurrentCell.Next = new CellData(x);
                            CurrentCell = CurrentCell.Next;
                            break;
                        }
                    } while (true);
                    #endregion
                }
                #endregion
            }
            else if (CurrentCell.X > x)
            {
                #region search from begining
                if (First.X > x)
                {
                    // when this value is less than first cell
                    // construct one
                    CurrentCell = new CellData(x);
                    CurrentCell.Next = First;
                    First = CurrentCell;
                }
                else if (First.X == x)
                {
                    // else, it exactly the first
                    // keep it
                    CurrentCell = First;
                }
                else
                {
                    // finding from begining, except first one
                    CurrentCell = First;
                    #region OLD CODE
                    //                    do
                    //                    {
                    //                        TempCell = CurrentCell;
                    //                        CurrentCell = CurrentCell.Next;
                    //#if DEBUG
                    //                        #region Defensive
                    //                        if (CurrentCell == null)
                    //                        {
                    //                            Log.Warning(string.Format("Check 3: Current cell is null. Previous X: {0}, while x is {1}",TempCell.X,x));
                    //                        }
                    //                        #endregion
                    //#endif
                    //                        if (CurrentCell.X > x)
                    //                        {
                    //                            TempCell.Next = new CellData(x);
                    //                            TempCell.Next.Next = CurrentCell;
                    //                            CurrentCell = TempCell.Next;
                    //                            break;
                    //                        }
                    //                    } while (CurrentCell.X < x);
                    #endregion

                    #region Seek
                    // sure that all cell have Next already (except the last)
                    do
                    {
                        // move next
                        TempCell = CurrentCell;
                        CurrentCell = CurrentCell.Next;
#if DEBUG
                        #region Defensive
                        if (CurrentCell == null)
                        {
                            Log.Warning("Check 1: Current cell is null");
                        }
                        #endregion
#endif

                        if (CurrentCell.X == x)
                        {
                            // if this exactly the cell that we finding
                            // exit the loop
                            break;
                        }
                        else if (CurrentCell.X > x)
                        {
                            // if this cell is not the last
                            // but next cell is greater than input value
                            // insert a new cell between
                            TempCell.Next = new CellData(x);
                            TempCell.Next.Next = CurrentCell;
                            CurrentCell = TempCell.Next;
                            break;
                        }
                        else if (CurrentCell.Next == null)
                        {
                            // if this cell is the last
                            // construct and return
                            CurrentCell.Next = new CellData(x);
                            CurrentCell = CurrentCell.Next;
                            break;
                        }
                    } while (true);
                    #endregion
                }
                #endregion
            }

            #region Defensive
#if DEBUG
            if (CurrentCell == null)
            {
                Log.Debug("Unepected result.Can not found correct cell for X ({0}).", x);
                #region Log other cell in current row
                Log.Debug("Test");
                object scope = Log.Start("Datas in row:");
                CellData cell = First;
                while (cell != null)
                {
                    Log.Debug("Cell:X {0}", cell.X);
                    cell = cell.Next;
                }
                Log.End(scope);
                #endregion
            }
#endif
            #endregion
            return CurrentCell;
        }
示例#38
0
            internal void DoClipping(Vector3D localPosition, float farPlaneDistance, RequestCollector collector)
            {
                MyClipmap.ComputeLodViewBounds(m_parent.m_scaleGroup, m_lodIndex, out m_nearDistance, out m_farDistance);

                m_fitsInFrustum = (farPlaneDistance * 1.25f) > m_nearDistance;

                if (!m_fitsInFrustum)
                    return;

                Vector3I min, max;
                {
                    var minD = localPosition - m_farDistance;
                    var maxD = localPosition + m_farDistance;
                    MyVoxelCoordSystems.LocalPositionToRenderCellCoord(ref minD, out min);
                    MyVoxelCoordSystems.LocalPositionToRenderCellCoord(ref maxD, out max);
                    Vector3I.Max(ref min, ref Vector3I.Zero, out min);
                    Vector3I.Max(ref max, ref Vector3I.Zero, out max);
                    min >>= m_lodIndex;
                    max >>= m_lodIndex;

                    Vector3I.Min(ref min, ref m_lodSizeMinusOne, out min);
                    Vector3I.Min(ref max, ref m_lodSizeMinusOne, out max);
                }

                if (m_lastMin == min && m_lastMax == max && !m_parent.m_updateClipping)
                    return;

                m_lastMin = min;
                m_lastMax = max;

                LodLevel parentLod, childLod;
                GetNearbyLodLevels(out parentLod, out childLod);

                // Moves cells which are still needed from one collection to another.
                // All that is left behind is unloaded as no longer needed.

                // Move everything in range to collection of next stored cells.
                MyUtils.Swap(ref m_storedCellData, ref m_clippedCells);
                m_storedCellData.Clear();
                MyCellCoord cell = new MyCellCoord(m_lodIndex, ref min);
                for (var it = new Vector3I.RangeIterator(ref min, ref max);
                    it.IsValid(); it.GetNext(out cell.CoordInLod))
                {
                    if (!WasAncestorCellLoaded(parentLod, ref cell))
                        continue;

                    var cellId = cell.PackId64();
                    CellData data;
                    if (m_clippedCells.TryGetValue(cellId, out data))
                        m_clippedCells.Remove(cellId);
                    else
                        data = new CellData();

                    if (data.State == CellState.Invalid)
                    {
                        collector.AddRequest(cellId, data.WasLoaded);
                        data.State = CellState.Pending;
                    }
                    m_storedCellData.Add(cellId, data);
                }
            }
    /// <summary>盤面、描画に関する情報を初期化します</summary>
		private void Reset()
    {
      for (int i = 0; i < data.Length; i++)
      {
        data[i] = new CellData();
        data[i].Init();
        data[i].Index = i;
        int y = i / BoardWidth;
        int x = i % BoardWidth;
        if (y == 0 || y == BoardHeight - 1 || x == 0 || x == BoardWidth - 1)
        {
          data[i].Val = Invalid;
        }
        data[i].Update();
      }
      outputImg.Rectangle(new CvRect(0, 0, outputImg.Width, outputImg.Height), new CvScalar(127, 127, 127, 255), -1);
    }
示例#40
0
 private void AddToScene(UInt64 key, CellData data = null)
 {
     data = data ?? m_storedCellData[key];
     if (!data.InScene)
     {
         Debug.Assert(data.Cell != null);
         m_parent.m_cellHandler.AddToScene(data.Cell);
         data.InScene = true;
     }
 }
示例#41
0
 /// <summary>
 /// Check whether the cell is overlapped with another cell
 /// </summary>
 public bool IsCellOverlapped(CellData cell)
 {
     return(false);
 }
示例#42
0
 private bool ValidateGroundGrass(CellData cell)
 {
     return(true);
 }
示例#43
0
 private void Delete(UInt64 key, CellData data = null)
 {
     data = data ?? m_storedCellData[key];
     if (data.Cell != null)
     {
         m_nonEmptyCells.Remove(key);
         RemoveFromScene(key, data);
         m_parent.m_cellHandler.DeleteCell(data.Cell);
     }
     m_storedCellData.Remove(key);
 }
示例#44
0
    public void OnCellShow(CellData cellRecord)
    {
        var cr = (ChatCellData)cellRecord;

        Message.text = cr.Message;
    }
示例#45
0
 private void RemoveFromScene(UInt64 key, CellData data = null)
 {
     data = data ?? m_storedCellData[key];
     if (data.InScene)
     {
         Debug.Assert(data.Cell != null);
         m_parent.m_cellHandler.RemoveFromScene(data.Cell);
         data.InScene = false;
     }
 }
示例#46
0
        void DoPolycountMap()
        {
            s_CellDatas.Clear();
            List <BoundsAndCount> meshBoundsAndCount = new List <BoundsAndCount>();
            Bounds levelBounds = new Bounds();

            Renderer[] allRenderers = GameObject.FindObjectsOfType <Renderer>();

            // Get level bounds and list of bounds & polycount
            for (int i = 0; i < allRenderers.Length; i++)
            {
                Renderer r = allRenderers[i];
                if (r.gameObject.GetComponent <IgnoreHeatMap>())
                {
                    continue;
                }

                levelBounds.Encapsulate(r.bounds);

                MeshRenderer mr = (r as MeshRenderer);
                if (mr)
                {
                    MeshFilter mf = r.GetComponent <MeshFilter>();
                    if (mf && mf.sharedMesh != null)
                    {
                        BoundsAndCount b = new BoundsAndCount();
                        b.Bounds = r.bounds;
                        b.Count  = mf.sharedMesh.triangles.Length / 3;

                        meshBoundsAndCount.Add(b);
                    }
                }
                else
                {
                    SkinnedMeshRenderer smr = (r as SkinnedMeshRenderer);
                    if (smr)
                    {
                        if (smr.sharedMesh != null)
                        {
                            BoundsAndCount b = new BoundsAndCount();
                            b.Bounds = r.bounds;
                            b.Count  = smr.sharedMesh.triangles.Length / 3;

                            meshBoundsAndCount.Add(b);
                        }
                    }
                }
            }

            Vector3    boundsBottomCorner = levelBounds.center - levelBounds.extents;
            Vector3Int gridResolution     = new Vector3Int(Mathf.CeilToInt((levelBounds.extents.x * 2f) / k_CellSize),
                                                           Mathf.CeilToInt((levelBounds.extents.y * 2f) / k_CellSize),
                                                           Mathf.CeilToInt((levelBounds.extents.z * 2f) / k_CellSize));

            int highestCount = 0;

            for (int x = 0; x < gridResolution.x; x++)
            {
                for (int y = 0; y < gridResolution.y; y++)
                {
                    for (int z = 0; z < gridResolution.z; z++)
                    {
                        CellData cellData = new CellData();

                        Vector3 cellCenter = boundsBottomCorner + (new Vector3(x, y, z) * k_CellSize) +
                                             (Vector3.one * k_CellSize * 0.5f);
                        cellData.Bounds = new Bounds(cellCenter, Vector3.one * k_CellSize);
                        for (int i = 0; i < meshBoundsAndCount.Count; i++)
                        {
                            if (cellData.Bounds.Intersects(meshBoundsAndCount[i].Bounds))
                            {
                                cellData.Count += meshBoundsAndCount[i].Count;
                            }
                        }

                        if (cellData.Count > highestCount)
                        {
                            highestCount = cellData.Count;
                        }

                        s_CellDatas.Add(cellData);
                    }
                }
            }

            for (int i = 0; i < s_CellDatas.Count; i++)
            {
                s_CellDatas[i].Ratio = (float)s_CellDatas[i].Count / (float)highestCount;
                Color col = Color.Lerp(Color.green, Color.red, s_CellDatas[i].Ratio);
                s_CellDatas[i].Color = col;
            }

            m_HeatmapIsCalculating = false;
            EditorUtility.ClearProgressBar();
        }
示例#47
0
        public CellData GetActiveCellDetails(int selectedIndex)
        {
            var fixer = ActiveDoneDoneDetail.IsPersonDetail() && NewIssue.Fixer.Id == ProjectPeople[selectedIndex].Id;
            var tester = ActiveDoneDoneDetail.IsPersonDetail() && NewIssue.Tester.Id == ProjectPeople[selectedIndex].Id;
            var ccdUser = ActiveDoneDoneDetail.IsPersonDetail() && NewIssue.CCdUsers.Contains(ProjectPeople[selectedIndex]);

            var cellData = new CellData ();

            switch (ActiveDoneDoneDetail) {

            case DoneDoneDetail.Project:
                cellData.Set(DataKeys.Title, Projects[selectedIndex].Value);
                cellData.Selected = Projects[selectedIndex].Id == NewIssue.Project.Id;
                break;
            case DoneDoneDetail.Priority:
                cellData.Set(DataKeys.Title, PriorityLevels[selectedIndex].Value);
                cellData.Selected = PriorityLevels[selectedIndex].Id == NewIssue.Priority.Id;
                break;
            case DoneDoneDetail.Fixer:
                var personFixer = ProjectPeople[selectedIndex];
                cellData.CellType = BugCellTypes.Person;
                cellData.Set(DataKeys.Title, personFixer.FullName);
                cellData.Set(DataKeys.Detail, !fixer ? tester ? "(tester)" : ccdUser ? "(CCd)" : "" : "");
                cellData.Set(DataKeys.Auxiliary, personFixer.Initials);
                cellData.Set(DataKeys.ImageUrl, personFixer.AvatarUrl);
                cellData.Selected = fixer;
                break;
            case DoneDoneDetail.Tester:
                var personTester = ProjectPeople[selectedIndex];
                cellData.CellType = BugCellTypes.Person;
                cellData.Set(DataKeys.Title, personTester.FullName);
                cellData.Set(DataKeys.Detail, !tester ? fixer ? "(fixer)" : ccdUser ? "(CCd)" : "" : "");
                cellData.Set(DataKeys.Auxiliary, personTester.Initials);
                cellData.Set(DataKeys.ImageUrl, personTester.AvatarUrl);
                cellData.Selected = tester;
                break;
            case DoneDoneDetail.Notify:
                var personNotify = ProjectPeople[selectedIndex];
                cellData.CellType = BugCellTypes.Person;
                cellData.Set(DataKeys.Title, personNotify.FullName);
                cellData.Set(DataKeys.Detail, fixer ? "(fixer)" : tester ? "(tester)" : "");
                cellData.Set(DataKeys.Auxiliary, personNotify.Initials);
                cellData.Set(DataKeys.ImageUrl, personNotify.AvatarUrl);
                cellData.Selected = ccdUser;
                break;
            case DoneDoneDetail.Tags:
                cellData.Set(DataKeys.Title, NewIssue.Project.Tags[selectedIndex].Value);
                cellData.Set(DataKeys.Detail, string.Format("({0})", NewIssue.Project.Tags[selectedIndex].NumberOfIssues));// "(\(String(NewIssue.Project.Tags[selectedIndex].NumberOfIssues)))");
                cellData.Selected = NewIssue.Tags.Contains(NewIssue.Project.Tags[selectedIndex]);
                break;
            default:
                break;
            }

            return cellData;
        }
        private void FormatColorCell()
        {
            int IDDM_Lop;

            for (int i = RowBegin; i <= fg.Rows.Count - 1; i++)
            {
                IDDM_Lop = int.Parse(fg[i, "IDDM_Lop"].ToString());
                indexCol = ColBegin;
                for (int j = 0; j <= dtTuan.Rows.Count - 1; j++)
                {
                    DataTable dtTemp = dtKeHoach.Copy();
                    dtTemp.DefaultView.RowFilter = "DM_LopID = " + IDDM_Lop.ToString() + " And IDXL_Tuan = " + dtTuan.Rows[j]["XL_TuanID"].ToString();
                    CellRange rg          = fg.GetCellRange(i, indexCol);
                    CellData  objCellData = new CellData();
                    if (!(fg[i, indexCol] == System.DBNull.Value))
                    {
                        mdtColor.DefaultView.RowFilter = "TenVietTat = '" + fg[i, indexCol].ToString() + "'";
                        if (dtTemp.DefaultView.Count > 0)
                        {
                            // Nếu ngày đang xét nằm trong khoảng có kế hoạch khác của tuần thì set IDKeHoachKhac cho ngày đó
                            for (int k = 0; k < dtTemp.DefaultView.Count; k++)
                            {
                                objCellData.NgayNghi = "" + dtTemp.DefaultView[k]["NgayNghi"];
                                //objCellData.dateDenNgay = (DateTime)dtTemp.DefaultView[k]["DenNgay"];
                                objCellData.KeHoachTruongID = int.Parse(dtTemp.DefaultView[k]["XL_KeHoachTruongID"].ToString());
                                objCellData.IDKeHoachKhac   = int.Parse(dtTemp.DefaultView[k]["IDXL_KeHoachKhac"].ToString());
                                objCellData.TenKeHoachKhac  = dtTemp.DefaultView[k]["TenKeHoachKhac"].ToString();
                                objCellData.TenVietTat      = dtTemp.DefaultView[k]["TenVietTat"].ToString();
                                objCellData.BuoiHoc         = dtTemp.DefaultView[0]["CaHoc"] == System.DBNull.Value ? -1 : int.Parse(dtTemp.DefaultView[0]["CaHoc"].ToString());
                                objCellData.IDPhongHoc      = dtTemp.DefaultView[0]["IDDM_PhongHoc"] == System.DBNull.Value ? 0 : int.Parse(dtTemp.DefaultView[0]["IDDM_PhongHoc"].ToString());
                                objCellData.TenPhongHoc     = dtTemp.DefaultView[0]["TenPhongHoc"].ToString();
                            }
                            //rg.Data = objCellData.TenVietTat;
                        }
                        // Nếu trên cell đã có dữ liệu kế hoạch khác thì gắn style cho cell đó
                        if (mdtColor.DefaultView.Count > 0)
                        {
                            //objCellData.BuoiHoc = dtKeHoach.DefaultView[0]["BuoiHoc"] == System.DBNull.Value ? -1 : int.Parse(dtKeHoach.DefaultView[0]["BuoiHoc"].ToString());
                            fg.SetCellStyle(i, indexCol, (CellStyle)htbCellStyle["MyCellStyle" + mdtColor.DefaultView[0]["XL_KeHoachKhacID"].ToString()]);
                        }
                        else
                        {
                            // Nếu Chưa có thì set style cho nó
                            if (dtTemp.DefaultView.Count > 0)
                            {
                                objCellData.BuoiHoc     = dtTemp.DefaultView[0]["CaHoc"] == System.DBNull.Value ? -1 : int.Parse(dtTemp.DefaultView[0]["CaHoc"].ToString());
                                objCellData.IDPhongHoc  = dtTemp.DefaultView[0]["IDDM_PhongHoc"] == System.DBNull.Value ? 0 : int.Parse(dtTemp.DefaultView[0]["IDDM_PhongHoc"].ToString());
                                objCellData.TenPhongHoc = dtTemp.DefaultView[0]["TenPhongHoc"].ToString();
                            }
                            else
                            {
                                DataTable dtTemp1 = dtKeHoach.Copy();
                                dtTemp1.DefaultView.RowFilter = "DM_LopID = " + IDDM_Lop.ToString();
                                objCellData.BuoiHoc           = dtTemp1.DefaultView[0]["CaHoc"] == System.DBNull.Value ? -1 : int.Parse(dtTemp1.DefaultView[0]["CaHoc"].ToString());
                                objCellData.IDPhongHoc        = dtTemp1.DefaultView[0]["IDDM_PhongHoc"] == System.DBNull.Value ? 0 : (int)dtTemp1.DefaultView[0]["IDDM_PhongHoc"];
                                objCellData.TenPhongHoc       = dtTemp1.DefaultView[0]["TenPhongHoc"].ToString();
                                objCellData.NgayNghi          = "" + dtTemp1.DefaultView[0]["NgayNghi"];
                            }
                            // SetCellStyle cho cell
                            fg.SetCellStyle(i, indexCol, (CellStyle)htbCellStyle["MyCellStyle" + (objCellData.BuoiHoc == 0 ? "Sang" : (objCellData.BuoiHoc == 1 ? "Chieu" : (objCellData.BuoiHoc == 2 ? "Toi" : "")))]);
                            if ("" + fg[i, indexCol] != "")
                            {
                                fg[i, indexCol] = EncodeCaHoc(fg[i, indexCol].ToString(), indexCol);
                            }
                        }
                    }
                    rg.UserData = objCellData;
                    indexCol++;
                }
            }
        }
        private bool TryGetCell(MyCellCoord cell, out bool isEmpty, out CellData nonEmptyCell)
        {
            MyPrecalcComponent.AssertUpdateThread();
            using (m_lock.AcquireSharedUsing())
            {
                if (IsEmpty(ref cell))
                {
                    isEmpty = true;
                    nonEmptyCell = null;
                    return true;
                }

                UInt64 key = cell.PackId64();
                if (m_cellsByCoordinate.TryGetValue(key, out nonEmptyCell))
                {
                    isEmpty = false;
                    return true;
                }

                isEmpty = default(bool);
                nonEmptyCell = default(CellData);
                return false;
            }
        }
        private void LuuKeHoach()
        {
            int IDTuan, currentIDTuan, c, IDDM_Lop;

            for (int r = RowBegin; r <= fg.Rows.Count - 1; r++)
            {
                IDDM_Lop = int.Parse(fg[r, "IDDM_Lop"].ToString());
                IDTuan   = int.Parse(fg[0, ColBegin].ToString());
                dtTuan.DefaultView.RowFilter = "XL_TuanID = " + IDTuan.ToString();
                c = ColBegin;
                while (c <= fg.Cols.Count - 1)
                {
                    CellRange rg          = fg.GetCellRange(r, c, r, c);
                    CellData  objCellData = (CellData)rg.UserData;
                    currentIDTuan = int.Parse(fg[0, c].ToString());
                    // Nếu vẫn là tuần đang xét thì sẽ lấy dữ liệu
                    if (IDTuan != currentIDTuan)
                    {
                        IDTuan = currentIDTuan;
                        dtTuan.DefaultView.RowFilter = "XL_TuanID = " + IDTuan.ToString();
                    }
                    if (rg.UserData != null)
                    {
                        if (objCellData.IDKeHoachKhac == -1)
                        {
                            if (objCellData.KeHoachTruongID > 0)
                            {
                                DeleteKeHoachTruongTuan(objCellData.KeHoachTruongID);
                            }
                        }
                        else
                        {
                            if (objCellData.Changed)
                            {
                                // Nếu có sự thay đổi trong kế hoạch và từ ca học -> nghỉ hoặc từ nghỉ -> ca học hoặc nghỉ -> nghỉ khác
                                // Từ nghỉ -> nghỉ khác thì update vào
                                if (objCellData.KeHoachTruongID > 0)
                                {
                                    // Nếu được thay thế bởi Kế hoạch nghỉ khác thì update
                                    //if (objCellData.IDKeHoachKhac > 0)
                                    //{
                                    pKeHoachTruongInfo = new XL_KeHoachTruongInfo();
                                    pKeHoachTruongInfo.XL_KeHoachTruongID = objCellData.KeHoachTruongID;
                                    pKeHoachTruongInfo.IDXL_KeHoachKhac   = objCellData.IDKeHoachKhac;
                                    pKeHoachTruongInfo.IDDM_Lop           = IDDM_Lop;
                                    pKeHoachTruongInfo.IDXL_Tuan          = IDTuan;
                                    pKeHoachTruongInfo.CaHoc         = objCellData.BuoiHoc;
                                    pKeHoachTruongInfo.IDDM_PhongHoc = objCellData.IDPhongHoc;
                                    pKeHoachTruongInfo.NgayNghi      = objCellData.NgayNghi;

                                    UpdateKeHoachTruongTuan(pKeHoachTruongInfo);
                                    //}
                                }
                                // Còn lại là Insert vào
                                else
                                {
                                    pKeHoachTruongInfo = new XL_KeHoachTruongInfo();
                                    pKeHoachTruongInfo.IDXL_KeHoachKhac = objCellData.IDKeHoachKhac;
                                    pKeHoachTruongInfo.IDDM_Lop         = IDDM_Lop;
                                    pKeHoachTruongInfo.IDXL_Tuan        = IDTuan;
                                    pKeHoachTruongInfo.CaHoc            = objCellData.BuoiHoc;
                                    pKeHoachTruongInfo.IDDM_PhongHoc    = objCellData.IDPhongHoc;
                                    pKeHoachTruongInfo.NgayNghi         = "" + objCellData.NgayNghi;

                                    objCellData.KeHoachTruongID = InsertKeHoachTruongTuan(pKeHoachTruongInfo);
                                }
                                objCellData.Changed = false;
                                rg.UserData         = objCellData;
                            }
                        }
                    }
                    c++;
                }
            }
        }
        internal CellData GetCell(ref MyCellCoord cell)
        {
            MyPrecalcComponent.AssertUpdateThread();

            bool isEmpty;
            CellData data;
            if (TryGetCell(cell, out isEmpty, out data))
            {
                return data;
            }

            MyIsoMesh mesh;
            if (!TryGetMesh(cell, out isEmpty, out mesh))
            {
                ProfilerShort.Begin("Cell precalc");
                if (true)
                {
                    var min = cell.CoordInLod << MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
                    var max = min + MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS;
                    // overlap to neighbor; introduces extra data but it makes logic for raycasts simpler (no need to check neighbor cells)
                    min -= 1;
                    max += 2;
                    mesh = MyPrecalcComponent.IsoMesher.Precalc(m_storage, 0, min, max, false, MyFakes.ENABLE_VOXEL_COMPUTED_OCCLUSION, true);
                }
                else
                {
                    mesh = MyPrecalcComponent.IsoMesher.Precalc(new MyIsoMesherArgs()
                    {
                        Storage = m_storage,
                        GeometryCell = cell,
                    });
                }
                ProfilerShort.End();
            }

            if (mesh != null)
            {
                data = new CellData();
                data.Init(
                    mesh.PositionOffset, mesh.PositionScale,
                    mesh.Positions.GetInternalArray(), mesh.VerticesCount,
                    mesh.Triangles.GetInternalArray(), mesh.TrianglesCount);
            }

            if (cell.Lod == 0)
            {
                using (m_lock.AcquireExclusiveUsing())
                {
                    if (data != null)
                    {
                        var key = cell.PackId64();
                        m_cellsByCoordinate[key] = data;
                    }
                    else
                    {
                        SetEmpty(ref cell, true);
                    }
                }
            }

            return data;
        }
示例#52
0
 public void Init(CellData cellData)
 {
     this.cellData  = cellData;
     spriteRenderer = GetComponent <SpriteRenderer>();
     originalScale  = gameObject.transform.localScale;
 }
示例#53
0
    /// <summary>
    /// 找出两个格子的方位
    /// </summary>
    /// <param name="cellData"></param>
    /// <param name="otherCellData"></param>
    /// <returns></returns>
    public CandyDirection CheckDirection(CellData cellData, CellData otherCellData)
    {
        if (cellData.Color == CandyColor.None || otherCellData.Color == CandyColor.None)
        {
            return CandyDirection.Other;
        }

        if (cellData.RowNum == otherCellData.RowNum)
        {
            if (cellData.ColNum - 1 == otherCellData.ColNum)
            {
                return CandyDirection.Left;
            }
            if (cellData.ColNum + 1 == otherCellData.ColNum)
            {
                return CandyDirection.Right;
            }
        }
        else if (cellData.ColNum == otherCellData.ColNum)
        {
            if (cellData.RowNum - 1 == otherCellData.RowNum)
            {
                return CandyDirection.Upper;
            }
            if (cellData.RowNum + 1 == otherCellData.RowNum)
            {
                return CandyDirection.Down;
            }
        }

        return CandyDirection.Other;
    }
示例#54
0
        public static RoomHandler AddCustomRuntimeRoom(PrototypeDungeonRoom prototype, bool addRoomToMinimap = true, bool addTeleporter = true, bool isSecretRatExitRoom = false, Action <RoomHandler> postProcessCellData = null, DungeonData.LightGenerationStyle lightStyle = DungeonData.LightGenerationStyle.STANDARD)
        {
            Dungeon     dungeon     = GameManager.Instance.Dungeon;
            GameObject  gameObject3 = (GameObject)UnityEngine.Object.Instantiate(BraveResources.Load("RuntimeTileMap", ".prefab"));
            tk2dTileMap component3  = gameObject3.GetComponent <tk2dTileMap>();
            string      str         = UnityEngine.Random.Range(10000, 99999).ToString();

            gameObject3.name           = "Breach_RuntimeTilemap_" + str;
            component3.renderData.name = "Breach_RuntimeTilemap_" + str + " Render Data";

            component3.Editor__SpriteCollection = dungeon.tileIndices.dungeonCollection;

            TK2DDungeonAssembler.RuntimeResizeTileMap(component3, 8, 8, component3.partitionSizeX, component3.partitionSizeY);

            GameObject  gameObject2 = (GameObject)UnityEngine.Object.Instantiate(BraveResources.Load("RuntimeTileMap", ".prefab"));
            tk2dTileMap component2  = gameObject2.GetComponent <tk2dTileMap>();
            //creepyRoom.OverrideTilemap = component;
            tk2dTileMap component4  = GameObject.Find("TileMap").GetComponent <tk2dTileMap>();
            tk2dTileMap mainTilemap = component4;

            //tk2dTileMap mainTilemap = dungeon.MainTilemap;

            if (mainTilemap == null)
            {
                ETGModConsole.Log("ERROR: TileMap object is null! Something seriously went wrong!", false);
                Debug.Log("ERROR: TileMap object is null! Something seriously went wrong!");
                return(null);
            }
            TK2DDungeonAssembler tk2DDungeonAssembler = new TK2DDungeonAssembler();

            tk2DDungeonAssembler.Initialize(dungeon.tileIndices);
            IntVector2 zero       = IntVector2.Zero;
            IntVector2 intVector  = new IntVector2(50, 50);
            int        x          = intVector.x;
            int        y          = intVector.y;
            IntVector2 intVector2 = new IntVector2(int.MaxValue, int.MaxValue);
            IntVector2 lhs        = new IntVector2(int.MinValue, int.MinValue);

            intVector2 = IntVector2.Min(intVector2, zero);
            IntVector2 intVector3 = IntVector2.Max(lhs, zero + new IntVector2(prototype.Width, prototype.Height)) - intVector2;
            IntVector2 b          = IntVector2.Min(IntVector2.Zero, -1 * intVector2);

            intVector3 += b;
            IntVector2 intVector4 = new IntVector2(dungeon.data.Width + x, x);
            int        newWidth   = dungeon.data.Width + x * 2 + intVector3.x;
            int        newHeight  = Mathf.Max(dungeon.data.Height, intVector3.y + x * 2);

            CellData[][] array = BraveUtility.MultidimensionalArrayResize <CellData>(dungeon.data.cellData, dungeon.data.Width, dungeon.data.Height, newWidth, newHeight);
            dungeon.data.cellData = array;
            dungeon.data.ClearCachedCellData();
            IntVector2 intVector5 = new IntVector2(prototype.Width, prototype.Height);
            IntVector2 b2         = zero + b;
            IntVector2 intVector6 = intVector4 + b2;
            CellArea   cellArea   = new CellArea(intVector6, intVector5, 0);

            cellArea.prototypeRoom = prototype;
            RoomHandler roomHandler = new RoomHandler(cellArea);

            for (int i = -x; i < intVector5.x + x; i++)
            {
                for (int j = -x; j < intVector5.y + x; j++)
                {
                    IntVector2 intVector7 = new IntVector2(i, j) + intVector6;
                    if ((i >= 0 && j >= 0 && i < intVector5.x && j < intVector5.y) || array[intVector7.x][intVector7.y] == null)
                    {
                        CellData cellData = new CellData(intVector7, CellType.WALL);
                        cellData.positionInTilemap        = cellData.positionInTilemap - intVector4 + new IntVector2(y, y);
                        cellData.parentArea               = cellArea;
                        cellData.parentRoom               = roomHandler;
                        cellData.nearestRoom              = roomHandler;
                        cellData.distanceFromNearestRoom  = 0f;
                        array[intVector7.x][intVector7.y] = cellData;
                    }
                }
            }
            dungeon.data.rooms.Add(roomHandler);
            try
            {
                roomHandler.WriteRoomData(dungeon.data);
            }
            catch (Exception)
            {
                ETGModConsole.Log("WARNING: Exception caused during WriteRoomData step on room: " + roomHandler.GetRoomName(), false);
            }
            try
            {
                dungeon.data.GenerateLightsForRoom(dungeon.decoSettings, roomHandler, GameObject.Find("_Lights").transform, lightStyle);
            }
            catch (Exception)
            {
                ETGModConsole.Log("WARNING: Exception caused during GeernateLightsForRoom step on room: " + roomHandler.GetRoomName(), false);
            }
            if (postProcessCellData != null)
            {
                postProcessCellData(roomHandler);
            }
            if (roomHandler.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.SECRET)
            {
                roomHandler.BuildSecretRoomCover();
            }
            GameObject  gameObject = (GameObject)UnityEngine.Object.Instantiate(BraveResources.Load("RuntimeTileMap", ".prefab"));
            tk2dTileMap component  = gameObject.GetComponent <tk2dTileMap>();
            string      str2       = UnityEngine.Random.Range(10000, 99999).ToString();

            gameObject.name                    = "Glitch_RuntimeTilemap_" + str;
            component.renderData.name          = "Glitch_RuntimeTilemap_" + str + " Render Data";
            component.Editor__SpriteCollection = dungeon.tileIndices.dungeonCollection;
            try
            {
                TK2DDungeonAssembler.RuntimeResizeTileMap(component, intVector3.x + y * 2, intVector3.y + y * 2, mainTilemap.partitionSizeX, mainTilemap.partitionSizeY);
                IntVector2 intVector8 = new IntVector2(prototype.Width, prototype.Height);
                IntVector2 b3         = zero + b;
                IntVector2 intVector9 = intVector4 + b3;
                for (int k = -y; k < intVector8.x + y; k++)
                {
                    for (int l = -y; l < intVector8.y + y + 2; l++)
                    {
                        tk2DDungeonAssembler.BuildTileIndicesForCell(dungeon, component, intVector9.x + k, intVector9.y + l);
                    }
                }
                RenderMeshBuilder.CurrentCellXOffset = intVector4.x - y;
                RenderMeshBuilder.CurrentCellYOffset = intVector4.y - y;
                component.ForceBuild();
                RenderMeshBuilder.CurrentCellXOffset    = 0;
                RenderMeshBuilder.CurrentCellYOffset    = 0;
                component.renderData.transform.position = new Vector3((float)(intVector4.x - y), (float)(intVector4.y - y), (float)(intVector4.y - y));
            }
            catch (Exception exception)
            {
                ETGModConsole.Log("WARNING: Exception occured during RuntimeResizeTileMap / RenderMeshBuilder steps!", false);
                Debug.Log("WARNING: Exception occured during RuntimeResizeTileMap/RenderMeshBuilder steps!");
                Debug.LogException(exception);
            }
            roomHandler.OverrideTilemap = component;
            for (int m = 0; m < roomHandler.area.dimensions.x; m++)
            {
                for (int n = 0; n < roomHandler.area.dimensions.y + 2; n++)
                {
                    IntVector2 intVector10 = roomHandler.area.basePosition + new IntVector2(m, n);
                    if (dungeon.data.CheckInBoundsAndValid(intVector10))
                    {
                        CellData currentCell = dungeon.data[intVector10];
                        TK2DInteriorDecorator.PlaceLightDecorationForCell(dungeon, component, currentCell, intVector10);
                    }
                }
            }
            Pathfinder.Instance.InitializeRegion(dungeon.data, roomHandler.area.basePosition + new IntVector2(-3, -3), roomHandler.area.dimensions + new IntVector2(3, 3));
            if (prototype.usesProceduralDecoration && prototype.allowFloorDecoration)
            {
                new TK2DInteriorDecorator(tk2DDungeonAssembler).HandleRoomDecoration(roomHandler, dungeon, mainTilemap);
            }
            roomHandler.PostGenerationCleanup();
            if (addRoomToMinimap)
            {
                roomHandler.visibility = RoomHandler.VisibilityStatus.VISITED;
                MonoBehaviour mono = new MonoBehaviour();
                mono.StartCoroutine(Minimap.Instance.RevealMinimapRoomInternal(roomHandler, true, true, false));
                if (isSecretRatExitRoom)
                {
                    roomHandler.visibility = RoomHandler.VisibilityStatus.OBSCURED;
                }
            }
            if (addTeleporter)
            {
                roomHandler.AddProceduralTeleporterToRoom();
            }
            if (addRoomToMinimap)
            {
                Minimap.Instance.InitializeMinimap(dungeon.data);
            }
            DeadlyDeadlyGoopManager.ReinitializeData();
            return(roomHandler);
        }
示例#55
0
文件: ViewStatus.cs 项目: xqy/game
    public ViewStatus(CellWarSceneDBVO vo, int time = 0)
    {
        this.vo = vo;
        this.time = time;

        char[] ch = new char[] { ',' };
        string[] campArr = vo.cellCamp.Split(ch);
        string[] hpArr = vo.cellHP.Split(ch);
        string[] xArr = vo.cellX.Split(ch);
        string[] yArr = vo.cellY.Split(ch);

        CellData cellData;
        for (int i = 0, len = campArr.Length; i < len; i++)
        {
            cellData = new CellData();
            cellData.index = i;
            cellData.addTime = time;
            cellData.outTime = time;
            cellData.hp = int.Parse(hpArr[i]);
            cellData.camp = (Camp)int.Parse(campArr[i]);
            cellData.position = new Vector2(int.Parse(xArr[i]), int.Parse(yArr[i]));
            cellDataList.Add(cellData);
        }
    }
        public void AddCells(GoogleSheetParameters googleSheetParameters, List <GoogleSheetRow> rows)
        {
            var requests = new BatchUpdateSpreadsheetRequest {
                Requests = new List <Request>()
            };

            var sheetId = GetSheetId(_sheetsService, _spreadsheetId, googleSheetParameters.SheetName);

            GridCoordinate gc = new GridCoordinate
            {
                ColumnIndex = googleSheetParameters.RangeColumnStart - 1,
                RowIndex    = googleSheetParameters.RangeRowStart - 1,
                SheetId     = sheetId
            };

            var request = new Request {
                UpdateCells = new UpdateCellsRequest {
                    Start = gc, Fields = "*"
                }
            };

            var listRowData = new List <RowData>();

            foreach (var row in rows)
            {
                var rowData      = new RowData();
                var listCellData = new List <CellData>();
                foreach (var cell in row.Cells)
                {
                    var cellData      = new CellData();
                    var extendedValue = new ExtendedValue {
                        StringValue = cell.CellValue
                    };

                    cellData.UserEnteredValue = extendedValue;
                    var cellFormat = new CellFormat {
                        TextFormat = new TextFormat()
                    };

                    if (cell.IsBold)
                    {
                        cellFormat.TextFormat.Bold = true;
                    }

                    cellFormat.BackgroundColor = new Color {
                        Blue = (float)cell.BackgroundColor.B / 255, Red = (float)cell.BackgroundColor.R / 255, Green = (float)cell.BackgroundColor.G / 255
                    };

                    cellData.UserEnteredFormat = cellFormat;
                    listCellData.Add(cellData);
                }
                rowData.Values = listCellData;
                listRowData.Add(rowData);
            }
            request.UpdateCells.Rows = listRowData;

            // It's a batch request so you can create more than one request and send them all in one batch. Just use reqs.Requests.Add() to add additional requests for the same spreadsheet
            requests.Requests.Add(request);

            _sheetsService.Spreadsheets.BatchUpdate(requests, _spreadsheetId).Execute();
        }
示例#57
0
文件: ViewStatus.cs 项目: xqy/game
 /// <summary>
 /// 细胞hp变化
 /// </summary>
 /// <param name="data">细胞</param>
 /// <param name="num">hp的变化量</param>
 /// <param name="camp">如果hp小于零,将转换的阵营</param>
 private void hpChange(CellData data, int num, Camp camp)
 {
     if (data.hp + num > 0)
     {
         data.hp += num;
     }
     else
     {
         data.hp = CellConstant.INIT_HP;
         data.camp = camp;
         retreatAllTentacles(data.index);
     }
 }
示例#58
0
 public virtual bool Validation(CellData cell)
 {
     Debug.LogError("Unhandled Validation Case");
     return(false);
 }
示例#59
0
文件: ViewStatus.cs 项目: xqy/game
 public CellData clone()
 {
     CellData data = new CellData();
     data.tentacleList = new List<int>(tentacleList);
     data.index = index;
     data.addTime = addTime;
     data.outTime = outTime;
     data.hp = hp;
     data.camp = camp;
     data.position = position;
     return data;
 }
示例#60
0
 private bool ValidatePit(CellData cell)
 {
     return(true);
 }