当前位置: 首页>>代码示例>>C#>>正文


C# Vector3i类代码示例

本文整理汇总了C#中Vector3i的典型用法代码示例。如果您正苦于以下问题:C# Vector3i类的具体用法?C# Vector3i怎么用?C# Vector3i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Vector3i类属于命名空间,在下文中一共展示了Vector3i类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixCoords

		public static bool FixCoords(ref Vector3i chunk, ref Vector3i local) {
			bool changed = false;
			if(local.x < 0) {
				chunk.x--;
				local.x += OCChunk.SIZE_X;
				changed = true;
			}
			if(local.y < 0) {
				chunk.y--;
				local.y += OCChunk.SIZE_Y;
				changed = true;
			}
			if(local.z < 0) {
				chunk.z--;
				local.z += OCChunk.SIZE_Z;
				changed = true;
			}
			
			if(local.x >= OCChunk.SIZE_X) {
				chunk.x++;
				local.x -= OCChunk.SIZE_X;
				changed = true;
			}
			if(local.y >= OCChunk.SIZE_Y) {
				chunk.y++;
				local.y -= OCChunk.SIZE_Y;
				changed = true;
			}
			if(local.z >= OCChunk.SIZE_Z) {
				chunk.z++;
				local.z -= OCChunk.SIZE_Z;
				changed = true;
			}
			return changed;
		}
开发者ID:ngeiswei,项目名称:unity3d-opencog-game,代码行数:35,代码来源:OCChunk.cs

示例2: UpdateLight

		private static void UpdateLight(OCMap map, Vector3i pos) {
	        list.Clear();
			foreach(Vector3i dir in Vector3i.directions) {
				list.Add( pos + dir );
			}
	        Scatter(map, list);
		}
开发者ID:ngeiswei,项目名称:unity3d-opencog-game,代码行数:7,代码来源:OCSunLightComputer.cs

示例3: DestroyBlock

	//NOTE: this function pulls the weight of actually destroying blocks for us. It is applied to the OCActions of a character; not to blocks themselves. 
	public void DestroyBlock(Vector3i? point)
	{
		if(point.HasValue)
		{
			OCMap map = OCMap.Instance;//(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault();
			
			//for updating goal controllers after deletion.
			OCBlock blockType = map.GetBlock(point.Value).block;
			OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController));
			
			//actually sets the block to null and recomputes the chunk. 
			Debug.Log(OCLogSymbol.DEBUG + "DeleteSelectedVoxel called from CreateBlockEffect");
			GameManager.world.voxels.DeleteSelectedVoxel(point.Value);
			
			//re-update goals concerned with this block type
			foreach(OCGoalController goalController in goalControllers)
			{
				if(goalController.GoalBlockType == blockType)
				{
					goalController.FindGoalBlockPositionInChunks(map.GetChunks());
				}
			}

			blocksDestroyed++;
		}
	}
开发者ID:virneo,项目名称:unity3d-opencog-game,代码行数:27,代码来源:OCDestroyBlockEffect.cs

示例4: RecomputeLightAtPosition

		public static void RecomputeLightAtPosition(OCMap map, Vector3i pos) {
			OCSunLightMap lightmap = map.GetSunLightmap();
			int oldSunHeight = lightmap.GetSunHeight(pos.x, pos.z);
			ComputeRayAtPosition(map, pos.x, pos.z);
			int newSunHeight = lightmap.GetSunHeight(pos.x, pos.z);
			
			if(newSunHeight < oldSunHeight) { // свет опустился
				// добавляем свет
				list.Clear();
	            for (int ty = newSunHeight; ty <= oldSunHeight; ty++) {
					pos.y = ty;
	                lightmap.SetLight(MIN_LIGHT, pos);
	                list.Add( pos );
	            }
	            Scatter(map, list);
			}
			if(newSunHeight > oldSunHeight) { // свет поднялся
				// удаляем свет
				list.Clear();
	            for (int ty = oldSunHeight; ty <= newSunHeight; ty++) {
					pos.y = ty;
					list.Add( pos );
	            }
	            RemoveLight(map, list);
			}
			
			if(newSunHeight == oldSunHeight) {
				if( map.GetBlock(pos).IsAlpha() ) {
					UpdateLight(map, pos);
				} else {
					RemoveLight(map, pos);
				}
			}
		}
开发者ID:ngeiswei,项目名称:unity3d-opencog-game,代码行数:34,代码来源:OCSunLightComputer.cs

示例5: DistanceSqr

	public int DistanceSqr(Vector3i other)
	{
		int x2 = x - other.x,
			y2 = y - other.y,
			z2 = z - other.z;
		return (x2 * x2) + (y2 * y2) + (z2 * z2);
	}
开发者ID:heyx3,项目名称:SimpleBoardGames,代码行数:7,代码来源:Vector3i.cs

示例6: TransferBlock

		//---------------------------------------------------------------------------
		
		#region Private Member Data
		
		//---------------------------------------------------------------------------
		
		
		
		//---------------------------------------------------------------------------
		
		#endregion
		
		//---------------------------------------------------------------------------
		
		#region Accessors and Mutators
		
		//---------------------------------------------------------------------------
		
		
		
		//---------------------------------------------------------------------------
		
		#endregion
		
		//---------------------------------------------------------------------------
		
		#region Public Member Functions
		
		//---------------------------------------------------------------------------
		
		public void TransferBlock(Vector3i? origin, Vector3i? destination)
		{
			if(origin.HasValue && destination.HasValue)
			{
				OCMap map = OCMap.Instance;//(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault();
				
				OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController));

				foreach(Transform battery in map.BatteriesSceneObject.transform)
				{
					if(VectorUtil.AreVectorsEqual(battery.position, new Vector3((float)origin.Value.x, (float)origin.Value.y, (float)origin.Value.z)))
						battery.position = new Vector3((float)destination.Value.x, (float)destination.Value.y, (float)destination.Value.z);
				}

				OCBlockData block = map.GetBlock(origin.Value);

				map.SetBlockAndRecompute(block, destination.Value);
				map.SetBlockAndRecompute(OCBlockData.CreateInstance<OCBlockData>().Init(null, origin.Value), origin.Value);
				
				foreach(OCGoalController goalController in goalControllers)
				{
					if(goalController.GoalBlockType == block.block)
					{
						goalController.FindGoalBlockPositionInChunks(map.GetChunks());
					}
				}
				
			}
		}
开发者ID:ngeiswei,项目名称:unity3d-opencog-game,代码行数:59,代码来源:OCTransferBlockEffect.cs

示例7: SetChunkLightDirty

		private static void SetChunkLightDirty(OCMap map, Vector3i chunkPos) {
			OCChunk chunkData = map.GetChunk(chunkPos);
			if(chunkData == null) return;
			OCChunkRenderer chunk = chunkData.GetChunkRenderer();
			if(chunk == null) return;
			chunk.SetLightDirty();
		}
开发者ID:ngeiswei,项目名称:unity3d-opencog-game,代码行数:7,代码来源:OCLightComputerUtils.cs

示例8: DontSpawnPlayerInWater

    // generates a new spawn near initial spawn if initial spawn is in water
    public Vector3i DontSpawnPlayerInWater(Vector3i initialSpawn)
    {
        if (IsPlayerPositionDry(initialSpawn.x, initialSpawn.y, initialSpawn.z))
        {
            return initialSpawn;
        }

        //find shore
        //bonus +10 because player shouldn't be spawned too close to shore.
        bool bonusset = false;
        int bonus = -1;
        Vector3i pos = initialSpawn;
        for (int i = 0; i < playerareasize / 4 - 5; i++)
        {
            if (IsPlayerPositionDry(pos.x, pos.y, pos.z))
            {
                if (!bonusset)
                {
                    bonus = 10;
                    bonusset = true;
                }
            }
            if (bonusset && bonus-- < 0)
            {
                break;
            }
            pos.x++;
            int newblockheight = MapUtil.blockheight(d_Map, 0, pos.x, pos.y);
            pos.z = newblockheight + 1;
        }
        return pos;
    }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:33,代码来源:ServerWorldManager.cs

示例9: ShiftWorldChunks

    public void ShiftWorldChunks(Vector3i increment)
    {
        m_ChunkProcessor.ChunksAreBeingAdded = true;
        // We copy the original, because if we moved each chunk it's a
        // "destructive" move, possibly overwriting another chunk that also needs
        // to move.
        Chunk[, ,] copyOfOriginalChunks = CreateCopyOfOriginalChunkArray();
        List<Chunk> newCunksAddedToMap = new List<Chunk>();
        List<Chunk> chunksToDecorate = new List<Chunk>();

        m_WorldData.MapChunkOffset = m_WorldData.MapChunkOffset - increment;
        //m_WorldData.MapChunkOffset.X -= increment.X;
        //m_WorldData.MapChunkOffset.Y -= increment.Y;
        for (int x = 0; x < m_WorldData.ChunksWide; x++)
        {
            for (int y = 0; y < m_WorldData.ChunksHigh; y++)
            {
                for (int z = 0; z < m_WorldData.ChunksDeep; z++)
                {
                    MoveChunk(copyOfOriginalChunks[x, y, z], increment, newCunksAddedToMap, chunksToDecorate);
                }
            }
        }
        m_ChunkProcessor.AddBatchOfChunks(newCunksAddedToMap, BatchType.TerrainGeneration);
        m_ChunkProcessor.AddBatchOfChunks(chunksToDecorate, BatchType.Decoration);
        m_ChunkProcessor.ChunksAreBeingAdded = false;
    }
开发者ID:thiasman,项目名称:MineLike,代码行数:27,代码来源:ChunkMover.cs

示例10: Update

    public override void Update(Server server, float dt)
    {
        int sizexchunks = server.mapsizexchunks();
        int sizeychunks = server.mapsizeychunks();
        int sizezchunks = server.mapsizezchunks();

        for (int i = 0; i < 100; i++)
        {
            MapUtilCi.PosInt(CompressUnusedIteration, sizexchunks, sizeychunks, chunkpos);
            ServerChunk c = server.d_Map.GetChunkValid(chunkpos.X, chunkpos.Y, chunkpos.Z);
            bool stop = false;
            if (c != null)
            {
                var globalpos = new Vector3i(chunkpos.X * Server.chunksize, chunkpos.Y * Server.chunksize, chunkpos.Z * Server.chunksize);
                bool unload = true;
                foreach (var k in server.clients)
                {
                    if (k.Value.IsBot)
                    {
                        // don't hold chunks in memory for bots
                        continue;
                    }
                    // unload distance = view distance + 60% (prevents chunks from being unloaded too early (square loading vs. circular unloading))
                    int viewdist = (int)(server.chunkdrawdistance * Server.chunksize * 1.8f);
                    if (server.DistanceSquared(server.PlayerBlockPosition(k.Value), globalpos) <= viewdist * viewdist)
                    {
                        //System.Console.WriteLine("No Unload:   {0},{1},{2}", chunkpos.X, chunkpos.Y, chunkpos.Z);
                        unload = false;
                    }
                }
                if (unload)
                {
                    // unload if chunk isn't seen by anyone
                    if (c.DirtyForSaving)
                    {
                        // save changes to disk if necessary
                        server.DoSaveChunk(chunkpos.X, chunkpos.Y, chunkpos.Z, c);
                    }
                    server.d_Map.SetChunkValid(chunkpos.X, chunkpos.Y, chunkpos.Z, null);
                    foreach (var client in server.clients)
                    {
                        // mark chunks unseen for all players
                        server.ClientSeenChunkRemove(client.Key, chunkpos.X, chunkpos.Y, chunkpos.Z);
                    }
                    stop = true;
                }
            }
            CompressUnusedIteration++;
            if (CompressUnusedIteration >= sizexchunks * sizeychunks * sizezchunks)
            {
                CompressUnusedIteration = 0;
            }
            if (stop)
            {
                // only unload one chunk at a time
                return;
            }
        }
    }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:59,代码来源:UnloadUnusedChunks.cs

示例11: Build

	//---------------------------------------------------------------------------

	#region Private Member Data

	//---------------------------------------------------------------------------
	

			
	//---------------------------------------------------------------------------

	#endregion

	//---------------------------------------------------------------------------

	#region Accessors and Mutators

	//---------------------------------------------------------------------------
		

			
	//---------------------------------------------------------------------------

	#endregion

	//---------------------------------------------------------------------------

	#region Public Member Functions

	//---------------------------------------------------------------------------

	public static void Build(Vector3i localPos, Vector3i worldPos, OpenCog.Map.OCMap map, OpenCog.Builder.OCMeshBuilder mesh, bool onlyLight)
	{
		if(!onlyLight)
		{
			BuildCross((Vector3)localPos, worldPos, map, mesh);
		}
		BuildCrossLight(map, worldPos, mesh);
	}
开发者ID:ngeiswei,项目名称:unity3d-opencog-game,代码行数:38,代码来源:OCCrossBuilder.cs

示例12: ClearChunkDetails

 public void ClearChunkDetails(Vector3i details)
 {
     BsonValue id = GetIDFor(details.X, details.Y, details.Z);
     lock (FSLock)
     {
         DBChunks.Delete(id);
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:8,代码来源:ChunkDataManager.cs

示例13: ComputeProgram

 static ComputeProgram()
 {
     int x,y,z;
     GL.GetInteger((GetIndexedPName)All.MaxComputeWorkGroupCount, 0, out x);
     GL.GetInteger((GetIndexedPName)All.MaxComputeWorkGroupCount, 1, out y);
     GL.GetInteger((GetIndexedPName)All.MaxComputeWorkGroupCount, 2, out z);
     MaximumWorkGroupSize = new Vector3i(x,y,z);
 }
开发者ID:olegbom,项目名称:ObjectTK,代码行数:8,代码来源:ComputeProgram.cs

示例14: CalculateRenderableCube

	CubeMesh CalculateRenderableCube(Cube cube, ref int visualVertexCount, ref int collisionVertexCount, Cube[,,] cubes, Vector3i gridPosition) {
    	if (cube == null) return null;
	    cube.cubeSize = cubeSize;
		
	    cube.indexes = gridPosition;
	    cube.chunk = this;
	    var cubeMesh = cube.Calculate(ref visualVertexCount, ref collisionVertexCount,cubes, cubeLegend, cubeObject.colliderType, cubeObject.cubeTag);
	    return cubeMesh;
	}
开发者ID:carriercomm,项目名称:cubed,代码行数:9,代码来源:Chunk.cs

示例15:

 public Block this[Vector3i Location]
 {
     get {
         return BlockData[Location.X, Location.Y, Location.Z];
     }
     set {
         BlockData[Location.X, Location.Y, Location.Z] = value;
     }
 }
开发者ID:CloneDeath,项目名称:FantasyScape,代码行数:9,代码来源:MemoryChunk.cs


注:本文中的Vector3i类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。