示例#1
0
        public AbstractKinectButton(Texture2D buttonImage, Vector2 position, SelectAnimation selectAnimation)
        {
            this.buttonImage = buttonImage;
            this.position = position;
            this.selectAnimation = selectAnimation;

            hotArea = new Rectangle((int)position.X, (int)position.Y, buttonImage.Width, buttonImage.Height);
        }
示例#2
0
 public KinectButton(Texture2D buttonImage, Vector2 position, SelectAnimation selectAnimation)
     : base(buttonImage, position, selectAnimation)
 {
 }
示例#3
0
        protected override void LoadContent()
        {
            IsMouseVisible = true;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            kinectRGBVideo = new Texture2D(GraphicsDevice, 1337, 1337);
            body = Content.Load<Texture2D>("Space_Invader");

            SelectAnimation selectAnimation = new SelectAnimation(1500, new Vector2(100, 100), Content.Load<Texture2D>("AnimationStrip"));
            SelectAnimation selectAnimation2 = new SelectAnimation(1500, new Vector2(100, 100), Content.Load<Texture2D>("AnimationStrip"));
            startbutton = new KinectButton(Content.Load<Texture2D>("Start_Button"), new Vector2(90, 250), selectAnimation);
            exitbutton = new KinectButton(Content.Load<Texture2D>("Exit_Button_StartScreen"), new Vector2(380, 250), selectAnimation2);
            startbutton.RegisterClientJoint(JointType.HandLeft);//sets joint to track!
            exitbutton.RegisterClientJoint(JointType.HandLeft);//sets joint to track!
            startbutton.KinectButtonClicked += new AbstractKinectButton.KinectButtonClickedHandler(startbutton_KinectButtonClicked);
            exitbutton.KinectButtonClicked += new AbstractKinectButton.KinectButtonClickedHandler(exitbutton_KinectButtonClicked);

            SelectAnimation selectAnimation3 = new SelectAnimation(1500, new Vector2(100, 100), Content.Load<Texture2D>("AnimationStrip"));
            SelectAnimation selectAnimation4 = new SelectAnimation(1500, new Vector2(100, 100), Content.Load<Texture2D>("AnimationStrip"));
            SelectAnimation selectAnimation5 = new SelectAnimation(1500, new Vector2(100, 100), Content.Load<Texture2D>("AnimationStrip"));
            pauseresumebutton = new KinectButton(Content.Load<Texture2D>("Resume_Button"), new Vector2(90, 150), selectAnimation3);
            pauseexitbutton = new KinectButton(Content.Load<Texture2D>("Exit_Button_PauseScreen"), new Vector2(380, 150), selectAnimation4);
            pauserestartbutton = new KinectButton(Content.Load<Texture2D>("Restart_Button"), new Vector2(230, 300), selectAnimation5);
            pauseresumebutton.RegisterClientJoint(JointType.HandLeft);//sets joint to track!
            pauseexitbutton.RegisterClientJoint(JointType.HandLeft);//sets joint to track!
            pauserestartbutton.RegisterClientJoint(JointType.HandLeft);//sets joint to track!
            pauseresumebutton.KinectButtonClicked += new AbstractKinectButton.KinectButtonClickedHandler(pauseresumebutton_KinectButtonClicked);
            pauseexitbutton.KinectButtonClicked += new AbstractKinectButton.KinectButtonClickedHandler(pauseexitbutton_KinectButtonClicked);
            pauserestartbutton.KinectButtonClicked += new AbstractKinectButton.KinectButtonClickedHandler(pauserestartbutton_KinectButtonClicked);
          
           rightHandImage = Content.Load<Texture2D>("Kinect_Hand");
           font = Content.Load<SpriteFont>("SpriteFont1");

            LKPunch = Content.Load<SoundEffect>("LKPunch");
            LKPunchInstance = LKPunch.CreateInstance();
            LKKick = Content.Load<SoundEffect>("LKKick");
            LKKickInstance = LKKick.CreateInstance();
            SPunch = Content.Load<SoundEffect>("SPunch");
            SPunchInstance = SPunch.CreateInstance();
            SKick = Content.Load<SoundEffect>("SKick");
            SKickInstance = SKick.CreateInstance();

            SWins = Content.Load<Song>("SWins");
            LKWins = Content.Load<Song>("LKWins");
            Fight = Content.Load<Song>("Fight");

            MenuMusic = Content.Load<SoundEffect>("Menu_Music");
            MenuInstance = MenuMusic.CreateInstance();
            MenuInstance.Volume = 0.3f;
            MenuInstance.IsLooped = true;

            FightMusic = Content.Load<SoundEffect>("Fight_Music");
            FightInstance = FightMusic.CreateInstance();
            FightInstance.Volume = 0.1f;
            FightInstance.IsLooped = true;

            MediaPlayer.Volume = 10f;

            backgroundTexture = Content.Load<Texture2D>("Background");
            startscreenTexture = Content.Load<Texture2D>("title");
            pausescreenTexture = Content.Load<Texture2D>("Pause_Screen");

            mIsGameScreenShown = false;
            mIsPauseScreenShown = false;
            mIsControllerDetectScreenShown = true;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>();//loads in player 1 (Scorpion)
            Dictionary<AnimationKey, Animation> animations2 = new Dictionary<AnimationKey, Animation>();//loads in player 2 (Liu Kang)

            Animation animation = new Animation(0, 0, 0, 0, 0);//no idea what this is, program doesn't work without it!
            Animation animation2 = new Animation(0, 0, 0, 0, 0);//does the same for animation2!.

            mBatch = new SpriteBatch(this.graphics.GraphicsDevice);//initialises the spritebatch.
            ContentManager aLoader = new ContentManager(this.Services);//creates a content manager to help load the image.
            mHealthBar = Content.Load<Texture2D>("HealthBar") as Texture2D;//loads in the healthbar texture.

            zbatch = new SpriteBatch(this.GraphicsDevice);
            ContentManager zLoader = new ContentManager(this.Services);
            LKnameplate = Content.Load<Texture2D>("LKNameplate") as Texture2D;
            Snameplate = Content.Load<Texture2D>("SNameplate") as Texture2D;

            animation = new Animation(12, 100, 135, 0, 0);//sets Scorpion idle
            animations.Add(AnimationKey.Idle, animation);//defines Scorpion idle animation.
            animation2 = new Animation(8, 100, 135, 0, 0);//sets Liu Kang idle.
            animations2.Add(AnimationKey.Idle, animation2);//defines Liu Kang idle animation.

            animation = new Animation(9, 100, 165, 0, 285);//sets Scorpion left.
            animations.Add(AnimationKey.Left, animation);//defines Scorpion left animation.
            animation2 = new Animation(9, 100, 165, 0, 135);//sets Liu Kang left.
            animations2.Add(AnimationKey.Left, animation2);//defines Liu Kang left animation.

            animation = new Animation(9, 100, 150, 0, 135);//sets Scorpion right.
            animations.Add(AnimationKey.Right, animation);//defines Scorpion right animation
            animation2 = new Animation(9, 100, 165, 0, 285);//sets Liu Kang right.
            animations2.Add(AnimationKey.Right, animation2);//defines Liu Kang right animation

            animation = new Animation(5, 150, 140, 0, 450);//sets Scorpion Punch
            animations.Add(AnimationKey.Punch, animation);//defines Scorpion punch animation.
            animation2 = new Animation(5, 150, 140, 0, 450);//sets Liu Kang Punch
            animations2.Add(AnimationKey.Punch, animation2);//defines Liu Kang punch animation.

            animation = new Animation(9, 150, 140, 0, 600);//sets Scorpion Kick
            animations.Add(AnimationKey.Kick, animation);//defines Scorpion Kick animation.
            animation2 = new Animation(9, 150, 140, 0, 600);//sets Liu Kang Kick
            animations2.Add(AnimationKey.Kick, animation2);//defines Liu Kang Kick animation.

            animation = new Animation(5, 100, 150, 0, 750);//sets Scorpion Block
            animations.Add(AnimationKey.Block, animation);//defines Scorpion Block animation.
            animation2 = new Animation(5, 100, 150, 0, 750);//sets Liu Kang Block
            animations2.Add(AnimationKey.Block, animation2);//defines Liu Kang Block animation.

            animation = new Animation(5, 100, 150, 0, 890);//sets Scorpion Duck
            animations.Add(AnimationKey.Duck, animation);//defines Scorpion Duck animation.
            animation2 = new Animation(5, 100, 150, 0, 890);//sets Liu Kang Duck
            animations2.Add(AnimationKey.Duck, animation2);//defines Liu Kang Duck animation.

            sprite = new AnimatedSprite(Content.Load<Texture2D>("Scorpion"), animations, animation.FrameWidth, animation.FrameHeight);//loads Scorpion sprite texture.
            sprite2 = new AnimatedSprite(Content.Load<Texture2D>("LiuKang"), animations2, animation2.FrameWidth, animation.FrameHeight);//loads Liu Kang sprite texture.

            sprite.position = new Vector2(100, groundheight);//sets sprite (Scorpion) start position.
            sprite2.position = new Vector2(560, groundheight);//sets sprite2 (Liu Kang) start position.

        }