public static Enemy createEnemyWithParams(Dictionary<string, string> fields)
        {
            int enemyX = int.Parse(fields["x"]);
            int enemyY = int.Parse(fields["y"]);

            Enemy e = new Enemy((int) ((enemyX+.5) * Level.tileWidth), (int) ((enemyY+ .5) * Level.tileHeight));

            foreach (KeyValuePair<string, string> entry in fields)
            {
                if (entry.Key == "patrolspeed")
                {
                    e.patrolspeed = int.Parse(entry.Value);
                    e.velocity.X = (float)-e.patrolspeed;
                }
                else if (entry.Key == "patrolRange")
                {
                    e.patrolRange = int.Parse(entry.Value);
                }
                else if (entry.Key == "maxSpeed")
                {
                    e.maxSpeed = float.Parse(entry.Value);
                }
                else if (entry.Key == "investigateMaxWait")
                {
                    e.investigateMaxWait = int.Parse(entry.Value);
                }
                else if (entry.Key == "vertViewRange")
                {
                    e.vertViewRange = int.Parse(entry.Value);
                }
                else if (entry.Key == "horizViewRange")
                {
                    e.horizViewRange = int.Parse(entry.Value);
                }
                else if (entry.Key == "soundRange")
                {
                    e.soundRange = int.Parse(entry.Value);
                }
                else if (entry.Key == "weaponType")
                {
                    e.weaponType = int.Parse(entry.Value);
                }
                else if (entry.Key == "lazerChargeTime")
                {
                    e.lazerChargeTime = float.Parse(entry.Value);
                }
                else if (entry.Key == "lazerDuration")
                {
                    e.lazerDuration = float.Parse(entry.Value);
                }
                else if (entry.Key == "fireInterval")
                {
                    e.fireInterval = float.Parse(entry.Value);
                }
            }
            return e;
        }
Example #2
0
        public Level()
        {
            gameOver = false;
            levelCompleted = false;
            eastermode = false;
            //hooray for things being in the right place!
            this.player = new Player();
            crosshair = new Crosshair();
            enemies = new LinkedList<Enemy>();
            contentHolder = new Enemy(-1, -1);
            bullets = new Bullet[50];
            usedCoins = new LinkedList<Vector2>();
            usedButtons = new Dictionary<Vector2, int>();
            pipeEngine = new PipeEngine(128, 128, 3000, 0f);

            for (int i = 0; i < bullets.Length; i++)
            {
                bullets[i] = new Bullet(Vector2.Zero);
            }
        }