示例#1
0
        protected override void Initialize()
        {
            CollisionManager = CollisionManager.GetInstance(this);
            InputManager     = InputManager.GetInstance(this);
            BasicManager     = BasicManager.GetInstance(this);
            if (useBloom)
            {
                bloom = new BloomComponent(this);
            }

            Overlay      = new Overlay(this);
            Camera       = new Camera(this);
            StateManager = new StateManager(this);

            Components.Add(InputManager);
            //Components.Add(BasicManager);
            //Components.Add(CollisionManager);
            Components.Add(StateManager);
            //if (useBloom)
            //    Components.Add(bloom);
            //Components.Add(Overlay);
            //Components.Add(Camera);

            base.Initialize();
        }
        protected void LoadPrimitive()
        {
            if (IsCollidable)
            {
                CollisionManager.GetInstance(null).AddToCollidables(this);
            }
            string className = GetType().Name;

            if (Settings.ContainsKey(className))
            {
                LoadSettings(className);
                return;
            }

            CreateVertexArray();
            _boundingSphereSize = GetLargestDistance();
            switch (Format)
            {
            case PrimitiveFormat.Color:
                VertexBuffer = new VertexBuffer(Game1.GameInstance.GraphicsDevice, typeof(VertexPositionColor),
                                                ColorVerts.Length, BufferUsage.None);
                VertexBuffer.SetData(ColorVerts);
                break;

            case PrimitiveFormat.ColorTexture:
                VertexBuffer = new VertexBuffer(Game1.GameInstance.GraphicsDevice,
                                                typeof(VertexPositionColorTexture),
                                                ColorTextureVerts.Length, BufferUsage.None);
                VertexBuffer.SetData(ColorTextureVerts);
                break;

            case PrimitiveFormat.NormalTexture:
                VertexBuffer = new VertexBuffer(Game1.GameInstance.GraphicsDevice,
                                                typeof(VertexPositionNormalTexture),
                                                NormalTextureVerts.Length, BufferUsage.None);
                VertexBuffer.SetData(NormalTextureVerts);
                break;

            case PrimitiveFormat.Texture:
                VertexBuffer = new VertexBuffer(Game1.GameInstance.GraphicsDevice, typeof(VertexPositionTexture),
                                                TextureVerts.Length, BufferUsage.None);
                VertexBuffer.SetData(TextureVerts);
                break;
            }
            VertexBufferBinding[] buffers = Game1.GameInstance.GraphicsDevice.GetVertexBuffers();
            int bufferSize = buffers.Length;

            Array.Resize(ref buffers, bufferSize + 1);
            buffers[bufferSize] = VertexBuffer;
            effect = new BasicEffect(Game1.GameInstance.GraphicsDevice);

            SaveSettings(className);
        }
示例#3
0
 protected void UpdateShots()
 {
     for (int i = 0; i < _shots.Count; ++i)
     {
         _shots[i].Update();
         if (_shots[i].Position.Z <-SHOT_BOUND || _shots[i].Position.Y <-SHOT_BOUND || _shots[i].Position.X <-SHOT_BOUND ||
                                                                                                             _shots[i].Position.Z> SHOT_BOUND || _shots[i].Position.Y> SHOT_BOUND || _shots[i].Position.X> SHOT_BOUND)
         {
             var s = _shots[i];
             _shots.RemoveAt(i);
             CollisionManager.GetInstance(null).RemoveFromCollidables(s);
         }
     }
 }