Example #1
0
 public Combatant(Game1 parent,Room room)
     : base()
 {
     leftFist = new AABB(0, 0, 0, 0.5f, 0.5f, 0.5f);
     rightFist = new AABB(0,0,0, 0.5f, 0.5f, 0.5f);
     hp = 100;
     drunkBuffer = 0;
     this.parent = parent;
     punch1 = parent.Content.Load<SoundEffect>("punch1").CreateInstance();
     punch2 = parent.Content.Load<SoundEffect>("punch2").CreateInstance();
     punch3 = parent.Content.Load<SoundEffect>("punch3").CreateInstance();
     punch4 = parent.Content.Load<SoundEffect>("punch4").CreateInstance();
     punch1.IsLooped = punch2.IsLooped = punch3.IsLooped = punch4.IsLooped = false;
     disconnected = -1;
     Combatant.room = room;
 }
Example #2
0
        public void loadCombatant(ContentManager content,string combatDef,PlayerIndex player)
        {
            this.player = player;
            BFFileReader reader = new BFFileReader(combatDef);
            List<Texture2D> textures = new List<Texture2D>();
            reader.Open();
            string line = "";
            #region Combatant parser
            while ((line = reader.ReadLine()) != null)
            {
                string[] param = line.Split(' ');
                switch(param[0])
                {
                    case "ModelID":
                        {
                            ModelID = param[1];
                            break;
                        }
                    case "HalfWidth":
                        {
                            HalfWidth = float.Parse(param[1]);
                            break;
                        }
                    case "HalfHeight":
                        {
                            HalfHeight = float.Parse(param[1]);
                            break;
                        }
                    case "HalfLength":
                        {
                            HalfLength = float.Parse(param[1]);
                            break;
                        }
                    case "Radius":
                        {
                            Radius = float.Parse(param[1]);
                            break;
                        }
                    case "TransX":
                        {
                            TransX = float.Parse(param[1]);
                            break;
                        }
                    case "TransY":
                        {
                            TransY = float.Parse(param[1]);
                            break;
                        }
                    case "TransZ":
                        {
                            TransZ = float.Parse(param[1]);
                            break;
                        }
                    case "Texture":
                        {
                            textures.Add(content.Load<Texture2D>(param[1]));
                            break;
                        }
                    case "CollideType":
                        {
                            switch (param[1].ToUpper())
                            {
                                case "AABB":
                                    {
                                        ORIGEN = new AABB();
                                        CollisionType = Origen.Collision_Type.AABB;

                                        break;
                                    }
                                case "NONE":
                                    {
                                        CollisionType = Origen.Collision_Type.NONE;
                                        break;
                                    }
                                case "BC":
                                    {
                                        ORIGEN = new BC();
                                        CollisionType = Origen.Collision_Type.BC;
                                        break;
                                    }
                                case "BS":
                                    {
                                        ORIGEN = new BS();
                                        CollisionType = Origen.Collision_Type.BS;
                                        break;
                                    }
                            }
                            break;
                        }

                }
            }
            #endregion
            reader.Close();
            model = new AnimatedModel(ModelID);
            model.LoadContent(content);
            //load the textures for the model
            model.textures = textures.ToArray();
            //play an animation
            model.PlayAnimation("TakePunchLeft", false);
            RotX -= (float)Math.PI/2;
        }
Example #3
0
        public bool collides(AABB other)
        {
            //check to se if this AABB collides with the other AABB

            return (Math.Abs(OrigenZ - other.OrigenZ) <= halfHeight + other.halfHeight &&
                Math.Abs(OrigenX - other.OrigenX) <= halfWidth + other.HalfWidth &&
                Math.Abs(OrigenY - other.OrigenY) <= HalfLength + other.HalfLength);
        }
Example #4
0
        public bool loadRoom(string roomAddress, ContentManager content, Shader shader, GraphicsDevice device,string[] selectCombatants)
        {
            //load the menu
            Texture2D exit = content.Load<Texture2D>("Exit");
            Texture2D resume = content.Load<Texture2D>("Resume");

            Combatant.PauseMenu = new Menu(4, new Rectangle(
                parent.ScreenWidth / 2 - (exit.Width / 2),
                parent.ScreenHeight / 2 - (exit.Height / 2 * 2),
                exit.Width,
                exit.Height),
                resume, exit);
            hasWon = false;
            BFFileReader reader = new BFFileReader(roomAddress);
            reader.Open();

            Dictionary<string, RefModel> modelDefs = new Dictionary<string, RefModel>();
            string line;
            //read all of the info in the script
            #region room parser
            while ((line = reader.ReadLine()) != null)
            {
                string[] param = line.Split(' ');

                //read the param
                switch (param[0])
                {
                    case "ModelDef":
                        {
                            //add the new modelname to the hashtable
                            BFModel model = new BFModel();//***
                            model.model = content.Load<Model>(param[1]);
                            shader.setEffects(model);
                            //add the model to the hashtable of models
                            models.Add(param[1], model);
                            break;
                        }
                    case "Music":
                        {
                            //set music
                            music = content.Load<SoundEffect>(param[1]);
                            break;
                        }
                    case "Model":
                        {
                            string modelName = param[1];
                            RefModel refModel = new RefModel();
                            while ((line = reader.ReadLine()) != null && line != "}")
                            {
                                //keep reading into this modelRef
                                param = line.Split(' ');
                                switch (param[0])
                                {
                                    case "ModelID":
                                        {
                                            //set the model id of this ref mode
                                            refModel.ModelID = param[1];

                                            break;
                                        }
                                    case "CollideType":
                                        {
                                            switch (param[1].ToUpper())
                                            {
                                                case "AABB":
                                                    {
                                                        refModel.ORIGEN = new AABB();
                                                        refModel.CollisionType = Origen.Collision_Type.AABB;

                                                        break;
                                                    }
                                                case "NONE":
                                                    {
                                                        refModel.CollisionType = Origen.Collision_Type.NONE;
                                                        break;
                                                    }
                                                case "BC":
                                                    {
                                                        refModel.ORIGEN = new BC();
                                                        refModel.CollisionType = Origen.Collision_Type.BC;
                                                        break;
                                                    }
                                                case "BS":
                                                    {
                                                        refModel.ORIGEN = new BS();
                                                        refModel.CollisionType = Origen.Collision_Type.BS;
                                                        break;
                                                    }
                                            }
                                            break;
                                        }
                                    case "OrigenX":
                                        {
                                            refModel.X = float.Parse(param[1]);
                                            break;
                                        }
                                    case "OrigenY":
                                        {
                                            refModel.Y = float.Parse(param[1]);
                                            break;
                                        }
                                    case "OrigenZ":
                                        {
                                            refModel.Z = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotX":
                                        {
                                            refModel.RotX = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotY":
                                        {
                                            refModel.RotY = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotZ":
                                        {
                                            refModel.RotZ = float.Parse(param[1]);
                                            break;
                                        }
                                    case "HalfWidth":
                                        {
                                            refModel.HalfWidth = float.Parse(param[1]);
                                            break;
                                        }
                                    case "HalfHeight":
                                        {
                                            refModel.HalfHeight = float.Parse(param[1]);
                                            break;
                                        }
                                    case "HalfLength":
                                        {
                                            refModel.HalfLength = float.Parse(param[1]);
                                            break;
                                        }
                                    case "Radius":
                                        {
                                            refModel.Radius = float.Parse(param[1]);
                                            break;
                                        }
                                    case "TransX":
                                        {
                                            refModel.TransX = float.Parse(param[1]);
                                            break;
                                        }
                                    case "TransY":
                                        {
                                            refModel.TransY = float.Parse(param[1]);
                                            break;
                                        }
                                    case "TransZ":
                                        {
                                            refModel.TransZ = float.Parse(param[1]);
                                            break;
                                        }
                                }

                            }

                            refModel.updateMatrix();
                            //add the refmodel to the list of modelsDefs
                            modelDefs.Add(modelName, refModel);
                            break;
                        }

                    case "DrinkSpawner":
                        {
                            string modelID = "";
                            float X = 0, Y = 0, Z = 0, RotX = 0, RotY = 0, RotZ = 0,spawnTime = 0,drinkStrength = 0,
                                halfWidth = 0,halfLength = 0,halfHeight = 0,transX = 0,transY = 0,transZ = 0;
                            while ((line = reader.ReadLine()) != null && line != "}")
                            {
                                param = line.Split(' ');
                                switch (param[0])
                                {
                                    case "X":
                                        {
                                            X = float.Parse(param[1]);
                                            break;
                                        }
                                    case "Y":
                                        {
                                            Y = float.Parse(param[1]);
                                            break;
                                        }
                                    case "Z":
                                        {
                                            Z = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotX":
                                        {
                                            RotX = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotY":
                                        {
                                            RotY = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotZ":
                                        {
                                            RotZ = float.Parse(param[1]);
                                            break;
                                        }
                                    case "ModelID":
                                        {
                                            modelID = param[1];
                                            break;
                                        }
                                    case "SpawnTime":
                                        {
                                            spawnTime = float.Parse(param[1]);
                                            break;
                                        }
                                    case "DrinkStrength":
                                        {
                                            drinkStrength = float.Parse(param[1]);
                                            break;
                                        }
                                    case "HalfWidth":
                                        {
                                            halfWidth = float.Parse(param[1]);
                                            break;
                                        }
                                    case "HalfHeight":
                                        {
                                            halfHeight= float.Parse(param[1]);
                                            break;
                                        }
                                    case "HalfLength":
                                        {
                                            halfLength = float.Parse(param[1]);
                                            break;
                                        }
                                    case "TransX":
                                        {
                                            transX = float.Parse(param[1]);
                                            break;
                                        }
                                    case "TransZ":
                                        {
                                            transZ = float.Parse(param[1]);
                                            break;
                                        }
                                    case "TransY":
                                        {
                                            transY = float.Parse(param[1]);
                                            break;
                                        }

                                }

                            }

                            DrinkSpawner drinkSpawner = new DrinkSpawner();
                            drinkSpawner.CollisionType = Origen.Collision_Type.AABB;
                            drinkSpawner.ORIGEN = new AABB();
                            drinkSpawner.X = X;
                            drinkSpawner.Y = Y;
                            drinkSpawner.Z = Z;
                            drinkSpawner.StartX = X;
                            drinkSpawner.StartY = Y;
                            drinkSpawner.StartZ = Z;
                            drinkSpawner.DrinkStrength = drinkStrength;
                            drinkSpawner.HalfHeight = halfHeight;
                            drinkSpawner.HalfLength = halfLength;
                            drinkSpawner.HalfWidth = halfWidth;
                            drinkSpawner.ModelID = modelID;
                            drinkSpawner.RotX = RotX;
                            drinkSpawner.RotY = RotY;
                            drinkSpawner.RotZ = RotZ;
                            drinkSpawner.TransX = transX;
                            drinkSpawner.TransY = transY;
                            drinkSpawner.TransZ = transZ;
                            drinkSpawner.DrinkSpawnTime = spawnTime;
                            drinkSpawner.SpawnTime = spawnTime;
                            drinkSpawner.updateMatrix();
                            drinks.Add(drinkSpawner);
                            break;
                        }

                    case "ModelGroup":
                        {
                            List<string> includedModels = new List<string>();
                            float X = 0, Y = 0, Z = 0, RotX = 0, RotY = 0, RotZ = 0;
                            while ((line = reader.ReadLine()) != null && line != "}")
                            {
                                param = line.Split(' ');
                                switch (param[0])
                                {
                                    case "X":
                                        {
                                            X = float.Parse(param[1]);
                                            break;
                                        }
                                    case "Y":
                                        {
                                            Y = float.Parse(param[1]);
                                            break;
                                        }
                                    case "Z":
                                        {
                                            Z = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotX":
                                        {
                                            RotX = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotY":
                                        {
                                            RotY = float.Parse(param[1]);
                                            break;
                                        }
                                    case "RotZ":
                                        {
                                            RotZ = float.Parse(param[1]);
                                            break;
                                        }
                                    case "IncludeModel":
                                        {
                                            includedModels.Add(param[1]);
                                            break;
                                        }
                                }

                            }

                            //now add the models to the scenes models
                            foreach (string modelName in includedModels)
                            {
                                //load the model to copy the model data from
                                RefModel temp = (RefModel)modelDefs[modelName];
                                RefModel copy = new RefModel();
                                copy.ORIGEN = new AABB();
                                copy.ORIGEN.Type = Origen.Collision_Type.AABB;
                                copy.HalfHeight = temp.HalfHeight;
                                copy.HalfLength = temp.HalfLength;
                                copy.HalfWidth = temp.HalfWidth;
                                copy.X = temp.X + X;
                                copy.Y = temp.Y + Y;
                                copy.Z = temp.Z + Z;
                                copy.RotX = temp.RotX + RotX;
                                copy.RotY = temp.RotY + RotY;
                                copy.RotZ = temp.RotZ + RotZ;
                                copy.TransX = temp.TransX;
                                copy.TransY = temp.TransY;
                                copy.TransZ = temp.TransZ;
                                copy.ModelID = temp.ModelID;
                                copy.updateMatrix();
                                //add the copy
                                parts.Add(copy);
                            }
                            break;
                        }

                    case "XWidth":
                        {
                            xWidth = float.Parse(param[1]);
                            break;
                        }

                    case "YWidth":
                        {
                            yWidth = float.Parse(param[1]);
                            break;
                        }

                    case "ZWidth":
                        {
                            zWidth = float.Parse(param[1]);
                            break;
                        }
                    case "LeftWallTexture":
                        {
                            leftWallTex = content.Load<Texture2D>(param[1]);
                            break;
                        }
                    case "RightWallTexture":
                        {
                            rightWallTex = content.Load<Texture2D>(param[1]);
                            break;
                        }
                    case "FrontWallTexture":
                        {
                            frontWallTex = content.Load<Texture2D>(param[1]);
                            break;
                        }
                    case "BackWallTexture":
                        {
                            backWallTex = content.Load<Texture2D>(param[1]);
                            break;
                        }
                    case "CeilingTexture":
                        {
                            ceilingTex = content.Load<Texture2D>(param[1]);
                            break;
                        }
                    case "FloorTexture":
                        {
                            floorTex = content.Load<Texture2D>(param[1]);
                            break;
                        }

                    case "Light":
                        {
                            switch (param[1])
                            {
                                case "X":
                                    {
                                        lightPos.X = float.Parse(param[2]);
                                        break;
                                    }
                                case "Y":
                                    {
                                        lightPos.Y = float.Parse(param[2]);
                                        break;
                                    }
                                case "Z":
                                    {
                                        lightPos.Z = float.Parse(param[2]);
                                        break;
                                    }
                                case "Power":
                                    {
                                        lightPower = float.Parse(param[2]);
                                        break;
                                    }
                                case "Ambient":
                                    {
                                        ambientPower = float.Parse(param[2]);
                                        break;
                                    }

                            }
                            break;
                        }
                    case "FloorXDensity":
                        {
                            floorXDensity = float.Parse(param[1]);
                            break;
                        }
                    case "FloorYDensity":
                        {
                            floorYDensity = float.Parse(param[1]);
                            break;
                        }
                    case "WallXDensity":
                        {
                            wallXDensity = float.Parse(param[1]);
                            break;
                        }
                    case "WallYDensity":
                        {
                            wallYDensity = float.Parse(param[1]);
                            break;
                        }
                    case "BarX":
                        {
                            barX = float.Parse(param[1]);
                            break;
                        }
                    case "BarY":
                        {
                            barY = float.Parse(param[1]);
                            break;
                        }
                    case "BarWidth":
                        {
                            barWidth = float.Parse(param[1]);
                            break;
                        }

                }
            }
            #endregion
            //close the file
            reader.Close();

            //play the music if the music exists
            if (music != null)
            {
                instance = music.CreateInstance();
                instance.IsLooped = true;
                instance.Play();
            }

            winSong = content.Load<SoundEffect>("WinSong").CreateInstance();
            winSong.IsLooped = true;
            //set up the bounding box for the room

            //init the buffers
            initBuffers(device);

            bounds = new AABB(0, 0, 0, xWidth, yWidth, zWidth);
            //load the combatants after clearing the list of the old ones
            combatants.Clear();
            loadCombatants(content,selectCombatants,parent.NumOfPlayers);

            return true;
        }
Example #5
0
        public bool collides(AABB other)
        {
            //check to se if this AABB collides with the other AABB
            bool result;
            bool b1 = Math.Abs(OrigenZ - other.OrigenZ) <= halfHeight + other.halfHeight;
            bool b2 = Math.Abs(OrigenX - other.OrigenX) <= halfWidth + other.HalfWidth;
            bool b3 = Math.Abs(OrigenY - other.OrigenY) <= HalfLength + other.HalfLength;
            result = b1 && b2 && b3;

            return result;
            //return Math.Abs(OrigenZ - other.OrigenZ) <= halfHeight + other.halfHeight &&
            //    Math.Abs(OrigenX - other.OrigenX) <= halfWidth + other.HalfWidth &&
            //    Math.Abs(OrigenY - other.OrigenY) <= HalfLength + other.HalfLength);
        }