Ejemplo n.º 1
0
 public FriendlyBoid(Project2Game game, Flock flock, Model model, Vector3 position) : base(game, flock, model, position, Flock.BoidType.Friendly)
 {
     maxHealth = 200;
     health = maxHealth;
     attack = 10;
     healthyColor = Color.Green;
 }
Ejemplo n.º 2
0
 public ShipModel(VisionContent vContent)
     : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
 {
     _model = vContent.Load<Model>(@"Models/galleonmodel");
     _texture = vContent.Load<Texture2D>(@"Models/galleon");
     _boundingSphere = _model.CalculateBounds();
 }
Ejemplo n.º 3
0
 public EnemyBoid(Project2Game game, Flock flock, Model model, Vector3 position)
     : base(game, flock, model, position, Flock.BoidType.Enemy)
 {
     maxHealth = 80;
     health = maxHealth;
     attack = 20;
     healthyColor = Color.Red;
 }
Ejemplo n.º 4
0
 public Monkey(Project2Game game, Model model, Vector3 position)
     : base(game, model, position)
 {
     // Load custom rainbox monkey effect
     effect = game.Content.Load<Effect>("Shaders\\Cel");
     PhysicsDescription.Mass = 20f;
     //PhysicsDescription.Tag = "player";
 }
 public ModelGameObject(Project2Game game, Model model, Vector3 position, Vector3 orientation, Vector3 scale)
     : base(game, position, orientation, scale)
 {
     this.model = model;
     if (model != null)
     {
         boundingSphere = model.CalculateBounds(WorldMatrix);
     }
 }
        protected ModelPhysicsObject(Project2Game game, Model model, Vector3 position, Vector3 orientation, Vector3 size)
            : base(game, model, position, orientation, size)
        {
            this.PhysicsDescription = GeneratePhysicsDescription();
            this.Position = PhysicsSystem.toVector3(PhysicsDescription.Position);

            game.physics.AddBody(PhysicsDescription);
            ToDestroy = false;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Stop the animation of a model.
        /// </summary>
        /// <param name="model">The animated model.</param>
        public void StopAnimation(Model model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            animationStates.Remove(model);
        }
Ejemplo n.º 8
0
 public CaveModel(LarvContent lcontent)
     : base(lcontent.TextureEffect)
 {
     _caveModel = lcontent.Load<Model>("models/cave");
     _texture = lcontent.Load<Texture2D>("textures/cave");
     _gratingModel = lcontent.Load<Model>("models/grating");
     _gratingTexture = lcontent.Load<Texture2D>("textures/black");
     _gratingPart1 = Matrix.Translation(0.08f, 0, -0.02f)*Matrix.Scaling(0.5f, 0.7f, 0.4f);
 }
Ejemplo n.º 9
0
        public Windmill(LarvContent lContent, Vector3 location)
            : base(lContent.TextureEffect)
        {
            World = Matrix.Scaling(0.004f)*Matrix.RotationY(1)*Matrix.Translation(location);
            _model = lContent.Load<Model>("models/windmillf");
            _texture = lContent.Load<Texture2D>("models/windmill_diffuse");

            _animatedBone = _model.Meshes.Single(mesh => mesh.Name == "Fan").ParentBone;
            _originalBoneTransformation = Matrix.Translation(0, 850, 0);
        }
Ejemplo n.º 10
0
 public Boid(Project2Game game, Flock flock, Model model, Vector3 position, Flock.BoidType boidType)
     : base(game, model, position)
 {
     this.health = maxHealth;
     this.PhysicsDescription.Mass = 0.25f;
     this.boidType = boidType;
     this.flock = flock;
     this.game.physics.World.CollisionSystem.CollisionDetected += HandleCollision;
     effect = game.Content.Load<Effect>("Shaders\\Cel");
 }
Ejemplo n.º 11
0
        public Bridge(VisionContent vContent, Matrix world)
            : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
        {
            _model = vContent.Load<Model>(@"Models/bridge");
            _texture = vContent.Load<Texture2D>("textures/bigstone");
            World = world * Matrix.Scaling(0.05f);

            foreach (var part in _model.Meshes.SelectMany(mesh => mesh.MeshParts))
                part.Effect = Effect.Effect;
        }
Ejemplo n.º 12
0
        public GameModel(Model model, Game game, float x, float y, float z)
        {
            this.game = (Project2Game) game;
            this.model = model;
            effect = game.Content.Load<Effect>("ObjectShader");
            this.position = new Vector3(x, y, z);
            World = Matrix.Identity;

            lightPointPositions = new [] {
                new Vector3(0, 180, 0),
                new Vector3(-this.game.landscape.baord_size_public , 180, 0),
                new Vector3(this.game.landscape.baord_size_public, 180, this.game.landscape.baord_size_public)
            };
        }
Ejemplo n.º 13
0
        public Frog(
            LarvContent lcontent,
            IVEffect effect,
            Serpents serpents)
            : base(effect)
        {
            _model = lcontent.Load<Model>(@"Models/frog");
            _modelRotation = Matrix.RotationY(MathUtil.Pi)*Matrix.Scaling(0.1f);

            _texture = lcontent.Load<Texture2D>(@"models/frogskin");
            _serpents = serpents;
            _ground = lcontent.Ground;
            Restart();
        }
        /// <summary>
        /// Creates a BoundingSphere from a given model and world matrix.
        /// </summary>
        /// <param name="model">Model to create BoundingSphere from.</param>
        /// <param name="world">Matrix to place BoundingSphere with.</param>
        /// <returns></returns>
        public static BoundingSphere CreateBoundingSphere(Model model, Matrix world)
        {
            Matrix[] boneTransforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(boneTransforms);

            BoundingSphere meshSphere, boundingSphere = new BoundingSphere();

            for (int i = 0; i < model.Meshes.Count; i++)
            {
                meshSphere = TransformBoundingSphere(boneTransforms[i], model.Meshes[i].BoundingSphere);
                boundingSphere = BoundingSphere.Merge(boundingSphere, meshSphere);
            }
            return TransformBoundingSphere(world, boundingSphere);
        }
Ejemplo n.º 15
0
        public Windmill(VisionContent vContent, Vector3 location)
            : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
        {
            World = Matrix.RotationY(-MathUtil.PiOverTwo)*Matrix.Scaling(0.005f)*Matrix.Translation(location);
            _model = vContent.Load<Model>("models/windmill");
            _texture = vContent.Load<Texture2D>("textures/windmill_diffuse");
            _bones = new Matrix[_model.Bones.Count];
            _model.CopyAbsoluteBoneTransformsTo(_bones);

            //foreach (var mesh in _model.Meshes)
            //    foreach (var part in mesh.MeshParts)
            //        part.Effect = Effect.Effect;

            _animation = new ObjectAnimation(new Vector3(0, 875, 0), new Vector3(0, 875, 0),
                Vector3.Zero, new Vector3(0, 0, MathUtil.TwoPi),
                TimeSpan.FromSeconds(10), true);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Starts a new animation.
        /// </summary>
        /// <param name="model">The animated model.</param>
        /// <param name="animation">The animation to play.</param>
        public void StartAnimation(Model model, ModelAnimation animation)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (animation == null)
            {
                throw new ArgumentNullException("animation");
            }

            animationStates[model] = new AnimationState
            {
                Model = model,
                Animation = animation,
                ChannelMap = BuildChannelMap(model, animation)
            };
        }
Ejemplo n.º 17
0
 public Projectile(ProjectileType type, Model sphere, Vector3 position, Vector3 forward, float angle, Level host)
 {
     this.type = type;
     level = host;
     origin = Matrix.Translation(startLocation);
     this.forward = forward;
     pos = position;
     startLocation = position;
     model = sphere;
     effect = new BasicEffect(Main.Graphics.GraphicsDevice);
     if (this.type == ProjectileType.Red)
     {
         effect.LightingEnabled = true;
         effect.DirectionalLight0.DiffuseColor = Color.Red.ToVector3();
         effect.DirectionalLight0.Direction = new Vector3(1, 0, -1);
         effect.DirectionalLight0.SpecularColor = new Vector3(1, 0, 0);
         worth = 10;
         velocity = 100;
     }
     else if (this.type == ProjectileType.Green)
     {
         effect.LightingEnabled = true;
         effect.DirectionalLight0.DiffuseColor = Color.Green.ToVector3();
         effect.DirectionalLight0.Direction = new Vector3(1, 0, -1);
         effect.DirectionalLight0.SpecularColor = new Vector3(1, 0, 0);
         worth = 25;
         velocity = 120;
     }
     else
     {
         effect.LightingEnabled = true;
         effect.DirectionalLight0.DiffuseColor = Color.Blue.ToVector3();
         effect.DirectionalLight0.Direction = new Vector3(1, 0, -1);
         effect.DirectionalLight0.SpecularColor = new Vector3(1, 0, 0);
         worth = 100;
         velocity = 150;
     }
 }
Ejemplo n.º 18
0
        public override void LoadContent()
        {
            Model = Main.GameContent.Load<Model>(string.Format("Models/{0}", kart));
            sphere = Main.GameContent.Load<Model>("Models/Sphere");
            loadBar = Main.GameContent.Load<Texture2D>("Menus/Load Bar");
            sphereRed = Main.GameContent.Load<Texture2D>("Menus/Red Sphere");
            nullImage = Main.GameContent.Load<Texture2D>("Menus/Null");
            sphereBlue = Main.GameContent.Load<Texture2D>("Menus/Blue Sphere");
            sphereGreen = Main.GameContent.Load<Texture2D>("Menus/Green Sphere");
            loadBarBack = Main.GameContent.Load<Texture2D>("Menus/Load Bar Back");
            currentSphere = nullImage;

            timer = 0;
            timeDone = false;

            Effect = new BasicEffect(Main.Graphics.GraphicsDevice);
            Effect.LightingEnabled = true;
            Effect.DirectionalLight0.DiffuseColor = Color.BurlyWood.ToVector3();
            Effect.DirectionalLight0.Direction = new Vector3(1, 0, -1);
            Effect.DirectionalLight0.SpecularColor = new Vector3(1, 0, 0);

            Rotation = Matrix.Identity;
        }
Ejemplo n.º 19
0
        protected override void LoadContent()
        {
            // Load the fonts
            arial16BMFont = Content.Load<SpriteFont>("Arial16");

            // Load the model (by default the model is loaded with a BasicEffect. Use ModelContentReaderOptions to change the behavior at loading time.
            models = new List<Model>();
            foreach (var modelName in new[] { "Dude", "Duck", "Car", "Happy", "Knot", "Skull", "Sphere", "Teapot" })
            {
                model = Content.Load<Model>(modelName);
                
                // Enable default lighting  on model.
                BasicEffect.EnableDefaultLighting(model, true);

                models.Add(model);
            }
            model = models[0];

            // Instantiate a SpriteBatch
            spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));

            base.LoadContent();
        }
Ejemplo n.º 20
0
        public void Apply(Model model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.ForEach(meshPart =>
                {
                    meshPart.Effect = Process(model, meshPart);
                });
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Implements this method to process a <see cref="ModelMeshPart"/>.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="meshPart">The mesh part.</param>
 /// <returns>Effect to be associated to the <see cref="ModelMeshPart"/>.</returns>
 protected abstract Effect Process(Model model, ModelMeshPart meshPart);
Ejemplo n.º 22
0
        protected override void LoadContent()
        {
            landscape = new Landscape2(this);

            model = Content.Load<Model>("Arrow");
            arrow = new Arrow(model, this, 0, 0, 0);
            models.Push(arrow);
            model = Content.Load<Model>("Ball");
            ball = new Ball(model, this, 0, 0, 0);
            models.Push(ball);
            model = Content.Load<Model>("Pin");
            pin = new GameModel(model, this, 0, 0, 0);
            models.Push(pin);

            movement = new BallMovement(this);

            base.LoadContent();
        }
Ejemplo n.º 23
0
        protected override void LoadContent()
        {
            // Instantiate a SpriteBatch
            spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));

            // Loads the balls texture (32 textures (32x32) stored vertically => 32 x 1024 ).
            // The [Balls.dds] file is defined with the build action [ToolkitTexture] in the project
            ballsTexture = Content.Load<Texture2D>("Balls");

            // Loads a sprite font
            // The [Arial16.xml] file is defined with the build action [ToolkitFont] in the project
            arial16Font = Content.Load<SpriteFont>("Arial16");

            // Load a 3D model
            // The [Ship.fbx] file is defined with the build action [ToolkitModel] in the project
            model = Content.Load<Model>("Ship");

            // Enable default lighting on model.
            BasicEffect.EnableDefaultLighting(model, true);

            // Creates a basic effect
            basicEffect = ToDisposeContent(new BasicEffect(GraphicsDevice));
            basicEffect.PreferPerPixelLighting = true;
            basicEffect.EnableDefaultLighting();

            // Creates torus primitive
            primitive = ToDisposeContent(GeometricPrimitive.Torus.New(GraphicsDevice));

            base.LoadContent();
        }
Ejemplo n.º 24
0
 public Ball(Project2Game game, Model model, Vector3 position)
     : base(game, model, position)
 {
     this.PhysicsDescription.Mass = 600f;
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Create a new Brick with default orientation
 /// </summary>
 /// <param name="game"></param>
 /// <param name="model"></param>
 /// <param name="position"></param>
 /// <param name="size"></param>
 /// <param name="isStatic"></param>
 public Brick(Project2Game game, Model model, Vector3 position, Vector3 size, Boolean isStatic)
     : base(game, model, position, Vector3.Zero, size)
 {
     this.PhysicsDescription.Mass = 20f;
 }
Ejemplo n.º 26
0
 public Arrow(Model model, Game game, float x, float y, float z)
     : base(model, game, x, y, z)
 {
 }
Ejemplo n.º 27
0
 public Box(Project2Game game, Model model, Vector3 position, Vector3 size)
     : this(game, model, position, size, Vector3.Zero)
 {
     
 }
Ejemplo n.º 28
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            var pointerState = pointer.GetState();
            if (pointerState.Points.Count > 0 && pointerState.Points[0].EventType == PointerEventType.Released)
            {
                // Go to next model when pressing key space
                model = models[(models.IndexOf(model) + 1) % models.Count];
            }

            // Calculate the bounds of this model
            modelBounds = model.CalculateBounds();

            // Calculates the world and the view based on the model size
            const float MaxModelSize = 10.0f;
            var scaling = MaxModelSize / modelBounds.Radius;
            view = Matrix.LookAtLH(new Vector3(0, 0, - MaxModelSize * 2.5f), new Vector3(0, 0, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovLH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, MaxModelSize * 10.0f);
            world = Matrix.Translation(-modelBounds.Center.X, -modelBounds.Center.Y, -modelBounds.Center.Z) * Matrix.Scaling(scaling) * Matrix.RotationY((float)gameTime.TotalGameTime.TotalSeconds);
        }
Ejemplo n.º 29
0
 public Box(Project2Game game, Model model, Vector3 position, Vector3 size, Vector3 orientation)
     : base(game, model, position, orientation, size)
 {
     
 }
Ejemplo n.º 30
0
        private int[] BuildChannelMap(Model model, ModelAnimation animation)
        {
            var channelMap = new int[animation.Channels.Count];

            for (int i = 0; i < animation.Channels.Count; i++)
            {
                channelMap[i] = -1;
                foreach (var bone in model.Bones)
                {
                    if (bone.Name == animation.Channels[i].BoneName)
                    {
                        channelMap[i] = bone.Index;
                        break;
                    }
                }
            }

            return channelMap;
        }