Beispiel #1
0
 public BeerController(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     physicalData = entity.GetSharedData(typeof(Entity)) as Entity;
     physicalData.IsAffectedByGravity = false;
     physicalData.CollisionInformation.Events.DetectingInitialCollision += HandleCollision;
 }
Beispiel #2
0
 public RioterController(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     physicalData = entity.GetSharedData(typeof(Entity)) as Entity;
     anims = entity.GetSharedData(typeof(AnimationPlayer)) as AnimationPlayer;
     playerData = game.GetPlayerEntity();
     runSpeed = game.rand.Next(15, 28);
 }
Beispiel #3
0
 public void AttractMinions(GameEntity ent)
 {
     foreach (GameEntity r in recruits)
     {
         RioterController c = r.GetComponent(typeof(RioterController)) as RioterController;
         c.AttackObject(ent);
     }
 }
        public AnimatedModelComponent(Game1 game, GameEntity entity, Model model, float drawScale, Vector3 drawOffset)
            : base(game, entity)
        {
            this.model = model;
            this.localOffset = drawOffset;
            this.syncedModels = entity.GetSharedData(typeof(Dictionary<string, Model>)) as Dictionary<string, Model>;
            this.animationPlayer = entity.GetSharedData(typeof(AnimationPlayer)) as AnimationPlayer;

            animationPlayer.StartClip(animationPlayer.skinningDataValue.AnimationClips.Keys.First(), MixType.None);

            modelParams = new SharedGraphicsParams();
            modelParams.size = new Vector3(drawScale);
            entity.AddSharedData(typeof(SharedGraphicsParams), modelParams);
        }
        /// <summary>
        /// constructs a new model component for rendering models without animations
        /// </summary>
        public UnanimatedModelComponent(Game1 game, GameEntity entity, Model model, Vector3 drawScale, Vector3 localOffset, float yaw, float pitch, float roll)
            : base(game, entity)
        {
            this.model = model;
            this.localOffset = localOffset;

            modelParams = new SharedGraphicsParams();
            modelParams.size = drawScale;
            entity.AddSharedData(typeof(SharedGraphicsParams), modelParams);

            this.yaw = yaw;
            this.pitch = pitch;
            this.roll = roll;

            Matrix3X3 bepurot = physicalData.OrientationMatrix;
            rotation = new Matrix(bepurot.M11, bepurot.M12, bepurot.M13, 0, bepurot.M21, bepurot.M22, bepurot.M23, 0, bepurot.M31, bepurot.M32, bepurot.M33, 0, 0, 0, 0, 1);
        }
Beispiel #6
0
        public void CreateBeer(Vector3 loc)
        {
            GameEntity entity = new GameEntity("");

            Entity box = new Box(loc, 6, 2, 6);
            box.CollisionInformation.CollisionRules.Personal = BEPUphysics.CollisionRuleManagement.CollisionRule.NoSolver;
            entity.AddSharedData(typeof(Entity), box);

            PhysicsComponent physics = new PhysicsComponent(mainGame, entity);
            entity.AddComponent(typeof(PhysicsComponent), physics);
            genComponentManager.AddComponent(physics);

            UnanimatedModelComponent graphics = new UnanimatedModelComponent(mainGame, entity, GetUnanimatedModel("Models\\beer"), new Vector3(3), Vector3.Zero, 0, 0, 0);
            graphics.AddYawSpeed(.1f);
            graphics.AddEmitter(typeof(BeerGlowSystem), "glow", 8, 0, Vector3.Up * 8);
            entity.AddComponent(typeof(UnanimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);

            BeerController controller = new BeerController(mainGame, entity);
            entity.AddComponent(typeof(BeerController), controller);
            genComponentManager.AddComponent(controller);
        }
Beispiel #7
0
        public void CreatePlayer()
        {
            GameEntity entity = new GameEntity("player");

            Entity box = new Box(playerSpawn, 2f, 4, 2f, 8);
            box.CollisionInformation.CollisionRules.Group = (Game as Game1).guyCollisionGroup;
            box.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;
            box.LocalInertiaTensorInverse = new Matrix3X3();
            entity.AddSharedData(typeof(Entity), box);
            camera.AssignEntity(box);

            PhysicsComponent physics = new PhysicsComponent(mainGame, entity);
            entity.AddComponent(typeof(PhysicsComponent), physics);
            genComponentManager.AddComponent(physics);

            Model playerModel = GetAnimatedModel("Models\\Player\\k_idle1");
            AnimationPlayer anims = new AnimationPlayer(playerModel.Tag as SkinningData);
            entity.AddSharedData(typeof(AnimationPlayer), anims);

            AnimatedModelComponent graphics = new AnimatedModelComponent(mainGame, entity, playerModel, 1, Vector3.Down * 2);
            entity.AddComponent(typeof(AnimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);

            PlayerController controller = new PlayerController(mainGame, entity);
            entity.AddComponent(typeof(PlayerController), controller);
            genComponentManager.AddComponent(controller);

            player = entity;
        }
Beispiel #8
0
        public void CreateMailbox2(Vector3 pos)
        {
            GameEntity entity = new GameEntity("prop");

            Entity data = new Box(pos, 2, 3.75f, 2, 200);
            data.CollisionInformation.LocalPosition += Vector3.Down * 1;
            entity.AddSharedData(typeof(Entity), data);

            PhysicsComponent roomPhysics = new PhysicsComponent(mainGame, entity);
            entity.AddComponent(typeof(PhysicsComponent), roomPhysics);
            genComponentManager.AddComponent(roomPhysics);

            UnanimatedModelComponent graphics = new UnanimatedModelComponent(mainGame, entity, GetUnanimatedModel("Models\\mailbox2"), new Vector3(1), Vector3.Down * 2, 0, 0, 0);
            entity.AddComponent(typeof(UnanimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);

            MailboxController controller = new MailboxController(mainGame, entity);
            entity.AddComponent(typeof(MailboxController), controller);
            genComponentManager.AddComponent(controller);

            lightPoles.Add(entity);
        }
Beispiel #9
0
        public void CreateLightPole(Vector3 pos)
        {
            GameEntity entity = new GameEntity("prop");

            Entity data = new Box(pos, 4, 18, 4, 800);
            data.CollisionInformation.LocalPosition += Vector3.Down * 4;
            entity.AddSharedData(typeof(Entity), data);

            PhysicsComponent roomPhysics = new PhysicsComponent(mainGame, entity);
            entity.AddComponent(typeof(PhysicsComponent), roomPhysics);
            genComponentManager.AddComponent(roomPhysics);

            UnanimatedModelComponent graphics = new UnanimatedModelComponent(mainGame, entity, GetUnanimatedModel("Models\\lamp"), new Vector3(4), Vector3.Down * 16.5f, 0, 0, 0);
            entity.AddComponent(typeof(UnanimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);

            LightPoleController controller = new LightPoleController(mainGame, entity);
            entity.AddComponent(typeof(LightPoleController), controller);
            genComponentManager.AddComponent(controller);

            camera.AddLightPoleEntity(data);

            lightPoles.Add(entity);
        }
Beispiel #10
0
        public void CreateLevel()
        {
            Vector3 levelScale = new Vector3(5);
            GameEntity entity = new GameEntity("environment");

            Entity locationHolder = new Box(Vector3.Zero, 1, 1, 1);
            entity.AddSharedData(typeof(Entity), locationHolder);

            Model roomModel = GetUnanimatedModel("Models\\welch");
            Vector3[] vertices;
            int[] indices;
            TriangleMesh.GetVerticesAndIndicesFromModel(roomModel, out vertices, out indices);
            StaticMesh roomMesh = new StaticMesh(vertices, indices, new AffineTransform(levelScale, Quaternion.Identity, Vector3.Zero));
            entity.AddSharedData(typeof(StaticMesh), roomMesh);

            StaticMeshComponent roomPhysics = new StaticMeshComponent(mainGame, entity);
            entity.AddComponent(typeof(StaticMeshComponent), roomPhysics);
            genComponentManager.AddComponent(roomPhysics);

            UnanimatedModelComponent graphics = new UnanimatedModelComponent(mainGame, entity, roomModel, levelScale, Vector3.Zero, 0, 0, 0);
            entity.AddComponent(typeof(UnanimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);

            level = entity;

            Matrix transform = Matrix.CreateScale(levelScale) * Matrix.CreateRotationY(MathHelper.PiOver2);
            LevelTagData tag = roomModel.Tag as LevelTagData;
            if (tag != null)
            {
                List<Vector3> lightPoles = tag.lightPoleLocations;
                foreach (Vector3 vec in lightPoles)
                {
                    CreateLightPole(Vector3.Transform(vec, transform) + Vector3.Up * 15);
                }

                List<Vector3> cars = tag.cars;
                foreach (Vector3 vec in cars)
                {
                    CreateCar(Vector3.Transform(vec, transform) + Vector3.Up * 15);
                }

                List<Vector3> boxes1 = tag.mailbox1;
                foreach (Vector3 vec in boxes1)
                {
                    CreateMailbox1(Vector3.Transform(vec, transform) + Vector3.Up * 5);
                }

                List<Vector3> boxes2 = tag.mailbox2;
                foreach (Vector3 vec in boxes2)
                {
                    CreateMailbox2(Vector3.Transform(vec, transform) + Vector3.Up * 5);
                }

                List<Vector3> beer = tag.beer;
                foreach (Vector3 vec in beer)
                {
                    CreateBeer(Vector3.Transform(vec, transform) + Vector3.Up * 5);
                }

                CreateBeer(new Vector3(10000, 10000, 10000));
            }

            CreateSkybox();
        }
Beispiel #11
0
 public CarController(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     stupid = 35;
 }
Beispiel #12
0
 public void PunchObject(GameEntity obj)
 {
     entities.AttractMinions(obj);
     AddStupid(2);
 }
Beispiel #13
0
        private void CreateSkybox()
        {
            GameEntity entity = new GameEntity("");

            Entity locationHolder = new Box(Vector3.Zero, 0, 0, 0);
            entity.AddSharedData(typeof(Entity), locationHolder);

            UnanimatedModelComponent graphics = new UnanimatedModelComponent(mainGame, entity, GetUnanimatedModel("Models\\skybox"), new Vector3(5), Vector3.Zero, 0, 0, 0);
            entity.AddComponent(typeof(UnanimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);
        }
Beispiel #14
0
 public Component(Game1 game, GameEntity entity)
 {
     this.Game = game;
     this.Entity = entity;
     Remove = false;
 }
Beispiel #15
0
 public MailboxController(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     stupid = 10;
 }
Beispiel #16
0
 public void AttackObject(GameEntity ob)
 {
     attackingObj = ob.GetSharedData(typeof(Entity)) as Entity;
 }
Beispiel #17
0
 public DestructibleProp(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     physicalData = entity.GetSharedData(typeof(Entity)) as Entity;
     physicalData.CollisionInformation.Events.DetectingInitialCollision += HandleCollision;
 }
Beispiel #18
0
 public PhysicsComponent(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     this.collidable = entity.GetSharedData(typeof(Entity)) as Entity;
 }
Beispiel #19
0
        public void CreatePunch(Vector3 pos, Vector3 dir, bool player)
        {
            GameEntity entity = new GameEntity("punch");

            Entity data = new Box(pos, .5f, .5f, .5f, 300);
            data.CollisionInformation.CollisionRules.Group = (Game as Game1).punchCollisionGroup;
            data.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;

            data.LinearVelocity = dir * 50;
            entity.AddSharedData(typeof(Entity), data);

            PhysicsComponent roomPhysics = new PhysicsComponent(mainGame, entity);
            entity.AddComponent(typeof(PhysicsComponent), roomPhysics);
            genComponentManager.AddComponent(roomPhysics);

            PunchController controller = new PunchController(mainGame, entity, player);
            entity.AddComponent(typeof(PunchController), controller);
            genComponentManager.AddComponent(controller);
        }
Beispiel #20
0
        public void CreateRioter(Vector3 loc)
        {
            GameEntity entity = new GameEntity("derper");

            Entity box = new Box(loc, 2f, 4, 2f, 4);
            box.Material.KineticFriction = 0;
            box.Material.KineticFriction = 0;
            box.LocalInertiaTensorInverse = new Matrix3X3();
            box.CollisionInformation.CollisionRules.Group = (Game as Game1).guyCollisionGroup;
            entity.AddSharedData(typeof(Entity), box);

            PhysicsComponent physics = new PhysicsComponent(mainGame, entity);
            entity.AddComponent(typeof(PhysicsComponent), physics);
            genComponentManager.AddComponent(physics);

            Model guy = GetAnimatedModel("Models\\Player\\k_idle1");
            AnimationPlayer anims = new AnimationPlayer(guy.Tag as SkinningData);
            entity.AddSharedData(typeof(AnimationPlayer), anims);

            AnimatedModelComponent graphics = new AnimatedModelComponent(mainGame, entity, guy, 1, Vector3.Down * 2);
            entity.AddComponent(typeof(AnimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);

            RioterController controller = new RioterController(mainGame, entity);
            entity.AddComponent(typeof(RioterController), controller);
            genComponentManager.AddComponent(controller);

            rioters.Add(entity);
        }
Beispiel #21
0
 public DrawableComponent3D(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     this.physicalData = entity.GetSharedData(typeof(Entity)) as Entity;
 }
Beispiel #22
0
 public StaticMeshComponent(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     this.collidable = Entity.GetSharedData(typeof(StaticMesh)) as StaticMesh;
 }
Beispiel #23
0
 public LightPoleController(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     stupid = 25;
 }
Beispiel #24
0
        public void CreateCar(Vector3 pos)
        {
            GameEntity entity = new GameEntity("prop");

            Entity data = new Box(pos, 8, 13, 11, 500);
            data.CollisionInformation.LocalPosition += Vector3.Down * 8;
            entity.AddSharedData(typeof(Entity), data);

            PhysicsComponent physics = new PhysicsComponent(mainGame, entity);
            entity.AddComponent(typeof(PhysicsComponent), physics);
            genComponentManager.AddComponent(physics);

            UnanimatedModelComponent graphics = new UnanimatedModelComponent(mainGame, entity, GetUnanimatedModel("Models\\jeep"), new Vector3(2, 4, 2), Vector3.Down * 16.5f, 0, 0, 0);
            entity.AddComponent(typeof(UnanimatedModelComponent), graphics);
            modelManager.AddComponent(graphics);

            CarController controller = new CarController(mainGame, entity);
            entity.AddComponent(typeof(CarController), controller);
            genComponentManager.AddComponent(controller);

            cars.Add(entity);
        }
Beispiel #25
0
 public PlayerController(Game1 game, GameEntity entity)
     : base(game, entity)
 {
     physicalData = entity.GetSharedData(typeof(Entity)) as Entity;
     anims = entity.GetSharedData(typeof(AnimationPlayer)) as AnimationPlayer;
 }