示例#1
0
        /// <summary>
        /// Creep instance constructor.
        /// </summary>
        /// <param name="stats">A dictionary of stats for this instance.</param>
        /// <param name="position">The spawning position.</param>
        /// <param name="textureID">The MEDIA_ID for this creep's texture.</param>
        public Creep(CreepTypeData creepData, Vector2 position, MEDIA_ID textureID)
        {
            CurrentDebuffs = new List<Debuff>();
            this.CenterPosition = new Vector2(position.X , position.Y);
            this.TextureID = textureID;

            DistanceTravelled = 0;

            Rotation = 0;

            this.stats = new Dictionary<CreepStats, int>();
            this.stats.Add(CreepStats.Width, creepData.Width);
            this.stats.Add(CreepStats.Height, creepData.Height);
            this.stats.Add(CreepStats.Health, creepData.Health);
            this.stats.Add(CreepStats.DamageToPlayer, creepData.DamageToPlayer);
            this.stats.Add(CreepStats.Speed, creepData.Speed);
            this.ScoreValue = creepData.Health;
        }
示例#2
0
        /// <summary>
        /// Load the paths, waypoints and wave data from xml.
        /// </summary>
        private void LoadData()
        {
            // Get the XML file with our data.
            XmlReader reader = XmlReader.Create("MapDefinitions.xml");

            // Initialize path data.
            int lastPath = -1;
            int lastWaypoint = 0;

            // Initialize wave data.
            int[][][] waves = null;
            int lastWave = -1;
            int lastCreep = -1;

            // Initialize creep stat data.

            int lastCreepDefinition = 0;

            // Initialize projectile stat data.
            int lastProjectileDefinition = 0;

            while (reader.Read())
            {
                XmlNodeType nodeType = reader.NodeType;

                if (nodeType == XmlNodeType.Element)
                {
                    if (reader.Name.Equals("map"))
                    {
                        TileDimensions = new Vector2(Int32.Parse(reader.GetAttribute("tileWidth")), Int32.Parse(reader.GetAttribute("tileHeight")));
                        TileCenter = new Vector2((int)(TileDimensions.X / 2), (int)(TileDimensions.Y / 2));
                    }
                    else if (reader.Name.Equals("creepDefinition"))
                    {
                        CreepTypeData creepData = new CreepTypeData
                        {
                            Width = Int32.Parse(reader.GetAttribute("width")),
                            Height = Int32.Parse(reader.GetAttribute("height")),
                            Health = Int32.Parse(reader.GetAttribute("health")),
                            Speed = Int32.Parse(reader.GetAttribute("speed")),
                            DamageToPlayer = Int32.Parse(reader.GetAttribute("damageToPlayer"))
                        };

                        CreepDefinitions.CreepStats.Add((CreepType)(lastCreepDefinition++), creepData);
                    }
                    else if (reader.Name.Equals("projectileDefinition"))
                    {
                        ProjectileTypeData projectileData = new ProjectileTypeData
                        {
                            AnimationDelay = Int32.Parse(reader.GetAttribute("delay")),
                            NumFrames = Int32.Parse(reader.GetAttribute("numFrames")),
                            Width = Int32.Parse(reader.GetAttribute("width")),
                            Height = Int32.Parse(reader.GetAttribute("height"))
                        };

                        ProjectileDefinitions.ProjectileStats.Add((ProjectileTypes)lastProjectileDefinition++, projectileData);
                    }
                    else if (reader.Name.Equals("paths"))
                    {
                        paths = new Vector2[Int32.Parse(reader.GetAttribute("numPaths"))][];
                    }
                    else if (reader.Name.Equals("path"))
                    {
                        paths[++lastPath] = new Vector2[Int32.Parse(reader.GetAttribute("numWaypoints"))];
                        lastWaypoint = 0;
                    }
                    else if (reader.Name.Equals("waypoint"))
                    {
                        paths[lastPath][lastWaypoint++] = new Vector2(Int32.Parse(reader.GetAttribute("column")) * Board.TileDimensions.X + Board.TileCenter.X, Int32.Parse(reader.GetAttribute("row")) * Board.TileDimensions.Y + Board.TileCenter.Y);
                    }
                    else if (reader.Name.Equals("waves"))
                    {
                        waves = new int[Int32.Parse(reader.GetAttribute("numWaves"))][][];
                        lastWave = -1;
                    }
                    else if (reader.Name.Equals("wave"))
                    {
                        waves[++lastWave] = new int[Int32.Parse(reader.GetAttribute("numCreeps"))][];
                        lastCreep = -1;
                    }
                    else if (reader.Name.Equals("creep"))
                    {
                        waves[lastWave][++lastCreep] = new int[] { Int32.Parse(reader.GetAttribute("type")), Int32.Parse(reader.GetAttribute("delay")) };
                    }
                }
            }

            if (null != waves)
            {
                waveManager.SetWaves(waves);
            }
        }
示例#3
0
        /// <summary>
        /// The update loop.
        /// </summary>
        public override void Update()
        {
            if (null != waveManager)
            {
                //if (waveManager.Update(creeps.Count == 0))
                //{
                //    creeps.Add(new Creep(CreepDefinitions.ProjectileStats[(CreepType)waveManager.waves[waveManager.currentWave][waveManager.nextSpawnIndex - 1][0]], new Vector2(paths[0][0].X, paths[0][0].Y), (MEDIA_ID)waveManager.waves[waveManager.currentWave][waveManager.nextSpawnIndex - 1][0], 0, 0));
                //    if (waveManager.GameWon)
                //    {
                //        GameEngine.RunningEngine.Load(Screens.WIN);
                //        return;
                //    }
                //}
                if (waveManager.InfiniteUpdate(creeps.Count == 0))
                {
                    double boost = Math.Pow(1.2, waveManager.BonusWave);

                    CreepTypeData creepNormal = new CreepTypeData(){DamageToPlayer = 1, Health = (int)boost * 5, Height = 16, Width = 16, Speed = 3};
                    CreepTypeData creepFast = new CreepTypeData(){DamageToPlayer = 1, Health =(int)boost * 4, Height = 32, Width = 32, Speed = 5};
                    CreepTypeData creepVariant = new  CreepTypeData(){DamageToPlayer = 1, Health = (int)boost * 5, Height = 32, Width = 32, Speed = 4};
                    CreepTypeData creepBoss = new CreepTypeData(){DamageToPlayer = 2, Health = (int)boost * 40, Height = 32, Width = 32, Speed = 3};

                    // What is this?
                    int thing = waveManager.BonusWave % 4;
                    Creep newCreep;

                    switch (thing)
                    {
                        case 0:
                            newCreep = new Creep(creepNormal, new Vector2(paths[0][0].X, paths[0][0].Y), MEDIA_ID.CREEP_0);
                            break;
                        case 1:
                             newCreep = new Creep(creepFast, new Vector2(paths[0][0].X, paths[0][0].Y), MEDIA_ID.CREEP_1);
                            break;
                        case 2:
                            newCreep = new Creep(creepVariant, new Vector2(paths[0][0].X, paths[0][0].Y), MEDIA_ID.CREEP_2);
                            break;
                        default:
                            newCreep = new Creep(creepBoss, new Vector2(paths[0][0].X, paths[0][0].Y), MEDIA_ID.CREEP_3);
                            break;
                    }

                    creeps.Add(newCreep);
                }
            }

            HandleCreepLoop();
            HandleTowerLoop();
            HandleProjectileLoop();
            HandleInput();
        }
示例#4
0
 /// <summary>
 /// Creep instance constructor.
 /// </summary>
 /// <param name="stats">A dictionary of stats for this instance.</param>
 /// <param name="position">The spawning position.</param>
 /// <param name="textureID">The MEDIA_ID for this creep's texture.</param>
 /// <param name="path">The index of the path to follow.</param>
 /// <param name="startingWaypoint">The waypoint to spawn at.</param>
 public Creep(CreepTypeData creepData, Vector2 position, MEDIA_ID textureID, int path, int startingWaypoint)
     : this(creepData, position, textureID)
 {
     this._path = path;
     this._nextWaypoint = startingWaypoint;
 }