コード例 #1
0
        public static void CreateObjectAtMousePosition(MetaDataType metaDataType)
        {
            var realPosition = SimulationGame.RealWorldMousePosition;

            if (metaDataType is BlockType)
            {
                var blockPosition = GeometryUtils.GetBlockFromReal((int)realPosition.X, (int)realPosition.Y);
                var blockType     = (BlockType)metaDataType;

                SimulationGame.World.SetBlockType(blockPosition.X, blockPosition.Y, SimulationGame.Player.InteriorID, blockType.ID);
            }
            else
            {
                if (!SimulationGame.KeyboardState.IsKeyDown(Keys.LeftControl) && !SimulationGame.KeyboardState.IsKeyDown(Keys.RightControl))
                {
                    var blockPosition = GeometryUtils.GetChunkPosition((int)realPosition.X, (int)realPosition.Y, 16, 16);

                    realPosition = new Vector2(blockPosition.X * 16, blockPosition.Y * 16);
                }

                var        newWorldPosition = new WorldPosition(realPosition.X, realPosition.Y, SimulationGame.Player.InteriorID);
                GameObject gameObject       = null;

                if (metaDataType is AmbientObjectType)
                {
                    gameObject = AmbientObjectType.Create(newWorldPosition, (AmbientObjectType)metaDataType);
                }
                else if (metaDataType is AmbientHitableObjectType)
                {
                    gameObject = AmbientHitableObjectType.Create(newWorldPosition, (AmbientHitableObjectType)metaDataType);
                }
                else if (metaDataType is LivingEntityType)
                {
                    gameObject = LivingEntityType.Create(newWorldPosition, (LivingEntityType)metaDataType);
                }

                gameObject.ConnectToWorld();
            }
        }
コード例 #2
0
 public static AmbientHitableObject createTree(WorldPosition position)
 {
     return(AmbientHitableObjectType.Create(new WorldPosition(position.X, position.Y + WorldGrid.BlockSize.Y - 1, position.InteriorID), AmbientHitableObjectType.lookup[0]));
 }