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


C# Vector3I.ToString方法代码示例

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


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

示例1: Invoke

        public override bool Invoke(ulong steamId, long playerId, string messageText)
        {
            var match = Regex.Match(messageText, @"/createroid\s+(?<X>[+-]?((\d+(\.\d*)?)|(\.\d+)))\s+(?<Y>[+-]?((\d+(\.\d*)?)|(\.\d+)))\s+(?<Z>[+-]?((\d+(\.\d*)?)|(\.\d+)))\s+(?<Size>(\d+?))\s+(?<Name>.+)", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                var position = new Vector3D(
                    double.Parse(match.Groups["X"].Value, CultureInfo.InvariantCulture),
                    double.Parse(match.Groups["Y"].Value, CultureInfo.InvariantCulture),
                    double.Parse(match.Groups["Z"].Value, CultureInfo.InvariantCulture));

                var length = int.Parse(match.Groups["Size"].Value, CultureInfo.InvariantCulture);
                if (length < 1 || length % 64 != 0)
                {
                    MyAPIGateway.Utilities.ShowMessage("Invalid", "Size specified.");
                    return true;
                }

                var size = new Vector3I(length, length, length);
                var name = match.Groups["Name"].Value;

                if (position.IsValid() && ((Vector3D)size).IsValid())
                {
                    MyAPIGateway.Utilities.ShowMessage("Size", size.ToString());
                    var newName = Support.CreateUniqueStorageName(name);

                    // MyAPIGateway.Session.VoxelMaps.CreateVoxelMap will always create a square shaped asteroid.
                    // This is by design within the API itself and cannot be altered.
                    var newVoxelMap = Support.CreateNewAsteroid(newName, size, position);
                    return true;
                }
            }

            return false;
        }
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:35,代码来源:CommandAsteroidCreate.cs

示例2: Vector3B

        public Vector3B(Vector3I vec)
        {
            Debug.Assert(vec.X >= sbyte.MinValue && vec.X <= sbyte.MaxValue
                && vec.Y >= sbyte.MinValue && vec.Y <= sbyte.MaxValue
                && vec.Z >= sbyte.MinValue && vec.Z <= sbyte.MaxValue, "This Vector3I does not fit Vector3B: " + vec.ToString());

            X = (sbyte)vec.X;
            Y = (sbyte)vec.Y;
            Z = (sbyte)vec.Z;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:10,代码来源:Vector3B.cs

示例3: GunMove

        public static void GunMove( Player player )
        {
            World world = player.World;
            if ( null == world )
                return;
            try {
                if ( null == world.Map )
                    return;
                if ( player.IsOnline ) {
                    Position p = player.Position;
                    double ksi = 2.0 * Math.PI * ( -player.Position.L ) / 256.0;
                    double phi = 2.0 * Math.PI * ( player.Position.R - 64 ) / 256.0;
                    double sphi = Math.Sin( phi );
                    double cphi = Math.Cos( phi );
                    double sksi = Math.Sin( ksi );
                    double cksi = Math.Cos( ksi );

                    if ( player.GunCache.Values.Count > 0 ) {
                        foreach ( Vector3I block in player.GunCache.Values ) {
                            if ( player.IsOnline ) {
                                player.Send( PacketWriter.MakeSetBlock( block.X, block.Y, block.Z, world.Map.GetBlock( block ) ) );
                                Vector3I removed;
                                player.GunCache.TryRemove( block.ToString(), out removed );
                            }
                        }
                    }

                    for ( int y = -1; y < 2; ++y ) {
                        for ( int z = -1; z < 2; ++z ) {
                            if ( player.IsOnline ) {
                                //4 is the distance betwen the player and the glass wall
                                Vector3I glassBlockPos = new Vector3I( ( int )( cphi * cksi * 4 - sphi * ( 0.5 + y ) - cphi * sksi * ( 0.5 + z ) ),
                                      ( int )( sphi * cksi * 4 + cphi * ( 0.5 + y ) - sphi * sksi * ( 0.5 + z ) ),
                                      ( int )( sksi * 4 + cksi * ( 0.5 + z ) ) );
                                glassBlockPos += p.ToBlockCoords();
                                if ( world.Map.GetBlock( glassBlockPos ) == Block.Air ) {
                                    player.Send( PacketWriter.MakeSetBlock( glassBlockPos.X, glassBlockPos.Y, glassBlockPos.Z, Block.Glass ) );
                                    player.GunCache.TryAdd( glassBlockPos.ToString(), glassBlockPos );
                                }
                            }
                        }
                    }
                }
            } catch ( Exception ex ) {
                Logger.Log( LogType.SeriousError, "GunGlass: " + ex );
            }
        }
开发者ID:Jonty800,项目名称:Guilds,代码行数:47,代码来源:GunGlass.cs

示例4: shootBlack

 public static void shootBlack()
 {
     world.Games.Remove(shootBlack);
     mode = GameMode.shootblack;
     GunModeOn();
     foreach (Player p in world.Players)
     {
         Vector3I block = new Vector3I(p.Position.X / 32, p.Position.Y /32, (p.Position.Z /32) + 8);
         if (world.Map.InBounds(block))
         {
             randomBlocks.TryAdd(block.ToString(), block);
             world.Map.QueueUpdate(new BlockUpdate(null, block, Block.Black));
         }
     }
     world.Players.Message("&WYou have 20 seconds to shoot all &8BLACK &Wblocks.... &AGO!");
     wait(10000);
     world.Players.Message("&WYou have 10 seconds left to shoot all &8BLACK &Wblocks.");
     wait(10000);
     GunModeOff();
     scoreCounter();
     foreach (Vector3I block in platform.Values)
     {
         if (world.Map != null && world.IsLoaded)
         {
             world.Map.QueueUpdate(new BlockUpdate(null, block, Block.Air));
             Vector3I removed;
             platform.TryRemove(block.ToString(), out removed);
         }
     }
     interval();
     gamePicker();
 }
开发者ID:Bedrok,项目名称:800craft,代码行数:32,代码来源:MineChallenge.cs

示例5: SetUpMines

 private static void SetUpMines()
 {
     for ( short i = 0; i <= _map.Width; ++i ) {
         for ( short j = 0; j <= _map.Length; ++j ) {
             if ( _map.GetBlock( i, j, _ground ) != Block.Red &&
                 _map.GetBlock( i, j, _ground ) != Block.Green &&
                 _map.GetBlock( i, j, _ground ) != Block.Water ) {
                 _map.SetBlock( i, j, _ground, Block.Dirt );
                 _map.SetBlock( i, j, _ground - 1, Block.Dirt );
                 if ( _rand.Next( 1, 100 ) > 96 ) {
                     Vector3I vec = new Vector3I( i, j, _ground );
                     Mines.TryAdd( vec.ToString(), vec );
                     //_map.SetBlock(vec, Block.Red);//
                 }
             }
         }
     }
 }
开发者ID:GlennMR,项目名称:800craft,代码行数:18,代码来源:MineField.cs

示例6: towerInit

 public static void towerInit(object sender, Events.PlayerPlacedBlockEventArgs e)
 {
     World world = e.Player.World;
     if (e.Player.towerMode)
     {
         if (world.Map != null && world.IsLoaded)
         {
             if (e.Context == BlockChangeContext.Manual)
             {
                 if (e.NewBlock == Block.Iron)
                 {
                     waterThread = new Thread(new ThreadStart(delegate
                     {
                         if (e.Player.TowerCache != null)
                         {
                             world.Map.QueueUpdate(new BlockUpdate(null, e.Player.towerOrigin, Block.Air));
                             e.Player.towerOrigin = e.Coords;
                             foreach (Vector3I block in e.Player.TowerCache.Values)
                             {
                                 e.Player.Send(PacketWriter.MakeSetBlock(block, Block.Air));
                             }
                             e.Player.TowerCache.Clear();
                         }
                         e.Player.towerOrigin = e.Coords;
                         e.Player.TowerCache = new System.Collections.Concurrent.ConcurrentDictionary<string, Vector3I>();
                         for (int z = e.Coords.Z; z <= world.Map.Height; z++)
                         {
                             Thread.Sleep(250);
                             if (world.Map != null && world.IsLoaded)
                             {
                                 if (world.Map.GetBlock(e.Coords.X, e.Coords.Y, z + 1) != Block.Air
                                     || world.Map.GetBlock(e.Coords) != Block.Iron
                                     || e.Player.towerOrigin != e.Coords
                                     || !e.Player.towerMode)
                                 {
                                     break;
                                 }
                                 else
                                 {
                                     Vector3I tower = new Vector3I(e.Coords.X, e.Coords.Y, z + 1);
                                     e.Player.TowerCache.TryAdd(tower.ToString(), tower);
                                     e.Player.Send(PacketWriter.MakeSetBlock(tower, Block.Water));
                                 }
                             }
                         }
                     })); waterThread.Start();
                 }
             }
         }
     }
 }
开发者ID:venofox,项目名称:AtomicCraft,代码行数:51,代码来源:WaterPhysics.cs

示例7: ProcessMovementPacket

        void ProcessMovementPacket()
        {
            BytesReceived += 10;
            reader.ReadByte();
            Position newPos = new Position {
                X = IPAddress.NetworkToHostOrder( reader.ReadInt16() ),
                Z = IPAddress.NetworkToHostOrder( reader.ReadInt16() ),
                Y = IPAddress.NetworkToHostOrder( reader.ReadInt16() ),
                R = reader.ReadByte(),
                L = reader.ReadByte()
            };

            Position oldPos = Position;

            // calculate difference between old and new positions
            Position delta = new Position {
                X = ( short )( newPos.X - oldPos.X ),
                Y = ( short )( newPos.Y - oldPos.Y ),
                Z = ( short )( newPos.Z - oldPos.Z ),
                R = ( byte )Math.Abs( newPos.R - oldPos.R ),
                L = ( byte )Math.Abs( newPos.L - oldPos.L )
            };

            // skip everything if player hasn't moved
            if ( delta.IsZero ) return;

            bool rotChanged = ( delta.R != 0 ) || ( delta.L != 0 );

            // only reset the timer if player rotated
            // if player is just pushed around, rotation does not change (and timer should not reset)
            if ( rotChanged ) ResetIdleTimer();

            if ( Info.IsFrozen ) {
                // special handling for frozen players
                if ( delta.X * delta.X + delta.Y * delta.Y > AntiSpeedMaxDistanceSquared ||
                    Math.Abs( delta.Z ) > 40 ) {
                    SendNow( PacketWriter.MakeSelfTeleport( Position ) );
                }
                newPos.X = Position.X;
                newPos.Y = Position.Y;
                newPos.Z = Position.Z;

                // recalculate deltas
                delta.X = 0;
                delta.Y = 0;
                delta.Z = 0;

            }
            if ( IsFlying ) {
                Vector3I oldPosi = new Vector3I( oldPos.X / 32, oldPos.Y / 32, oldPos.Z / 32 );
                Vector3I newPosi = new Vector3I( newPos.X / 32, newPos.Y / 32, newPos.Z / 32 );
                //Checking e.Old vs e.New increases accuracy, checking old vs new uses a lot less updates
                if ( ( oldPosi.X != newPosi.X ) || ( oldPosi.Y != newPosi.Y ) || ( oldPosi.Z != newPosi.Z ) ) {
                    //finally, /fly decends
                    if ( ( oldPos.Z > newPos.Z ) ) {
                        foreach ( Vector3I block in FlyCache.Values ) {
                            SendNow( PacketWriter.MakeSetBlock( block, Block.Air ) );
                            Vector3I removed;
                            FlyCache.TryRemove( block.ToString(), out removed );
                        }
                    }
                    // Create new block parts
                    for ( int i = -1; i <= 1; i++ ) //reduced width and length by 1
                    {
                        for ( int j = -1; j <= 1; j++ ) {
                            for ( int k = 2; k <= 3; k++ ) //added a 2nd layer
                            {
                                Vector3I layer = new Vector3I( newPosi.X + i, newPosi.Y + j, newPosi.Z - k );
                                if ( World.Map.GetBlock( layer ) == Block.Air ) {
                                    SendNow( PacketWriter.MakeSetBlock( layer, Block.Glass ) );
                                    FlyCache.TryAdd( layer.ToString(), layer );
                                }
                            }
                        }
                    }

                    // Remove old blocks
                    foreach ( Vector3I block in FlyCache.Values ) {
                        if ( fCraft.Utils.FlyHandler.CanRemoveBlock( this, block, newPosi ) ) {
                            SendNow( PacketWriter.MakeSetBlock( block, Block.Air ) );
                            Vector3I removed;
                            FlyCache.TryRemove( block.ToString(), out removed );
                        }
                    }
                }
            } else if ( !Can( Permission.UseSpeedHack ) ) {
                int distSquared = delta.X * delta.X + delta.Y * delta.Y + delta.Z * delta.Z;
                // speedhack detection
                if ( DetectMovementPacketSpam() ) {
                    return;

                } else if ( ( distSquared - delta.Z * delta.Z > AntiSpeedMaxDistanceSquared || delta.Z > AntiSpeedMaxJumpDelta ) &&
                           speedHackDetectionCounter >= 0 ) {

                    if ( speedHackDetectionCounter == 0 ) {
                        lastValidPosition = Position;
                    } else if ( speedHackDetectionCounter > 1 ) {
                        DenyMovement();
                        speedHackDetectionCounter = 0;
                        return;
//.........这里部分代码省略.........
开发者ID:Jonty800,项目名称:800Craft-SMP,代码行数:101,代码来源:Player.Networking.cs

示例8: LogCellRemoval

 public void LogCellRemoval(MyVoxelNavigationMesh navMesh, Vector3I cell)
 {
     m_log.WriteLine("NMOP: " + navMesh.ToString() + " REM " + cell.ToString());
 }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:4,代码来源:MyVoxelPathfindingLog.cs

示例9: LogCellAddition

 public void LogCellAddition(MyVoxelNavigationMesh navMesh, Vector3I cell)
 {
     m_log.WriteLine("NMOP: " + navMesh.ToString() + " ADD " + cell.ToString());
 }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:4,代码来源:MyVoxelPathfindingLog.cs

示例10: sendWorldBlock

 //processess one blockupdate
 public void sendWorldBlock( int index, byte type )
 {
     if ( world.Map == null ) {
         started = false;
         return;
     }
     if ( world.IsLoaded ) {
         int x = 0, y = 0, z = 0;
         switch ( direction ) {
             case Direction.one:
                 x = ( int )( index / 8 ) + EndPos.X;
                 y = StartPos.Y;
                 z = StartPos.Z + ( index % 8 );
                 if ( world.map.InBounds( x, y, z ) ) {
                     if ( x >= StartPos.X && x <= FinishPos.X ) {
                         if ( ( Block )type != Block.Air ) {
                             Vector3I Pos = new Vector3I( x, y, z );
                             world.map.QueueUpdate( new BlockUpdate( null, Pos, ( Block )type ) );
                             Blocks.TryAdd( Pos.ToString(), Pos );
                         }
                     }
                 }
                 break;
             case Direction.two:
                 x = ( short )( EndPos.X - ( index / 8 ) );
                 y = ( short )StartPos.Y;
                 z = ( short )( StartPos.Z + ( index % 8 ) );
                 if ( world.map.InBounds( x, y, z ) ) {
                     if ( x <= StartPos.X && x >= FinishPos.X ) {
                         if ( ( Block )type != Block.Air ) {
                             Vector3I Pos = new Vector3I( x, y, z );
                             world.map.QueueUpdate( new BlockUpdate( null, Pos, ( Block )type ) );
                             Blocks.TryAdd( Pos.ToString(), Pos );
                         }
                     }
                 }
                 break;
             case Direction.three:
                 x = ( short )StartPos.X;
                 y = ( short )( EndPos.Y + ( index / 8 ) );
                 z = ( short )( StartPos.Z + ( index % 8 ) );
                 if ( world.map.InBounds( x, y, z ) ) {
                     if ( y >= StartPos.Y && y <= FinishPos.Y ) {
                         if ( ( Block )type != Block.Air ) {
                             Vector3I Pos = new Vector3I( x, y, z );
                             world.map.QueueUpdate( new BlockUpdate( null, Pos, ( Block )type ) );
                             Blocks.TryAdd( Pos.ToString(), Pos );
                         }
                     }
                 }
                 break;
             case Direction.four:
                 x = ( short )StartPos.X;
                 y = ( short )( EndPos.Y - ( index / 8 ) );
                 z = ( short )( StartPos.Z + ( index % 8 ) );
                 if ( world.map.InBounds( x, y, z ) ) {
                     if ( y <= StartPos.Y && y >= FinishPos.Y ) {
                         if ( ( Block )type != Block.Air ) {
                             Vector3I Pos = new Vector3I( x, y, z );
                             world.map.QueueUpdate( new BlockUpdate( null, Pos, ( Block )type ) );
                             Blocks.TryAdd( Pos.ToString(), Pos );
                         }
                     }
                 }
                 break;
             default:
                 break;
         }
     }
 }
开发者ID:Jonty800,项目名称:800Craft-SMP,代码行数:71,代码来源:FeedData.cs

示例11: Player_Moved

        private static void Player_Moved(object sender, Events.PlayerMovedEventArgs e)
        {
            try
            {
                if (e.Player.IsFlying)
                {
                    // We need to have block positions, so we divide by 32
                    Vector3I oldPos = new Vector3I(e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32);
                    Vector3I newPos = new Vector3I(e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32);

                    // Check if the player actually moved and not just rotated
                    if ((oldPos.X != newPos.X) || (oldPos.Y != newPos.Y) || (oldPos.Z != newPos.Z))
                    {
                        // Create new blocks part
                        for (int i = -2; i <= 2; i++)
                        {
                            for (int j = -2; j <= 2; j++)
                            {
                                Vector3I carpet = new Vector3I(newPos.X + i, newPos.Y + j, newPos.Z - 2);

                                if (e.Player.World.Map.GetBlock(carpet) == Block.Air)
                                {
                                    e.Player.Send(PacketWriter.MakeSetBlock(carpet, Block.Glass));
                                    e.Player.FlyCache.TryAdd(carpet.ToString(), carpet);
                                }
                            }
                        }

                        // Remove old blocks
                        foreach(Vector3I block in e.Player.FlyCache.Values)
                        {
                            if (CanRemoveBlock(e.Player, block, newPos))
                            {
                                e.Player.Send(PacketWriter.MakeSetBlock(block, Block.Air));
                                Vector3I removed;
                                e.Player.FlyCache.TryRemove(block.ToString(), out removed);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log( LogType.Error, "FlyHandler.Player_Moved: " + ex);
            }
        }
开发者ID:Desertive,项目名称:800craft,代码行数:46,代码来源:FlyHandler.cs

示例12: Player_Moved

        private static void Player_Moved(object sender, Events.PlayerMovedEventArgs e)
        {
            try
            {
                if (e.Player.IsFlying)
                {
                    Vector3I oldPos = new Vector3I(e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32);
                    Vector3I newPos = new Vector3I(e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32);
                    //Checking e.Old vs e.New increases accuracy, checking old vs new uses a lot less updates
                    if ((oldPos.X != newPos.X) || (oldPos.Y != newPos.Y) || (oldPos.Z != newPos.Z))
                    {
                        //finally, /fly decends
                        if((e.OldPosition.Z > e.NewPosition.Z))
                        {
                            foreach (Vector3I block in e.Player.FlyCache.Values)
                            {
                                e.Player.Send(PacketWriter.MakeSetBlock(block, Block.Air));
                                Vector3I removed;
                                e.Player.FlyCache.TryRemove(block.ToString(), out removed);
                            }
                        }
                        // Create new block parts
                        for (int i = -1; i <= 1; i++) //reduced width and length by 1
                        {
                            for (int j = -1; j <= 1; j++)
                            {
                                for (int k = 2; k <= 3; k++) //added a 2nd layer
                                {
                                    Vector3I layer = new Vector3I(newPos.X + i, newPos.Y + j, newPos.Z - k);
                                    if (e.Player.World.Map.GetBlock(layer) == Block.Air)
                                    {
                                        e.Player.Send(PacketWriter.MakeSetBlock(layer, Block.Glass));
                                        e.Player.FlyCache.TryAdd(layer.ToString(), layer);
                                    }
                                }
                            }
                        }

                        // Remove old blocks
                        foreach (Vector3I block in e.Player.FlyCache.Values)
                        {
                            if (CanRemoveBlock(e.Player, block, newPos))
                            {
                                e.Player.Send(PacketWriter.MakeSetBlock(block, Block.Air));
                                Vector3I removed;
                                e.Player.FlyCache.TryRemove(block.ToString(), out removed);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogType.Error, "FlyHandler.Player_Moved: " + ex);
            }
        }
开发者ID:Bedrok,项目名称:800craft,代码行数:56,代码来源:FlyHandler.cs

示例13: TestToString

 public void TestToString()
 {
     CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
     try
     {
         Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
         Vector3I a = new Vector3I(1, 2, 3);
         Assert.AreEqual("(1, 2, 3)", a.ToString());
     }
     finally
     {
         Thread.CurrentThread.CurrentCulture = originalCulture;
     }
 }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:14,代码来源:Vector3ITests.cs


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