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


C# IntVector3.ToIntVector2方法代码示例

本文整理汇总了C#中IntVector3.ToIntVector2方法的典型用法代码示例。如果您正苦于以下问题:C# IntVector3.ToIntVector2方法的具体用法?C# IntVector3.ToIntVector2怎么用?C# IntVector3.ToIntVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IntVector3的用法示例。


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

示例1: UpdateTileInfo

        void UpdateTileInfo(IntVector3 p)
        {
            if (m_terrain.Size.Plane.Contains(p.ToIntVector2()) == false)
                return;

            int h = m_terrain.GetSurfaceLevel(p.ToIntVector2());

            zTextBlock.Text = String.Format("{0} ({1})", p, h);

            IntVector3 mp;

            if (p.Z == m_size.Depth)
                mp = new IntVector3(p.X, p.Y, h);
            else if (p.Z >= 0)
                mp = p;
            else
                return;

            terrainTextBlock.Text = m_terrain.GetTileID(mp).ToString();
            terrainMatTextBlock.Text = m_terrain.GetMaterialID(mp).ToString();

            //interiorTextBlock.Text = m_terrain.GetInteriorID(mp).ToString();
            //interiorMatTextBlock.Text = m_terrain.GetInteriorMaterialID(mp).ToString();
        }
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:24,代码来源:MainWindow.xaml.cs

示例2: SetTileData

        /// <summary>
        /// Note: this does not change tile flags!
        /// </summary>
        public void SetTileData(IntVector3 p, TileData data)
        {
            Debug.Assert(this.IsInitialized);
            Debug.Assert(this.World.IsWritable);

            this.Version += 1;

            var oldData = GetTileData(p);

            // retain the old flags
            Debug.Assert(data.Flags == oldData.Flags || data.Flags == 0);
            data.Flags = oldData.Flags;

            m_tileGrid[p.Z, p.Y, p.X] = data;

            var p2d = p.ToIntVector2();
            int oldSurfaceLevel = GetSurfaceLevel(p2d);
            int newSurfaceLevel = oldSurfaceLevel;

            if (data.IsWall && oldSurfaceLevel <= p.Z)
            {
                // Surface level has risen
                Debug.Assert(p.Z >= 0 && p.Z < 256);
                newSurfaceLevel = p.Z + 1;
            }
            else if (data.IsWall == false && oldSurfaceLevel == p.Z + 1)
            {
                // Surface level has possibly lowered
                if (p.Z == 0)
                    throw new Exception();

                for (int z = p.Z - 1; z >= 0; --z)
                {
                    if (GetTileData(p.X, p.Y, z).IsWall)
                    {
                        Debug.Assert(z >= 0 && z < 256);
                        newSurfaceLevel = z + 1;
                        break;
                    }
                }
            }

            if (newSurfaceLevel != oldSurfaceLevel)
                SetSurfaceLevel(p2d, (byte)newSurfaceLevel);

            MapChanged(p, data);

            if (this.TerrainOrInteriorChanged != null)
                this.TerrainOrInteriorChanged(p, oldData, data);

            if (data.WaterLevel > 0)
                m_waterHandler.AddWater(p);
            else
                m_waterHandler.RemoveWater(p);

            if (newSurfaceLevel > oldSurfaceLevel)
            {
                for (int z = oldSurfaceLevel; z < newSurfaceLevel; ++z)
                    SetTileFlags(new IntVector3(p2d, z), TileFlags.Subterranean, true);
            }
            else if (newSurfaceLevel < oldSurfaceLevel)
            {
                for (int z = oldSurfaceLevel - 1; z >= newSurfaceLevel; --z)
                    SetTileFlags(new IntVector3(p2d, z), TileFlags.Subterranean, false);
            }

            // ZZZ notify up
            if (Contains(p.Up))
            {
                // ZZZ if this tile was the only support for the tile above, it should crash down
                var pu = p.Up;

                // if support is removed, clear greenery above
                if (oldData.IsSupporting && data.IsSupporting == false)
                {
                    if (m_tileGrid[pu.Z, pu.Y, pu.X].IsGreen)
                    {
                        m_tileGrid[pu.Z, pu.Y, pu.X].ID = TileID.Empty;
                        m_tileGrid[pu.Z, pu.Y, pu.X].MaterialID = MaterialID.Undefined;
                    }
                }

                if (data.IsSupporting)
                    m_tileGrid[pu.Z, pu.Y, pu.X].Flags |= TileFlags.HasSupport;
                else
                    m_tileGrid[pu.Z, pu.Y, pu.X].Flags &= ~TileFlags.HasSupport;

                if (data.IsWall)
                    m_tileGrid[pu.Z, pu.Y, pu.X].Flags |= TileFlags.HasWallBelow;
                else
                    m_tileGrid[pu.Z, pu.Y, pu.X].Flags &= ~TileFlags.HasWallBelow;

                MapChanged(pu, GetTileData(pu));

                //if (this.TerrainOrInteriorChanged != null)
                //	this.TerrainOrInteriorChanged(p, oldData, data);
            }
//.........这里部分代码省略.........
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:101,代码来源:EnvironmentObject.cs


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