public static ObjectShip CreateShip(GraphicsDevice device, ContentManager content)
        {
            ObjectShip result = new ObjectShip();
            result.model = content.Load<Model>(@"objects\pop_simple_lemming3");

            Vector3 originalColor = ((BasicEffect)result.model.Meshes[0].Effects[0]).DiffuseColor;
            result.bodyColor = colorSwitchHack ? new Vector3(originalColor.X, originalColor.Z, originalColor.Y) : originalColor;
            colorSwitchHack = !colorSwitchHack;

            result.centerOffset = new Vector3(0f, 0f, 0f);
            result.scale    = 5.0f;
            result.Position = new Vector3(160f, 160f, 0f);
            result.Speed    = new Vector3(0f, 0f, 0f);
            result.Rotation = Vector3.Zero;

            GetBoundingFromMeshes(result.model.Meshes, out result.boundingBox, out result.boundingSphere);
            result.colisionPoints = FindCollisionPoints(result.model.Meshes, result.boundingBox);

            return result;
        }
        public void Render(GraphicsDevice device, BasicEffect basicEffect, ObjectShip ship, LevelBackgroundGF levelBackground)
        {
            basicEffect.World = Matrix.Identity;

            basicEffect.LightingEnabled = false;
            device.RenderState.DepthBufferEnable = false;
            device.RenderState.CullMode = CullMode.None;

            device.RenderState.PointSpriteEnable = true;
            //device.RenderState.PointScaleEnable = true ;
            device.RenderState.PointSize = 10.0f;
            device.RenderState.PointSizeMin = 0.00f;
            device.RenderState.PointSizeMax = 100.00f;
            //device.RenderState.PointScaleA = 0.00f;
            //device.RenderState.PointScaleB = 0.00f;
            //device.RenderState.PointScaleC = 1.00f;

            device.RenderState.AlphaBlendEnable = true;
            device.RenderState.SourceBlend = Blend.One;
            device.RenderState.DestinationBlend = Blend.One;

            basicEffect.Texture = texture;
            basicEffect.TextureEnabled = true;

            int count = 0;

            bool hackColliding = false;
            for(int i = 0; i < 6; i++)
            {
                Vector3 v = ship.colisionPoints[i];
                //v = Vector3.TransformCoordinate(v, ship.renderMatrix);
                v = Vector3.Transform(v, ship.renderMatrix);

            ////                Vector3 v = ship.Position;
            ////                v.Y = v.Y + (float)(ship.boundingBoxMax.Y * ship.scale * Math.Cos(ship.Rotation.Z));
            ////                v.X = v.X - (float)(ship.boundingBoxMax.Y * ship.scale * Math.Sin(ship.Rotation.Z));
                bool collide = levelBackground.CheckCollision(v);

                VertexPositionColor pv;
                pv.Position = v;
                pv.Color = collide ? Color.Yellow : Color.White;

                if(collide)
                {
                    vertices[count] = pv;
                    count++;
                }

                hackColliding |= collide;
            }
            if(!ship.hackColliding && hackColliding)
            {
                ship.Position = ship.OldPosition;
                ship.Speed = -ship.Speed * 0.3f;
                SoundHandler.Checkpoint();
            }
            ship.hackColliding = hackColliding;

            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);

            //// Unlock the vertex buffer
            //vertexBuffer.Unlock();
            //// Render any remaining particles
            if (count > 0)
            {
                basicEffect.Begin();
                foreach(EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Begin();

                    device.DrawUserPrimitives(PrimitiveType.PointList, vertices, 0, count);

                    pass.End();
                }
                basicEffect.End();
            }

            //// Reset render states
            //device.RenderState.PointSpriteEnable = false;
            //device.RenderState.PointScaleEnable = false;

            //device.RenderState.PointSpriteEnable = true;
            //device.RenderState.PointScaleEnable = true ;
            //device.RenderState.AlphaBlendEnable = false;

            device.RenderState.PointSpriteEnable = false;
            device.RenderState.DepthBufferWriteEnable = true;
            device.RenderState.SourceBlend = Blend.SourceAlpha;
            device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
        }
 public void Interact(ObjectShip other)
 {
     if(other.Speed.Y <= 0)
     {
         if(Math.Abs(other.Position.X - Position.X) < 16)
         {
             if(other.Position.Y <= Position.Y)
             {
                 if(other.OldPosition.Y >= Position.Y)
                 {
                     double pop = Math.Cos(other.Rotation.Z);
                     if(pop >= 0.93)
                     {
                         if(other.OldPosition.Y != Position.Y)
                         {
                             SoundHandler.TochDown();
                         }
                         other.Speed = Vector3.Zero;
                         other.Position.Y = Position.Y;
                         other.Rotation.Z = 0;
                     }
                     else
                     {
                         SoundHandler.Bigexp();
                     }
                 }
             }
         }
     }
 }
        public void Bots(ObjectShip other)
        {
            Vector3 distance = other.Position - Position;
            if(distance.Length() < (boundingSphere.Radius * scale))
            {
                //Speed = -Speed;
                Position = OldPosition;
                other.Position = other.OldPosition;

                Vector3 tmp = other.Speed;
                other.Speed = Speed; // + Vector3.Scale(Speed, (float)0.5);
                Speed = tmp; // + Vector3.Scale(tmp, (float)0.5);
                SoundHandler.Shipcollide();
            }
        }