示例#1
0
        public override void Update()
        {
            //Update position
            if (facingRight)
            {
                rect.X += (int)Math.Round(PhysManager.Unicorns * 5d / 60d);
            }
            else
            {
                rect.X -= (int)Math.Round(PhysManager.Unicorns * 5d / 60d);
            }

            //Check for player collision
            foreach (Entity e in Game1.Entities)
            {
                if (e is Player)
                {
                    Player p = ((Player)e);
                    if (p.FighterState != FighterState.Jump && Hitbox.Intersects(p.Hitbox))
                    {
                        p.Hp -= 10;
                        PhysManager.Knockback(p);
                        Game1.RemoveEntity(this);
                    }
                }
            }

            //Remove if 20 or more unicorns from start so they don't stack up and lag
            if (Math.Abs(Box.X - startX) > PhysManager.Unicorns * 7)
            {
                Game1.RemoveEntity(this);
            }
        }
示例#2
0
 public Boss(int x, int y, int width, int height, AnimationSet animSet, int hp, int dmg, Texture2D shadow, PhysManager phys, Texture2D bulletTexture)
     : base(x, y, width, height, hp, dmg, animSet, FighterState.Idle, shadow)
 {
     state              = BossState.Idle;
     this.phys          = phys;
     this.bulletTexture = bulletTexture;
     rando              = new Random();
     alive              = true;
 }
示例#3
0
        // enemy specific fields

        public Enemy(int x, int y, int width, int height, int hp, int dmg, AnimationSet animSet, PhysManager phys, Texture2D shadow, FighterState fighterState = FighterState.Idle, bool facingRight = true)
            : base(x, y, width, height, hp, dmg, animSet, fighterState, shadow)
        {
            this.facingRight = facingRight;
            active           = true;
            kbState          = Keyboard.GetState();
            this.phys        = phys;
            Speed            = 3;
            closest          = false;
        }
示例#4
0
        //player specific fields


        public Player(int x, int y, int width, int height, int hp, int dmg, AnimationSet animSet, PhysManager phys, Texture2D shadow, SoundEffect hit, SoundEffect jump, Weapon weapon = null, FighterState fighterState = FighterState.Idle, bool facingRight = true)
            : base(new Rectangle(x, y, width, height), hp, dmg, animSet, fighterState, shadow)
        {
            wep = weapon;
            //100 is just a placeholder value, subject to change
            alive            = true;
            this.facingRight = facingRight;
            this.phys        = phys;
            Stunned          = false;
            Speed            = 7;

            //Initialize keyboard and mouse, and gamepad states
            kbState = Keyboard.GetState();
            mState  = Mouse.GetState();
            gpState = GamePad.GetState(PlayerIndex.One);

            // Initialize sound effects
            this.hit  = hit;
            this.jump = jump;
        }
示例#5
0
 // Class constructor
 public Student(int x, int y, int width, int height, AnimationSet animSet, int hp, int dmg, PhysManager phys, Texture2D shadow)
     : base(x, y, width, height, hp, dmg, animSet, phys, shadow)
 {
     Speed = 3;
 }
示例#6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            drawables.Add(player);
            phys = new PhysManager(player, enemyList, obstacles, GraphicsDevice.Viewport.Height, boss);

            // TODO: use this.Content to load your game content here
            startTexture       = Content.Load <Texture2D>("start");
            optionsTexture     = Content.Load <Texture2D>("options");           //loads button textures
            exitTexture        = Content.Load <Texture2D>("exit");
            controls           = Content.Load <Texture2D>("textures/Controls");
            obstacleTexture    = Content.Load <Texture2D>("obstacle");
            shadowTexture      = Content.Load <Texture2D>("textures/sprites/Shadow");
            bulletTexture      = Content.Load <Texture2D>("Bullet");
            titleScreenTexture = Content.Load <Texture2D>("textures/TitleScreen");
            menu = new Menu(startTexture, optionsTexture, exitTexture, startButton, optionsButton, exitButton);
            font = Content.Load <SpriteFont>("placeholderText");

            // Load sound effects
            hit  = Content.Load <SoundEffect>("woosh");
            jump = Content.Load <SoundEffect>("jump");

            //Test player
            AnimationSet playerAnimSet = new AnimationSet(
                Animation.LoadAnimation(Animation.CANNOLI_IDLE, Content),
                Animation.LoadAnimation(Animation.CANNOLI_WALKING, Content),
                Animation.LoadAnimation(Animation.CANNOLI_FALLING, Content),
                Animation.LoadAnimation(Animation.CANNOLI_JUMPING, Content),
                Animation.LoadAnimation(Animation.CANNOLI_ATTACK_SANDWICH, Content),
                Animation.LoadAnimation(Animation.CANNOLI_HIT, Content)
                );

            phys   = new PhysManager(player, enemyList, obstacles, GraphicsDevice.Viewport.Height, boss);
            player = new Player(0, 0, PhysManager.Unicorns * 2, PhysManager.Unicorns * 4, 100, 0, playerAnimSet, phys, shadowTexture, hit, jump,
                                new Weapon(
                                    new Rectangle(PhysManager.Unicorns * 2, PhysManager.Unicorns * 4 - PhysManager.Unicorns / 4 * 3, PhysManager.Unicorns, PhysManager.Unicorns),
                                    Animation.LoadAnimation(Animation.CANNOLI_ATTACK_SANDWICH, Content), 10, 0.5));
            phys.Player = player;

            //Background
            background = new Background(Content.Load <Texture2D>("textures/backgrounds/Classroom"));

            //Health bar
            healthBackground = new Texture2D(graphics.GraphicsDevice, PhysManager.Unicorns * 4, PhysManager.Unicorns / 2);
            Color[] data = new Color[healthBackground.Width * healthBackground.Height];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = Color.DarkGray;
            }
            healthBackground.SetData(data);

            healthBar = new Texture2D(graphics.GraphicsDevice, healthBackground.Width, healthBackground.Height);
            data      = new Color[healthBar.Width * healthBar.Height];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = Color.IndianRed;
            }
            healthBar.SetData(data);

            healthBarBoss = new Texture2D(graphics.GraphicsDevice, healthBackground.Width, healthBackground.Height);
            data          = new Color[healthBar.Width * healthBar.Height];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = Color.CornflowerBlue;
            }
            healthBarBoss.SetData(data);

            //Start level
            LevelStart();
        }