Ejemplo n.º 1
0
 /// <summary>
 /// 新建一个AOD模型
 /// </summary>
 /// <param name="game">所属的Game</param>
 /// <param name="modelType">AOD模型类型</param>
 public AODModel(GameWorld gameWorld, AODModelType modelType, Vector3 position, Matrix rotation, float scale)
 {
     this.scale      = scale;
     this.rotation   = rotation;
     this.position   = position;
     effects         = new List <ParticleEffect>(2);
     deathEffects    = new List <ParticleEffect>(2);
     movementEffects = new List <ParticleEffect>(2);
     LoadType(gameWorld, modelType);
     foreach (ParticleEffect e in birthEffects)
     {
         if (e != null)
         {
             e.BeginToDie();
         }
     }
     if (birthsound != null)
     {
         gameWorld.Play3DSound(birthsound, position);
     }
     ResetBounding();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 从AODModelType读取相关参数
        /// </summary>
        /// <param name="game"></param>
        /// <param name="modelType">需要读取的AODModelType</param>
        void LoadType(GameWorld gameWorld, AODModelType modelType)
        {
            this.modelType = modelType;
            #region 已抛弃的代码
            //if (modelType.dModel1 != "")
            //{
            //    models.Add(new DModel(this,
            //                          gameWorld.game,
            //                          gameWorld.game.Content.Load<DModelType>(modelType.dModel1),
            //                          modelType.dModel1_scale,
            //                          modelType.dModel1_rotation,
            //                          modelType.dModel1_position));

            //}
            //if (modelType.dModel2 != "")
            //{
            //    models.Add(new DModel(this,
            //                          gameWorld.game,
            //                          gameWorld.game.Content.Load<DModelType>(modelType.dModel2),
            //                          modelType.dModel2_scale,
            //                          modelType.dModel2_rotation,
            //                          modelType.dModel2_position));

            //}
            //if (modelType.dModel3 != "")
            //{
            //    models.Add(new DModel(this,
            //                          gameWorld.game,
            //                          gameWorld.game.Content.Load<DModelType>(modelType.dModel3),
            //                          modelType.dModel3_scale,
            //                          modelType.dModel3_rotation,
            //                          modelType.dModel3_position));

            //}
            //if (modelType.dModel4 != "")
            //{
            //    models.Add(new DModel(this,
            //                          gameWorld.game,
            //                          gameWorld.game.Content.Load<DModelType>(modelType.dModel4),
            //                          modelType.dModel4_scale,
            //                          modelType.dModel4_rotation,
            //                          modelType.dModel4_position));

            //}
            //if (modelType.dModel5 != "")
            //{
            //    models.Add(new DModel(this,
            //                          gameWorld.game,
            //                          gameWorld.game.Content.Load<DModelType>(modelType.dModel5),
            //                          modelType.dModel5_scale,
            //                          modelType.dModel5_rotation,
            //                          modelType.dModel5_position));

            //}
            //if (modelType.pEffect1 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect1),
            //                                   this,
            //                                   modelType.pEffect1_position));

            //}
            //if (modelType.pEffect2 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect2),
            //                                   this,
            //                                   modelType.pEffect2_position));

            //}
            //if (modelType.pEffect3 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect3),
            //                                   this,
            //                                   modelType.pEffect3_position));

            //}
            //if (modelType.pEffect4 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect4),
            //                                   this,
            //                                   modelType.pEffect4_position));

            //}
            //if (modelType.pEffect5 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect5),
            //                                   this,
            //                                   modelType.pEffect5_position));

            //}
            //if (modelType.pEffect6 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect6),
            //                                   this,
            //                                   modelType.pEffect6_position));

            //}
            //if (modelType.pEffect7 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect7),
            //                                   this,
            //                                   modelType.pEffect7_position));

            //}
            //if (modelType.pEffect8 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect8),
            //                                   this,
            //                                   modelType.pEffect8_position));

            //}
            //if (modelType.pEffect9 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect9),
            //                                   this,
            //                                   modelType.pEffect9_position));

            //}
            //if (modelType.pEffect10 != "")
            //{
            //    effects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.pEffect10),
            //                                   this,
            //                                   modelType.pEffect10_position));

            //}
            //if (modelType.deathEffect1 != "")
            //{
            //    deathEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.deathEffect1),
            //                                   this,
            //                                   modelType.deathEffect1_position));

            //}
            //if (modelType.deathEffect2 != "")
            //{
            //    deathEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.deathEffect2),
            //                                   this,
            //                                   modelType.deathEffect2_position));

            //}
            //if (modelType.moveEffect1 != "")
            //{
            //    movingEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.moveEffect1),
            //                                   this,
            //                                   modelType.moveEffect1_position));

            //}
            //if (modelType.moveEffect2 != "")
            //{
            //    movingEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.moveEffect2),
            //                                   this,
            //                                   modelType.moveEffect2_position));

            //}
            //if (modelType.moveEffect3 != "")
            //{
            //    movingEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.moveEffect3),
            //                                   this,
            //                                   modelType.moveEffect3_position));

            //}
            //if (modelType.moveEffect4 != "")
            //{
            //    movingEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.moveEffect4),
            //                                   this,
            //                                   modelType.moveEffect4_position));

            //}
            //if (modelType.moveEffect5 != "")
            //{
            //    movingEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.moveEffect5),
            //                                   this,
            //                                   modelType.moveEffect5_position));

            //}
            //if (modelType.moveEffect6 != "")
            //{
            //    movingEffects.Add(new ParticleEffect(gameWorld,
            //                                   gameWorld.game.Content.Load<ParticleEffectType>(modelType.moveEffect6),
            //                                   this,
            //                                   modelType.moveEffect6_position));

            //}
            #endregion
            foreach (DModelEntry de in modelType.ChildModels)
            {
                if (de != null)
                {
                    Matrix r = AODGameLibrary.Helpers.RandomHelper.RotationVector3ToMatrix(de.Rotation);

                    models.Add(new DModel(this,
                                          gameWorld.game,
                                          de.DModel,
                                          de.Scale,
                                          r,
                                          de.Position, de.Alpha));
                }
            }
            foreach (ParticleEffectEntry pE in modelType.NormalEffects)
            {
                if (pE != null)
                {
                    effects.Add(new ParticleEffect(gameWorld, gameWorld.game.Content.Load <ParticleEffectType>(pE.AssetName), this, pE.Position, pE.Scale));
                }
            }
            foreach (ParticleEffectEntry pE in modelType.MovementEffects)
            {
                if (pE != null)
                {
                    movementEffects.Add(new ParticleEffect(gameWorld, gameWorld.game.Content.Load <ParticleEffectType>(pE.AssetName), this, pE.Position, pE.Scale));
                }
            }
            foreach (ParticleEffectEntry pE in modelType.DeathEffects)
            {
                if (pE != null)
                {
                    deathEffects.Add(new ParticleEffect(gameWorld, gameWorld.game.Content.Load <ParticleEffectType>(pE.AssetName), this, pE.Position, pE.Scale));
                }
            }
            foreach (ParticleEffectEntry pE in modelType.BirthEffects)
            {
                if (pE != null)
                {
                    birthEffects.Add(new ParticleEffect(gameWorld, gameWorld.game.Content.Load <ParticleEffectType>(pE.AssetName), this, pE.Position, pE.Scale));
                }
            }
            if (modelType.BirthSound != "")
            {
                birthsound = gameWorld.Content.Load <SoundEffect>(modelType.BirthSound).CreateInstance();
            }
            if (modelType.DeathSound != "")
            {
                deathsound = gameWorld.Content.Load <SoundEffect>(modelType.DeathSound).CreateInstance();
            }
            this.gameWorld = gameWorld;
        }