Ejemplo n.º 1
0
        public BlackFog(IServiceProvider services, GraphicsDevice graphics, int hp = 0)
        {
            graphicsDevice = graphics;

            if (content == null)
            {
                content = new ContentManager(services)
                {
                    RootDirectory = "Content"
                }
            }
            ;

            fsm = new FSM(this);

            rand = new Random();

            BF_RampageState     rampage     = new BF_RampageState();
            BF_SwordAttackState swordAttack = new BF_SwordAttackState();
            BF_SlamAttackState  slamAttack  = new BF_SlamAttackState();

            // Adding transitions for states to all other states
            // if it satisfies the enum condition
            rampage.AddTransition(new Transition(swordAttack, () => currentMove == MoveSet.SwordAttack));
            rampage.AddTransition(new Transition(slamAttack, () => currentMove == MoveSet.SlamAttack));

            swordAttack.AddTransition(new Transition(rampage, () => currentMove == MoveSet.Rampage));
            swordAttack.AddTransition(new Transition(slamAttack, () => currentMove == MoveSet.SlamAttack));

            slamAttack.AddTransition(new Transition(rampage, () => currentMove == MoveSet.Rampage));
            slamAttack.AddTransition(new Transition(swordAttack, () => currentMove == MoveSet.SwordAttack));

            // Add all the states to the state machine
            fsm.AddState(rampage);
            fsm.AddState(swordAttack);
            fsm.AddState(slamAttack);

            fsm.Initialise("Rampage");

            idleAnimation = new Animation(content.Load <Texture2D>("Graphics/Boss/BlackFogIdle"), 0.1f, true, 18);
            runAnimation  = new Animation(content.Load <Texture2D>("Graphics/Boss/BlackFogRunning"), 0.06f, true, 12);
            fallAnimation = new Animation(content.Load <Texture2D>("Graphics/Boss/BlackFogFalling"), 0.3f, false, 6);
            dieAnimation  = new Animation(content.Load <Texture2D>("Graphics/Boss/BlackFogDying"), 0.08f, false, 15);

            shockwaveSound = content.Load <SoundEffect>("Audio/shockwave_pound");

            movementSpeed = 500.0f;

            startingPosition = new Vector2(graphics.Viewport.Width / 2, 0.0f);
            position         = startingPosition;
            dest             = Vector2.Zero;

            direction = 1;

            maxHealth = 500;

            // If it's initialised with 0 from the script
            // then set it to the max health
            if (hp == 0)
            {
                health = maxHealth;
            }
            else
            {
                health = hp;
            }

            // Time to wait to switch
            // to the next state
            FSMWaitDelay = 3.0f;
            FSMWaitTime  = FSMWaitDelay;

            // Modified Rectangle dimensions
            // of the frame for collisions
            int width  = (int)(idleAnimation.FrameWidth * 0.4);
            int left   = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.1);
            int top    = idleAnimation.FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);

            sprite = new Animator(OriginLocation.Center);
            sprite.PlayAnimation(idleAnimation);

            sword      = new BlackFogSword();
            left_wave  = new BlackFogShockwave();
            right_wave = new BlackFogShockwave();

            sword.Initialise(content, position);
            left_wave.Initialise(content);
            right_wave.Initialise(content);

            haltMovement       = false;
            castShockWave      = false;
            initialPositionSet = false;

            currentMoveNum = 0;
        }
Ejemplo n.º 2
0
        public SwampCry(IServiceProvider services, GraphicsDevice graphics, int hp = 0)
        {
            graphicsDevice = graphics;

            if (content == null)
            {
                content = new ContentManager(services)
                {
                    RootDirectory = "Content"
                }
            }
            ;

            fsm = new FSM(this);

            rand = new Random();

            SC_RampageState    idle        = new SC_RampageState();
            SC_ClubAttackState clubAttack  = new SC_ClubAttackState();
            SC_ThrowAttack     throwAttack = new SC_ThrowAttack();

            idle.AddTransition(new Transition(clubAttack, () => currentMove == MoveSet.ClubAttack));
            idle.AddTransition(new Transition(throwAttack, () => currentMove == MoveSet.ThrowAttack));

            clubAttack.AddTransition(new Transition(idle, () => currentMove == MoveSet.Rampage));
            clubAttack.AddTransition(new Transition(throwAttack, () => currentMove == MoveSet.ThrowAttack));

            throwAttack.AddTransition(new Transition(idle, () => currentMove == MoveSet.Rampage));
            throwAttack.AddTransition(new Transition(clubAttack, () => currentMove == MoveSet.ClubAttack));

            fsm.AddState(idle);
            fsm.AddState(clubAttack);
            fsm.AddState(throwAttack);

            fsm.Initialise("Rampage");

            idleAnimation  = new Animation(content.Load <Texture2D>("Graphics/Boss/SwampCryIdle"), 0.1f, true, 18);
            runAnimation   = new Animation(content.Load <Texture2D>("Graphics/Boss/SwampCryRunning"), 0.06f, true, 12);
            throwAnimation = new Animation(content.Load <Texture2D>("Graphics/Boss/SwampCryThrowing"), 0.07f, true, 12);
            fallAnimation  = new Animation(content.Load <Texture2D>("Graphics/Boss/SwampCryFalling"), 0.3f, false, 6);
            dieAnimation   = new Animation(content.Load <Texture2D>("Graphics/Boss/SwampCryDying"), 0.08f, false, 15);

            movementSpeed = 750.0f;

            startingPosition = new Vector2(graphics.Viewport.Width / 2, 0.0f);
            position         = startingPosition;
            dest             = Vector2.Zero;

            direction = 1;

            maxHealth = 500;

            if (hp == 0)
            {
                health = maxHealth;
            }
            else
            {
                health = hp;
            }

            FSMWaitDelay = 3.0f;
            FSMWaitTime  = FSMWaitDelay;

            int width  = (int)(idleAnimation.FrameWidth * 0.4);
            int left   = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.1);
            int top    = idleAnimation.FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);

            sprite = new Animator(OriginLocation.Center);
            sprite.PlayAnimation(fallAnimation);

            club  = new SwampCryClub();
            spell = new SwampCrySpell();

            club.Initialise(content, position);
            spell.Initialise(content);

            currentMoveNum = 0;
        }