예제 #1
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;
        }