Esempio n. 1
0
 public AI(Game game, SpriteBatch screenSpriteBatch)
     : base(game, screenSpriteBatch, PlayerSide.Right)
 {
     Catapult = new Catapult(game, screenSpriteBatch,
                             "Textures/Catapults/Red/redIdle/redIdle",
                             new Vector2(600, 332), SpriteEffects.FlipHorizontally, true);
 }
Esempio n. 2
0
		public Human (Game game, SpriteBatch screenSpriteBatch)
            : base(game, screenSpriteBatch)
		{
			Catapult = new Catapult (game, screenSpriteBatch,
                                    "Textures/Catapults/Blue/blueIdle/blueIdle",
                                    catapultPosition, SpriteEffects.None, false);
		}
Esempio n. 3
0
 public Human(Game game, SpriteBatch screenSpriteBatch)
     : base(game, screenSpriteBatch)
 {
     Catapult = new Catapult(game, screenSpriteBatch,
                             "Textures/Catapults/Blue/blueIdle/blueIdle",
                             catapultPosition, SpriteEffects.None, false);
 }
Esempio n. 4
0
        public override void Initialize()
        {
            arrow = curGame.Content.Load <Texture2D>("Textures/HUD/arrow");
            Catapult.Initialize();

            base.Initialize();
        }
Esempio n. 5
0
 public AI(Game game, SpriteBatch screenSpriteBatch)
     : base(game, screenSpriteBatch, PlayerSide.Right)
 {
     Catapult = new Catapult(game, screenSpriteBatch,
                     "Textures/Catapults/Red/redIdle/redIdle",
                     new Vector2(600, 332), SpriteEffects.FlipHorizontally, true);
 }
Esempio n. 6
0
        public override void Initialize()
        {
            //Initialize randomizer
            random = new Random();

            Catapult.Initialize();
            base.Initialize();
        }
Esempio n. 7
0
 public AI(Game game, SpriteBatch screenSpriteBatch)
     : base(game, screenSpriteBatch)
 {
     // Initialize catapult
     Catapult = new Catapult(game, screenSpriteBatch,
         "Textures/Catapults/Red/redIdle/redIdle",
         new Vector2(600, 332), SpriteEffects.FlipHorizontally,
         true);
 }
Esempio n. 8
0
 public AI(Game game, SpriteBatch screenSpriteBatch)
     : base(game, screenSpriteBatch)
 {
     // Initialize catapult
     Catapult = new Catapult(game, screenSpriteBatch,
                             "Textures/Catapults/Red/redIdle/redIdle",
                             new Vector2(600, 332), SpriteEffects.FlipHorizontally,
                             true);
 }
Esempio n. 9
0
        public override void Initialize()
        {
            arrow    = curGame.Content.Load <Texture2D>("Textures/HUD/arrow");
            guideDot = curGame.Content.Load <Texture2D>("Textures/HUD/guideDot");

            Catapult.Initialize();

            guideProjectile = new Projectile(Game, spriteBatch,
                                             "Textures/Ammo/rock_ammo", Catapult.ProjectileStartPosition,
                                             Catapult.GroundHitOffset, false, Catapult.Gravity);

            base.Initialize();
        }
Esempio n. 10
0
        public void HandleInput(GestureSample gestureSample)
        {
            // Process input only if in Human's turn
            if (IsActive)
            {
                // Process any Drag gesture
                if (gestureSample.GestureType == GestureType.FreeDrag)
                {
                    // If drag just began, save the sample for future
                    // calculations and start Aim "animation"
                    if (null == firstSample)
                    {
                        firstSample           = gestureSample;
                        Catapult.CurrentState = CatapultState.Aiming;
                    }

                    // save the current gesture sample
                    prevSample = gestureSample;

                    // calculate the delta between first sample and current
                    // sample to present visual sound on screen
                    Vector2 delta = prevSample.Value.Position -
                                    firstSample.Value.Position;
                    Catapult.ShotStrength = delta.Length() / maxDragDelta;
                    float baseScale = 0.001f;
                    arrowScale = baseScale * delta.Length();
                    isDragging = true;
                }
                else if (gestureSample.GestureType == GestureType.DragComplete)
                {
                    // calculate velocity based on delta between first and last
                    // gesture samples
                    if (null != firstSample)
                    {
                        Vector2 delta = prevSample.Value.Position -
                                        firstSample.Value.Position;
                        Catapult.ShotVelocity = MinShotStrength +
                                                Catapult.ShotStrength *
                                                (MaxShotStrength - MinShotStrength);
                        Catapult.Fire(Catapult.ShotVelocity);
                        Catapult.CurrentState = CatapultState.Firing;
                    }

                    // turn off dragging state
                    ResetDragState();
                }
            }
        }
Esempio n. 11
0
		public Human (Game game, SpriteBatch screenSpriteBatch, PlayerSide playerSide) : base(game, screenSpriteBatch)
		{
			string idleTextureName = "";
			this.playerSide = playerSide;

			if (playerSide == PlayerSide.Left) {
				catapultPosition = new Vector2 (140, 332);
				idleTextureName = "Textures/Catapults/Blue/blueIdle/blueIdle";
			} else {
				catapultPosition = new Vector2 (600, 332);
				spriteEffect = SpriteEffects.FlipHorizontally;
				idleTextureName = "Textures/Catapults/Red/redIdle/redIdle";
			}

			Catapult = new Catapult (game, screenSpriteBatch,
						idleTextureName, catapultPosition, spriteEffect,
						playerSide == PlayerSide.Left ? false : true);
		}
Esempio n. 12
0
        public void HandleInput(InputState input)
        {
            // Process input only if in Human's turn
            if (IsActive && !IsAI)
            {
                if (input.MouseGesture.HasFlag(MouseGestureType.FreeDrag))
                {
                    // If drag just began save the sample for future
                    // calculations and start Aim "animation"
                    if (null == firstMouseSample)
                    {
                        firstMouseSample      = input.MouseDragStartPosition;
                        Catapult.CurrentState = CatapultState.Aiming;
                    }

                    // save the current gesture sample
                    prevMouseSample = input.CurrentMousePosition;

                    // calculate the delta between first sample and current
                    // sample to present visual sound on screen
                    Vector2 delta = (Vector2)prevMouseSample - (Vector2)firstMouseSample;
                    Catapult.ShotStrength = delta.Length() / maxDragDelta;
                    float baseScale = 0.001f;
                    arrowScale = baseScale * delta.Length();
                    isDragging = true;
                }
                else if (input.MouseGesture.HasFlag(MouseGestureType.DragComplete))
                {
                    // calc velocity based on delta between first and last
                    // gesture samples
                    if (null != firstMouseSample)
                    {
                        Vector2 delta = (Vector2)prevMouseSample - (Vector2)firstMouseSample;
                        Catapult.ShotVelocity = MinShotStrength + Catapult.ShotStrength *
                                                (MaxShotStrength - MinShotStrength);
                        Catapult.Fire(Catapult.ShotVelocity);
                        Catapult.CurrentState = CatapultState.Firing;
                    }

                    ResetDragState();
                }
            }
        }
Esempio n. 13
0
        public Human(Game game, SpriteBatch screenSpriteBatch, PlayerSide playerSide) : base(game, screenSpriteBatch)
        {
            string idleTextureName = "";

            this.playerSide = playerSide;

            if (playerSide == PlayerSide.Left)
            {
                catapultPosition = new Vector2(140, 332);
                idleTextureName  = "Textures/Catapults/Blue/blueIdle/blueIdle";
            }
            else
            {
                catapultPosition = new Vector2(600, 332);
                spriteEffect     = SpriteEffects.FlipHorizontally;
                idleTextureName  = "Textures/Catapults/Red/redIdle/redIdle";
            }

            Catapult = new Catapult(game, screenSpriteBatch,
                                    idleTextureName, catapultPosition, spriteEffect,
                                    playerSide == PlayerSide.Left ? false : true);
        }
Esempio n. 14
0
 public override void Draw(GameTime gameTime)
 {
     // Draw related catapults
     Catapult.Draw(gameTime);
     base.Draw(gameTime);
 }
Esempio n. 15
0
 public override void Update(GameTime gameTime)
 {
     // Update catapult related to the player
     Catapult.Update(gameTime);
     base.Update(gameTime);
 }