Пример #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public EnemyBoss(ref GameEnemySpec spec)
     : base(ref spec)
 {
     //  Load Animations
     if (spec.AnimationFolderPath.Length > 0)
     {
         LoadAnimationData(spec.AnimationFolderPath);
     }
 }
Пример #2
0
        /// <summary>
        /// loads an enemy's information using spec file (.spec).
        /// </summary>
        /// <param name="info">enemy information for level</param>
        /// <returns>enemy's spec information</returns>
        public static GameEnemySpec LoadEnemySpec(ref EnemyInLevel info)
        {
            //  Load the spawn enemy information
            GameEnemySpec spec = new GameEnemySpec();

            spec = (GameEnemySpec)GameDataSpecManager.Load(info.SpecFilePath,
                                                           spec.GetType());

            return(spec);
        }
Пример #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameEnemy(ref GameEnemySpec spec)
            : base(spec.ModelFilePath)
        {
            this.specData = spec;

            Name    = this.specData.UnitType.ToString();
            Life    = this.specData.Life;
            MaxLife = this.SpecData.Life;

            //  Load the waepon
            CreateWeapon(spec.DefaultWeaponFilePath);

            //  Create the AI context
            this.aiContext = new AIContext();
            AddChild(this.aiContext);
        }
Пример #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public EnemyTank(ref GameEnemySpec spec)
     : base(ref spec)
 {
 }
Пример #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public EnemyBoss(ref GameEnemySpec spec)
     : base(ref spec)
 {
     //  Load Animations
     if (spec.AnimationFolderPath.Length > 0)
         LoadAnimationData(spec.AnimationFolderPath);
 }
Пример #6
0
        /// <summary>
        /// creates an enemy for level.
        /// reads an enemy information file(.spec) and configures the enemy class.
        /// The read enemy class is stored in the list.
        /// </summary>
        /// <param name="info">enemy information for level</param>
        /// <param name="sceneParent">3D scene parent node</param>
        protected void CreateSpawnEnemy(ref EnemyInLevel info,
                                        NodeBase sceneParent)
        {
            GameEnemy     enemy = null;
            GameEnemySpec spec  = LoadEnemySpec(ref info);

            //  creates an enemy by unit type
            switch (spec.UnitClass)
            {
            case UnitClassId.Tank:
                enemy = new EnemyTank(ref spec);
                break;

            case UnitClassId.LightMech:
            case UnitClassId.HeavyMech:
                enemy = new EnemyMech(ref spec);
                break;

            case UnitClassId.Boss:
                enemy = new EnemyBoss(ref spec);
                break;

            default:
                throw new NotSupportedException(
                          "Not supported unit type : " + spec.UnitType);
            }

            //  sets the material
            RenderMaterial material = new RenderMaterial();

            material.alpha        = 1.0f;
            material.diffuseColor = new Color((byte)info.MaterialDiffuseColor.X,
                                              (byte)info.MaterialDiffuseColor.Y,
                                              (byte)info.MaterialDiffuseColor.Z);

            material.specularColor = new Color((byte)info.MaterialSpecularColor.X,
                                               (byte)info.MaterialSpecularColor.Y,
                                               (byte)info.MaterialSpecularColor.Z);

            material.emissiveColor = new Color((byte)info.MaterialEmissiveColor.X,
                                               (byte)info.MaterialEmissiveColor.Y,
                                               (byte)info.MaterialEmissiveColor.Z);

            material.specularPower = info.MaterialSpecularPower;

            material.vertexColorEnabled     = false;
            material.preferPerPixelLighting = false;

            enemy.Material       = material;
            enemy.ActiveFog      = true;
            enemy.ActiveLighting = true;

            //  adds this to the list.
            enemyList.Add(enemy);

            //  entries this in parent scene node.
            sceneParent.AddChild(enemy);

            //  sets to rotate axis.
            if (spec.UnitType == UnitTypeId.Tiger)
            {
                enemy.SetRootAxis(
                    Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f)) *
                    Matrix.CreateRotationZ(MathHelper.ToRadians(90.0f)));
            }
            else
            {
                enemy.SetRootAxis(Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f)));
            }

            //  sets to stage spawn position.
            enemy.SpawnPoint =
                Matrix.CreateRotationY(MathHelper.ToRadians(info.SpawnAngle)) *
                Matrix.CreateTranslation(info.SpawnPoint);

            //  activate draw culling.
            enemy.EnableCulling = true;

            //  creates a collision data.
            {
                Vector3 centerPos = Vector3.Transform(
                    new Vector3(0.0f, spec.MechRadius, 0.0f),
                    Matrix.Invert(enemy.RootAxis));

                CollideSphere collide = new CollideSphere(centerPos, spec.MechRadius);
                enemy.SetCollide(collide);
            }

            //  creates a game event.
            switch (info.SpawnType)
            {
            case SpawnTypeId.Time:
            {
                FrameworkCore.GameEventManager.AddEvent(
                    new GameTimeEvent(info.SpawnTime, enemy, false));
            }
            break;

            case SpawnTypeId.Area:
            {
                FrameworkCore.GameEventManager.AddEvent(
                    new GameAreaEvent(info.SpawnPoint, info.SpawnRadius,
                                      enemy, false));
            }
            break;
            }

            //  sets start A.I.
            enemy.SetStartAI(info.StartAi, info.StartAiTime);
        }
Пример #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public EnemyTank(ref GameEnemySpec spec)
     : base(ref spec) {}
Пример #8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameEnemy(ref GameEnemySpec spec)
            : base(spec.ModelFilePath)
        {
            this.specData = spec;

            Name = this.specData.UnitType.ToString();
            Life = this.specData.Life;
            MaxLife = this.SpecData.Life;

            //  Load the waepon
            CreateWeapon(spec.DefaultWeaponFilePath);

            //  Create the AI context
            this.aiContext = new AIContext();
            AddChild(this.aiContext);
        }