Beispiel #1
0
 public Enemy(ref global_vars variables, Texture2D enemysprite, ref Character player_char, ref Campaign currentCampaign,  Game1 game)
     : base(game)
 {
     this.enemy = enemysprite;
     this.player = player_char;
     this.variables = variables;
     this.game = game;
     this.currentCampaign = currentCampaign;
     thisEnemy = this;
 }
Beispiel #2
0
 public Player(ref global_vars vars, int experience, String[] special, String selectedSpecial, int game_credit, ref Game1 g)
 {
     this.experience = experience;
     this.avaliableSpecials = special;
     this.game_credit = game_credit;
     variables = vars;
     game = g;
     this.selectedSpecial = selectedSpecial;
     character = new Character(selectedSpecial, ref variables, ref g);
 }
Beispiel #3
0
        Shield thisShield; //Copy of this implementation of Shield interace, so that it may be passed as ref

        #endregion Fields

        #region Constructors

        public Basic_Shield(int timeAvaliable, Rectangle positionPlaced, ref Character castee, ref global_vars variables, ref Game1 game)
            : base(game)
        {
            this.position = positionPlaced;
            this.castee = castee;
            shieldBatch = new SpriteBatch(game.GraphicsDevice);
            thisShield = this;

            active = new Timer(timeAvaliable);
            active.Elapsed += new ElapsedEventHandler(timeElapsed);
            activate = true;
        }
Beispiel #4
0
        public Character(String special_ability, ref global_vars vars, ref Game1 game)
            : base(game)
        {
            this.game = game;
            thisCharacter = this;
            this.variables = vars;

            this.special_ability = special_ability;
            this.position = new Rectangle(variables.CHARACTER_START_POSITION.X, variables.CHARACTER_START_POSITION.Y, variables.CHARACTER_WIDTH, variables.CHARACTER_HEIGHT);

            base.UpdateOrder = variables.CHARACTER_UPDATE_PRIORITY;
            base.DrawOrder = variables.CHARACTER_UPDATE_PRIORITY;

            this.move_state = variables.CHARACTER_DEFAULT_MOVESTATE;
            this.charsprite = new SpriteBatch(variables.manager.GraphicsDevice);

            attackDelayTimer = new Timer(variables.ATTACK_DELAY);
            attackDelayTimer.Elapsed += new ElapsedEventHandler(attackIsReady);
        }
Beispiel #5
0
        public Campaign(ref global_vars vars, Player player, Texture2D map, Game1 game)
            : base(game)
        {
            this.variables = vars;
            this.player = player;
            this.map = map;
            this.game = game;
            thisCampaign = this;
            play = this;

            s1 = new Vector2(40, variables.screen_height - 40);
            l1 = new Rectangle(variables.screen_width - 190, variables.screen_height - 70, 50, 50);
            l2 = new Rectangle(variables.screen_width - 130, variables.screen_height - 70, 50, 50);
            l3 = new Rectangle(variables.screen_width - 70, variables.screen_height - 70, 50, 50);

            mapPosition = new Rectangle(0, 0, variables.screen_width, variables.screen_height);
            this.character = this.player.getCharacter(thisCampaign);
            creepers = 0;
            shadows = 0;
        }
Beispiel #6
0
 public void setAbility(int num)
 {
     try
     {
         selectedSpecial = avaliableSpecials[num];
     }
     catch (Exception e) { throw e; }
     //Create a new character with new selected ability
     character = new Character(selectedSpecial, ref variables, ref game);
 }
Beispiel #7
0
 public Character getNewCharacter(Playable playable)
 {
     Character c = new Character(selectedSpecial, ref variables, ref game);
     c.setPlayable(playable);
     character = c;
     return c;
 }
Beispiel #8
0
 public Creeper(ref global_vars variables, Texture2D enemysprite, ref Character player_char, ref Campaign currentCampaign, Game1 game)
     : base(ref variables, enemysprite, ref player_char, ref currentCampaign, game)
 {
 }
Beispiel #9
0
 protected void playerDeath()
 {
     this.character = this.player.getNewCharacter(thisCampaign);
         //Block the pause screen
         pauseScreen.pauseBlock();
         //Clear the screen with a firewave
         game.Components.Add(new FireWave(5000, new Rectangle(-100, 0, 50, variables.screen_height), 'r', global_vars.sender.Special, ref variables, ref game));
         //Give back all specials and sheilds
         specialAvaliable = true;
         shieldsAvaliable = 3;
         //Don't allow enemies to spawn during respawn period
         creeperConstant = 0;
         //No shadows
         shadowEaterStart.Stop();
         spawnShadows = false;
         //Respawn delay
         Timer t = new Timer(3000, game);
         t.Elapsed = setRespawn;
         t.AutoReset = false;
         t.Start();
 }
Beispiel #10
0
 public ShadowEater(ref global_vars variables, Texture2D enemysprite, ref Character player_char, ref Campaign currentCampaign, Game1 game)
     : base(ref variables, enemysprite, ref player_char, ref currentCampaign, game)
 {
     attackSound = game.Content.Load<SoundEffect>("Sounds\\shadowAttackSound");
 }
Beispiel #11
0
        public static void handleCommand(ref Character character, ref Playable playable, ref global_vars variables, ref Game1 game)
        {
            keypressed = Keyboard.GetState();

            //Player movement

            if (keypressed.IsKeyDown(variables.CHARACTER_UP) && (character.getPosition().Y > 0))
            {
                character.setPosition(character.getPosition().X, character.getPosition().Y - variables.CHARACTER_DEFAULT_MOVE_SPEED);
                character.move_state = global_vars.movestate.up;
            }
            else if (keypressed.IsKeyDown(variables.CHARACTER_DOWN) && (character.getPosition().Y < (variables.screen_height - variables.CHARACTER_HEIGHT)))
            {
                character.setPosition(character.getPosition().X, character.getPosition().Y + variables.CHARACTER_DEFAULT_MOVE_SPEED);
                character.move_state = global_vars.movestate.down;
            }
            else if (keypressed.IsKeyDown(variables.CHARACTER_RIGHT) && (character.getPosition().X < variables.screen_width - variables.CHARACTER_WIDTH))
            {
                character.setPosition(character.getPosition().X + variables.CHARACTER_DEFAULT_MOVE_SPEED, character.getPosition().Y);
                character.move_state = global_vars.movestate.right;
            }
            else if (keypressed.IsKeyDown(variables.CHARACTER_LEFT) && (character.getPosition().X > 0))
            {
                character.setPosition(character.getPosition().X - variables.CHARACTER_DEFAULT_MOVE_SPEED, character.getPosition().Y);
                character.move_state = global_vars.movestate.left;
            }

            else character.move_state = global_vars.movestate.notmoving;

            //User commands (spells, shields, etc)
            //Attacks start at player's center
            int posx = character.getPosition().X + (variables.CHARACTER_WIDTH / 4);
            int posy = character.getPosition().Y + (variables.CHARACTER_HEIGHT / 4);
            int shieldx = character.getPosition().X - (variables.SHIELD_WIDTH / 2);
            int shieldy = character.getPosition().Y - (variables.SHIELD_HEIGHT / 2);

            //Sheild (One at a time)
            if (keypressed.IsKeyDown(variables.SHIELD) && (character.shieldOut == false))
            {
                try
                {
                    bool answer = playable.notify(global_vars.notification.ShieldRequest);
                    if (answer)
                    {
                        character.shieldOut = true;
                        game.Components.Add(new Basic_Shield(10000, new Rectangle(shieldx, shieldy, variables.SHIELD_WIDTH, variables.SHIELD_HEIGHT), ref character, ref variables, ref game));
                    }
                }
                catch (Exception e) { throw e; }
            }

            //Basic Attack
            if (keypressed.IsKeyDown(variables.ATTACK_BASIC_UP) && (character.attackReady == true))
            {
                character.attackReady = false;
                game.Components.Add(new Basic_Attack(3000, new Rectangle(posx, posy, variables.ATTACK_SPELL_SIZE, variables.ATTACK_SPELL_SIZE), 'u', global_vars.sender.Character, ref variables, ref game));
            }
            else if (keypressed.IsKeyDown(variables.ATTACK_BASIC_RIGHT) && (character.attackReady == true))
            {
                character.attackReady = false;
                game.Components.Add(new Basic_Attack(3000, new Rectangle(posx, posy, variables.ATTACK_SPELL_SIZE, variables.ATTACK_SPELL_SIZE), 'r', global_vars.sender.Character, ref variables, ref game));
            }
            else if (keypressed.IsKeyDown(variables.ATTACK_BASIC_LEFT) && (character.attackReady == true))
            {
                character.attackReady = false;
                game.Components.Add(new Basic_Attack(3000, new Rectangle(posx, posy, variables.ATTACK_SPELL_SIZE, variables.ATTACK_SPELL_SIZE), 'l', global_vars.sender.Character, ref variables, ref game));
            }
            else if (keypressed.IsKeyDown(variables.ATTACK_BASIC_DOWN) && (character.attackReady == true))
            {
                character.attackReady = false;
                game.Components.Add(new Basic_Attack(3000, new Rectangle(posx, posy, variables.ATTACK_SPELL_SIZE, variables.ATTACK_SPELL_SIZE), 'd', global_vars.sender.Character, ref variables, ref game));
            }

            //Special Ability
            if (keypressed.IsKeyDown(variables.SPECIAL_ABILITY))
            {
                try
                {
                    bool answer = playable.notify(global_vars.notification.SpecialRequest);
                    if (answer)
                    {
                        Ability_Manager.performSpecialAbility(character.getSpecial(), ref variables, ref game);
                    }
                }
                catch (Exception e) { }
            }

            //Exit Full Screen
               // if (keypressed.IsKeyDown(Keys.Escape))
              //      variables.manager.ToggleFullScreen();
        }