Exemplo n.º 1
0
        public Room(ref StreamReader m, int xCoord, int yCoord)
        {
            x = xCoord;
            y = yCoord;

            roomOrigin = new Vector2((float)xCoord * 100f, (float)yCoord * ((9f / 16f) * 100f));
            backGround = new XNACS1Rectangle(new Vector2(roomOrigin.X + 50f, roomOrigin.Y + 50 * (9f / 16f)), 100f, 100f * (9f / 16f), "bg1");
            walls      = new WallSet(roomOrigin);

            hasStairs  = Convert.ToInt32(m.ReadLine());
            numDoors   = Convert.ToInt32(m.ReadLine());
            myDoors    = new Doors[numDoors];
            numEnemies = Convert.ToInt32(m.ReadLine());

            if (hasStairs == 1)
            {
                float stairX = (float)Convert.ToDouble(m.ReadLine());
                float stairY = (float)Convert.ToDouble(m.ReadLine());
                stairs = new Stair(new Vector2(stairX + roomOrigin.X, stairY + roomOrigin.Y));
            }

            activeEnemies = numEnemies;
            myEnemies     = new Enemy[numEnemies];
            roomObjects   = new XNACS1PrimitiveSet();

            coord = new Vector2((float)x, (float)y);

            for (int i = 0; i < numEnemies; i++)
            {
                float  posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float  posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Enemy(new Vector2(posX, posY), "guard");
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = 0; i < numDoors; i++)
            {
                //takes in the origin of the room and the door type
                myDoors[i] = new Doors(roomOrigin, coord, m.ReadLine());
                roomObjects.AddToSet(myDoors[i]);
            }

            roomObjects.RemoveAllFromAutoDrawSet();

            wand = new Wand();
        }
        public Room(ref StreamReader m, int xCoord, int yCoord)
        {
            x = xCoord;
            y = yCoord;

            roomOrigin = new Vector2((float)xCoord * 100f, (float)yCoord * ((9f / 16f) * 100f));
            walls      = new WallSet(roomOrigin);


            numDoors = Convert.ToInt32(m.ReadLine());
            myDoors  = new Doors[numDoors];

            numEnemies    = Convert.ToInt32(m.ReadLine());
            activeEnemies = numEnemies;
            myEnemies     = new Enemy[numEnemies];
            //line = m.ReadLine();
            //isVisited = Convert.ToBoolean(line);

            //line = m.ReadLine();
            //hasStairs = Convert.ToBoolean(line);
            roomObjects = new XNACS1PrimitiveSet();

            coord = new Vector2((float)x, (float)y);

            for (int i = 0; i < numEnemies; i++)
            {
                float posX = Convert.ToInt64(m.ReadLine()) + roomOrigin.X;
                float posY = Convert.ToInt64(m.ReadLine()) + roomOrigin.Y;
                myEnemies[i] = new Enemy(new Vector2(posX, posY), "guard");
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = 0; i < numDoors; i++)
            {
                //takes in the origin of the room and the door type
                myDoors[i] = new Doors(roomOrigin, coord, m.ReadLine());
                roomObjects.AddToSet(myDoors[i]);
            }

            roomObjects.RemoveAllFromAutoDrawSet();

            wand = new Wand();
        }
        int y; //location of the room in y

        #endregion Fields

        #region Constructors

        public Room(ref StreamReader m, int xCoord, int yCoord)
        {
            x = xCoord;
            y = yCoord;

            roomOrigin = new Vector2((float)xCoord * 100f, (float)yCoord * ((9f / 16f) * 100f));
            walls = new WallSet(roomOrigin);

            numDoors = Convert.ToInt32(m.ReadLine());
            myDoors = new Doors[numDoors];

            numEnemies = Convert.ToInt32(m.ReadLine());
            activeEnemies = numEnemies;
            myEnemies = new Enemy[numEnemies];
            //line = m.ReadLine();
            //isVisited = Convert.ToBoolean(line);

            //line = m.ReadLine();
            //hasStairs = Convert.ToBoolean(line);
            roomObjects = new XNACS1PrimitiveSet();

            coord = new Vector2((float)x, (float)y);

            for (int i = 0; i < numEnemies; i++) {
                float posX = Convert.ToInt64(m.ReadLine()) + roomOrigin.X;
                float posY = Convert.ToInt64(m.ReadLine()) + roomOrigin.Y;
                myEnemies[i] = new Enemy(new Vector2(posX, posY), "guard");
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = 0; i < numDoors; i++) {
                //takes in the origin of the room and the door type
                myDoors[i] = new Doors(roomOrigin, coord, m.ReadLine());
                roomObjects.AddToSet(myDoors[i]);
            }

            roomObjects.RemoveAllFromAutoDrawSet();

            wand = new Wand();
        }
Exemplo n.º 4
0
        public Room(ref StreamReader m, int xCoord, int yCoord)
        {
            x = xCoord;
            y = yCoord;

            triggerPressed = false;
            roomOrigin     = new Vector2((float)xCoord * 100f, (float)yCoord * ((9f / 16f) * 100f));
            backGround     = new XNACS1Rectangle(new Vector2(roomOrigin.X + 50f, roomOrigin.Y + 50 * (9f / 16f)), 100f, 100f * (9f / 16f), "dungeonFloor");
            walls          = new WallSet(roomOrigin);

            hasStairs   = Convert.ToInt32(m.ReadLine());
            numDoors    = Convert.ToInt32(m.ReadLine());
            myDoors     = new Doors[numDoors];
            numEnemies  = Convert.ToInt32(m.ReadLine());
            numKnights  = Convert.ToInt32(m.ReadLine());
            roomObjects = new XNACS1PrimitiveSet();
            isAlive     = false;
            heroCaught  = false;

            if (hasStairs == 1)
            {
                float stairX = (float)Convert.ToDouble(m.ReadLine());
                float stairY = (float)Convert.ToDouble(m.ReadLine());
                stairs = new Stair(new Vector2(stairX + roomOrigin.X, stairY + roomOrigin.Y));
                roomObjects.AddToSet(stairs);

                float badGuyX = (float)Convert.ToDouble(m.ReadLine());
                float badGuyY = (float)Convert.ToDouble(m.ReadLine());
                badGuy = new Wizard(new Vector2(badGuyX + roomOrigin.X, badGuyY + roomOrigin.Y));

                roomObjects.AddToSet(badGuy);
                hasWon = false;
            }

            activeEnemies = numEnemies;
            myEnemies     = new Enemy[numEnemies];
            numGuards     = numEnemies - numKnights;
            coord         = new Vector2((float)x, (float)y);


            for (int i = 0; i < numGuards; i++)
            {
                float  posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float  posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Guard(new Vector2(posX, posY));
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = numGuards; i < numEnemies; i++)
            {
                float  posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float  posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Knight(new Vector2(posX, posY));
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = 0; i < numDoors; i++)
            {
                //takes in the origin of the room and the door type
                myDoors[i] = new Doors(roomOrigin, coord, m.ReadLine());
                roomObjects.AddToSet(myDoors[i]);
            }

            roomObjects.RemoveAllFromAutoDrawSet();

            wand = new Wand();
        }
Exemplo n.º 5
0
        public bool Update(Hero hero, Wand w)
        {
            heroHit = false;
            health.Update(new Vector2(this.Center.X, this.Center.Y + 1), healthRemaining, initialLives);

            if (current == wizardStatus.isAlive)
            {
                if (shieldCoolDown < 0 && !shielded)
                {
                    shielded       = true;
                    shieldCoolDown = 100;
                }
                else
                {
                    shieldCoolDown--;
                }

                if (shieldCoolDown < 0 && shielded)
                {
                    shielded       = false;
                    shieldCoolDown = 100;
                }


                if (shielded)
                {
                    Texture = "wizardShield";
                }
                else
                {
                    Texture = "wizardRight";
                    if (coolDown < 0)
                    {
                        coolDown = 40;
                        shoot(hero.Center);
                    }
                    else
                    {
                        coolDown--;
                    }
                }

                for (int i = 0; i < list.Count; i++)
                {
                    shot temp = list[i];
                    if (list[i].shotLife == 0)
                    {
                        list[i].bullet.RemoveFromAutoDrawSet();
                        list[i].emitter.RemoveFromAutoDrawSet();
                        list.Remove(list[i]);
                    }
                    else
                    {
                        temp.shotLife--;
                        if (hero.Collided(temp.bullet) && !temp.hit)
                        {
                            hero.Caught();
                            hero.Center = hero.HeroInitialPos;
                            temp.hit    = true;
                            heroHit     = true;
                        }
                        list[i] = temp;
                        list[i].emitter.Center = list[i].bullet.Center;
                    }
                }
                for (int i = 0; i < w.list.Count; i++)
                {
                    if (w.list[i].bullet.Collided(this))
                    {
                        if (!shielded)
                        {
                            healthRemaining--;
                        }
                        else
                        {
                            Random r = new Random();
                            if (r.Next(0, 100) < 10)
                            {
                                healthRemaining--;
                            }
                        }
                    }
                }

                if (healthRemaining <= 0)
                {
                    current = wizardStatus.isDead;
                    Texture = "Newteddybear";
                    XNACS1Base.PlayACue("Bear-Sound");

                    return(true);
                }

                if (this.Center.X - hero.Center.X > 0)
                {
                    Texture = shielded ? "wizardShieldLeft" : "wizardLeft";
                }
                else
                {
                    Texture = shielded ? "wizardShield" : "wizardRight";
                }
            }

            if (current == wizardStatus.isDead)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].bullet.RemoveFromAutoDrawSet();
                    list[i].emitter.RemoveFromAutoDrawSet();
                    list.Remove(list[i]);
                }
            }
            return(false);
        }
Exemplo n.º 6
0
        public Room(ref StreamReader m, int xCoord, int yCoord)
        {
            x = xCoord;
            y = yCoord;

            triggerPressed = false;
            roomOrigin = new Vector2((float)xCoord * 100f, (float)yCoord * ((9f / 16f) * 100f));
            backGround = new XNACS1Rectangle(new Vector2(roomOrigin.X + 50f, roomOrigin.Y + 50 * (9f / 16f)), 100f, 100f * (9f / 16f), "dungeonFloor");
            walls = new WallSet(roomOrigin);

            hasStairs = Convert.ToInt32(m.ReadLine());
            numDoors = Convert.ToInt32(m.ReadLine());
            myDoors = new Doors[numDoors];
            numEnemies = Convert.ToInt32(m.ReadLine());
            numKnights = Convert.ToInt32(m.ReadLine());
            roomObjects = new XNACS1PrimitiveSet();
            isAlive = false;
            heroCaught = false;

            if (hasStairs == 1) {
                float stairX = (float)Convert.ToDouble(m.ReadLine());
                float stairY = (float)Convert.ToDouble(m.ReadLine());
                stairs = new Stair(new Vector2(stairX + roomOrigin.X, stairY + roomOrigin.Y));
                roomObjects.AddToSet(stairs);

                float badGuyX = (float)Convert.ToDouble(m.ReadLine());
                float badGuyY = (float)Convert.ToDouble(m.ReadLine());
                badGuy = new Wizard(new Vector2(badGuyX + roomOrigin.X, badGuyY + roomOrigin.Y));

                roomObjects.AddToSet(badGuy);
                hasWon = false;
            }

            activeEnemies = numEnemies;
            myEnemies = new Enemy[numEnemies];
            numGuards = numEnemies - numKnights;
            coord = new Vector2((float)x, (float)y);

            for (int i = 0; i < numGuards; i++) {
                float posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Guard(new Vector2(posX, posY));
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = numGuards; i < numEnemies; i++) {
                float posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Knight(new Vector2(posX, posY));
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = 0; i < numDoors; i++) {
                //takes in the origin of the room and the door type
                myDoors[i] = new Doors(roomOrigin, coord, m.ReadLine());
                roomObjects.AddToSet(myDoors[i]);
            }

            roomObjects.RemoveAllFromAutoDrawSet();

            wand = new Wand();
        }
Exemplo n.º 7
0
        public bool Update(Hero hero, Wand w)
        {
            heroHit = false;
            health.Update(new Vector2(this.Center.X, this.Center.Y+1), healthRemaining, initialLives);

            if (current == wizardStatus.isAlive) {
                if (shieldCoolDown < 0 && !shielded) {
                    shielded = true;
                    shieldCoolDown = 100;
                }
                else
                    shieldCoolDown--;

                if (shieldCoolDown < 0 && shielded) {
                    shielded = false;
                    shieldCoolDown = 100;
                }

                if (shielded) {
                    Texture = "wizardShield";

                }
                else {
                    Texture = "wizardRight";
                    if (coolDown < 0) {
                        coolDown = 40;
                        shoot(hero.Center);
                    }
                    else
                        coolDown--;
                }

                for (int i = 0; i < list.Count; i++) {
                    shot temp = list[i];
                    if (list[i].shotLife == 0) {
                        list[i].bullet.RemoveFromAutoDrawSet();
                        list[i].emitter.RemoveFromAutoDrawSet();
                        list.Remove(list[i]);
                    }
                    else {
                        temp.shotLife--;
                        if (hero.Collided(temp.bullet) && !temp.hit) {
                            hero.Caught();
                            hero.Center = hero.HeroInitialPos;
                            temp.hit = true;
                            heroHit = true;
                        }
                        list[i] = temp;
                        list[i].emitter.Center = list[i].bullet.Center;
                    }
                }
                for (int i = 0; i < w.list.Count; i++)
                    if (w.list[i].bullet.Collided(this)) {
                        if (!shielded)
                            healthRemaining--;
                        else {
                            Random r = new Random();
                            if (r.Next(0, 100) < 10)
                                healthRemaining--;
                        }
                    }

                if (healthRemaining <= 0) {
                    current = wizardStatus.isDead;
                    Texture = "Newteddybear";
                    XNACS1Base.PlayACue("Bear-Sound");

                    return true;
                }

                if (this.Center.X - hero.Center.X > 0)
                    Texture = shielded ? "wizardShieldLeft" : "wizardLeft";
                else
                    Texture = shielded ? "wizardShield" : "wizardRight";
            }

            if (current == wizardStatus.isDead) {
                for (int i = 0; i < list.Count; i++) {
                    list[i].bullet.RemoveFromAutoDrawSet();
                    list[i].emitter.RemoveFromAutoDrawSet();
                    list.Remove(list[i]);
                }
            }
            return false;
        }
        int y; //location of the room in y

        #endregion Fields

        #region Constructors

        public Room(ref StreamReader m, int xCoord, int yCoord)
        {
            x = xCoord;
            y = yCoord;

            roomOrigin = new Vector2((float)xCoord * 100f, (float)yCoord * ((9f / 16f) * 100f));
            backGround = new XNACS1Rectangle(new Vector2(roomOrigin.X + 50f, roomOrigin.Y + 50 * (9f / 16f)), 100f, 100f * (9f / 16f), "bg1");
            walls = new WallSet(roomOrigin);

            hasStairs = Convert.ToInt32(m.ReadLine());
            numDoors = Convert.ToInt32(m.ReadLine());
            myDoors = new Doors[numDoors];
            numEnemies = Convert.ToInt32(m.ReadLine());

            if (hasStairs == 1) {
                float stairX = (float)Convert.ToDouble(m.ReadLine());
                float stairY = (float)Convert.ToDouble(m.ReadLine());
                stairs = new Stair(new Vector2(stairX + roomOrigin.X, stairY + roomOrigin.Y));
            }

            activeEnemies = numEnemies;
            myEnemies = new Enemy[numEnemies];
            roomObjects = new XNACS1PrimitiveSet();

            coord = new Vector2((float)x, (float)y);

            for (int i = 0; i < numEnemies; i++) {
                float posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Enemy(new Vector2(posX, posY), "guard");
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = 0; i < numDoors; i++) {
                //takes in the origin of the room and the door type
                myDoors[i] = new Doors(roomOrigin, coord, m.ReadLine());
                roomObjects.AddToSet(myDoors[i]);
            }

            roomObjects.RemoveAllFromAutoDrawSet();

            wand = new Wand();
        }