This is the main type for your game
Inheritance: Microsoft.Xna.Framework.Game
        public Inventory(int SCREEN_WIDTH, int SCREEN_HEIGHT, Pantheon gameReference)
        {
            locationBoxes = new List<Rectangle>();
            equippedBoxes = new List<Rectangle>();
            types = new List<int>();
            infoBox = new Rectangle();
            movingBox = new Rectangle();
            trashBox = new Rectangle();

            tempStorage = new Item();

            this.SCREEN_WIDTH = SCREEN_WIDTH;
            this.SCREEN_HEIGHT = SCREEN_HEIGHT;

            SetBoxes();

            selected = -1;
            hoveredOver = -1;

            color = new Color(34, 167, 222, 50);
            trashColor = Color.White;

            inventorySelector = gameReference.Content.Load<Texture2D>("Inventory/InvSelect");
            trashCan = gameReference.Content.Load<Texture2D>("Inventory/TrashCan");
            nullImage = new Texture2D(gameReference.GraphicsDevice, 1,1);
            nullImage.SetData(new[] { new Color(0,0,0,0) });
        }
        /// <summary>
        /// The constructor for the player entity class.
        /// </summary>
        public PlayerCharacter(Pantheon gameReference)
            : base(Vector2.Zero,
                new Rectangle(0,0,86,142),
                new Rectangle(28,100,30,30))
        {
            initializeInventory();

            TotalArmor = 100;
            CurrentArmor = 100;
            //TotalShield = 300;
            //CurrentShield = 300;
            cursorLocation = Vector2.Zero;
            totalOffset = Vector2.Zero;
            offset = Vector2.Zero;
            laserTexture = new Texture2D(gameReference.GraphicsDevice, 1, 1);

            EquippedItems.Add("scar", new Scar(gameReference.Content));
            inventory.equipped.RemoveAt(0);
            inventory.equipped.Insert(0, EquippedItems["scar"]);
            EquippedItems.Add("sniper", new Sniper(gameReference.Content));
            inventory.equipped.RemoveAt(1);
            inventory.equipped.Insert(1, EquippedItems["sniper"]);
            EquippedItems.Add("shield", new Shield(gameReference.Content));
            inventory.equipped.RemoveAt(6);
            inventory.equipped.Insert(6, EquippedItems["shield"]);

            ArmedItem = EquippedItems["scar"];
            drawLasar = true;

            characteristics.Add("Player");
            drawLasar = true;
        }
Beispiel #3
0
 /// <summary>
 /// The constructor for a Trigger entity. Note that the bounding box and drawing box are the same since the Trigger will not be drawn. The location 
 /// is also specified by the location box. The action point is defaultly located in the center of the trigger.
 /// </summary>
 /// <param name="locationBox">There is no location box...</param>
 public Trigger(Rectangle locationBox, Pantheon gameReference)
     : base(new Vector2(locationBox.X + locationBox.Width/2, locationBox.Y + locationBox.Height/2),
         locationBox,
         new Rectangle(0, 0, locationBox.Width, locationBox.Height))
 {
     characteristics.Add("Triggerable");
 }
Beispiel #4
0
        /// <summary>
        /// The constructor assumes that you are generating the bullet from a given location at a given velocity.
        /// </summary>
        /// <param name="location">The initial position for the bullet.</param>
        /// <param name="velocity">The initial velocity of the bullet.</param>
        public Bullet(Vector2 location, int speed, float angle, int range, int damage, Pantheon gameReference)
            : base(location,
                new Rectangle(0,0,20,20),
                new Rectangle(1,1,18,18))
        {
            // If scoping, then use perfect accuracy.
            // otherwies use a random deviation.
            if (gameReference.ControlManager.actions.Aim)
            {
                this.Velocity = new Vector2(speed * (float)Math.Cos(angle), speed * (float)Math.Sin(angle));
                sprite.Rotation = angle;
            }
            else
            {
                double randomDeviation = new Random().NextDouble();
                float randomAngle = (float)(angle + (randomDeviation * .1) - .05);
                // Max deviaion of .01 radians
                // -.05 to center the deviation around the laser

                this.Velocity = new Vector2(speed * (float)Math.Cos(randomAngle), speed * (float)Math.Sin(randomAngle));
                sprite.Rotation = randomAngle;
            }
            timeToLive = range;
            this.damage = damage;
        }
 /// <summary>
 /// Causes the quest to be completed.
 /// </summary>
 /// <param name="gameReference"></param>
 public override void Initialize(Pantheon gameReference)
 {
     Dictionary<string,string> payload = new Dictionary<string,string>();
     payload.Add("QuestId", questId + "");
     Event closeQuestEvent = new Event("CloseQuest", payload);
     gameReference.EventManager.notify(closeQuestEvent);
 }
Beispiel #6
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Pantheon game = new Pantheon())
     {
         game.Run();
     }
 }
Beispiel #7
0
        public override void Update(GameTime gameTime, Pantheon gameReference)
        {
            base.Update(gameTime, gameReference);
            if (currentArmor <= 0)
            {
                String command = "Die ";
                command += HamburgerHelper.GetDirection(Facing);

                Console.WriteLine(command);
                CurrentState = command;

                if (sprite.isComplete())
                {
                    toDestroy = true;
                }
            }

            if (!isRoaming)
            {
                if (!gameReference.player.CurrentState.Contains("Die"))
                {
                    this.EquippedItems["weapon"].activate(gameReference, this);
                }
            }

            if (((Weapon)this.EquippedItems["weapon"]).CurrentAmmo == 0 && !((Weapon)this.EquippedItems["weapon"]).Reloading)
            {
                ((Weapon)this.EquippedItems["weapon"]).Reload(gameTime);
            }

            if (currentState.Contains("Die"))
            {
                gameReference.audioManager.playSoundEffect("Blood");
            }
        }
        /// <summary>
        /// Initializes the quest creator object with possible quests and
        /// registers the quest creator for quest creation notifications.
        /// </summary>
        /// <param name="metaLoader">The metaLoader object.</param>
        public QuestCreator(QuestMetaLoader metaLoader, Pantheon gameReference)
        {
            this.metaLoader = metaLoader;

            // Register the activate quest function for handling requests to activate a quest
            handler = ActivateQuest;
            gameReference.EventManager.register("ActivateQuest", handler);
        }
 public void PlayLevelLoad(Pantheon gameReference)
 {
     cutcsenePlaying = true;
     gameReference.controlManager.disableControls(false);
     hideRect.Width = gameReference.GraphicsDevice.Viewport.Width;
     hideRect.Height = gameReference.GraphicsDevice.Viewport.Height;
     hideOffset = -20;
 }
 public override void Update(GameTime gameTime, Pantheon gameReference)
 {
     base.Update(gameTime, gameReference);
     if (currentArmor <= 0)
     {
         currentState = "Die";
         toDestroy = true;
     }
 }
        /// <summary>
        /// Update the FEESH
        /// </summary>
        /// <param name="gameTime">The game time object for letting you know how old you've gotten since starting the game.</param>
        /// <param name="gameReference">Another global game reference.</param>
        public override void Update(GameTime gameTime, Pantheon gameReference)
        {
            base.Update(gameTime, gameReference);

            PlayerCharacter theCharacter = (PlayerCharacter)gameReference.player;

            // Fish goes on head.
            this.actionPoint.X = (int)(theCharacter.DrawingBox.Left + theCharacter.DrawingBox.Width/2);
            this.actionPoint.Y = (int)(theCharacter.DrawingBox.Top - this.DrawingBox.Height / 2);
        }
        public QuestManager(Pantheon gameReference)
        {
            quests = new List<Quest>();

            // Register the event handler with the event manager
            HandleEvent createQuestHandler = AddQuest;
            gameReference.EventManager.register("CreateQuest", createQuestHandler);

            HandleEvent closeQuestHandler = CompleteQuest;
            gameReference.EventManager.register("CloseQuest", closeQuestHandler);
        }
        /// <summary>
        /// UPDATE THE BUTTERFLY CLASS FOR THE WIN
        /// </summary>
        /// <param name="gameTime">The game time object for letting you know how old you've gotten since starting the game.</param>
        /// <param name="gameReference">Game reference of doom</param>
        public override void Update(GameTime gameTime, Pantheon gameReference)
        {
            base.Update(gameTime, gameReference);

            if (!isRoaming)
            {
                this.EquippedItems["weapon"].activate(gameReference, this);
                if (((Weapon)this.EquippedItems["weapon"]).CurrentAmmo == 0 && !((Weapon)this.EquippedItems["weapon"]).Reloading)
                {
                    ((Weapon)this.EquippedItems["weapon"]).Reload(gameTime);
                }
            }
        }
        public override void Update(GameTime gameTime, Pantheon gameReference)
        {
            base.Update(gameTime, gameReference);

            if (!isRoaming)
            {
                switch (facing)
                {
                    case Direction.forward:
                        sprite.changeState(currentState + " Forward");
                        break;
                    case Direction.forwardLeft:
                        sprite.changeState(currentState + " Forward Left");
                        break;
                    case Direction.Left:
                        sprite.changeState(currentState + " Left");
                        break;
                    case Direction.backLeft:
                        sprite.changeState(currentState + " Back Left");
                        break;
                    case Direction.back:
                        sprite.changeState(currentState + " Back");
                        break;
                    case Direction.backRight:
                        sprite.changeState(currentState + " Back Right");
                        break;
                    case Direction.Right:
                        sprite.changeState(currentState + " Right");
                        break;
                    case Direction.forwardRight:
                        sprite.changeState(currentState + " Forward Right");
                        break;
                    default:
                        sprite.changeState(currentState + " Forward");
                        break;
                }
            }

            changeDirection = changeDirection.Subtract(gameTime.ElapsedGameTime);
            if (changeDirection.CompareTo(TimeSpan.Zero) <= 0)
            {
                if (isRoaming)
                {
                    switchDirection(gameReference);
                }
                changeDirection = TimeSpan.FromSeconds(gameReference.rand.Next(3) + 1);
            }

            ComfortZone = new Rectangle(BoundingBox.X - ComfortZone.Width / 2, BoundingBox.Y - ComfortZone.Height / 2,
                ComfortZone.Width, ComfortZone.Height);
        }
        // METHOD AND FUNCTION DEFINITION --
        /// <summary>
        /// Constructs the basics of the DialogueManager class and prepares it to handle
        /// dialogue and conversation.
        /// </summary>
        public DialogueManager(Pantheon gameReference, SpriteFont textFont)
        {
            ContentManager content = gameReference.Content;

            this.textFont = textFont;
            this.activeTextBubbles = new LinkedList<TextBubble>();
            this.conversations = new Dictionary<string, ArrayList>();
            this.npcStates = new Dictionary<string, string>();
            this.npcStateBubbles = new Dictionary<string, TextBubble>();

            this.currentConversationState = 0;

            // Set up event handling...
            this.interactionEventHandler = this.interact;
            this.interactionAlertEventHandler = this.interactAlert;
            this.spontaneousConversationEventHandler = this.spontaneousConversation;

            gameReference.EventManager.register("Interaction", this.interactionEventHandler);
            gameReference.EventManager.register("InteractionAlert", this.interactionAlertEventHandler);
            gameReference.EventManager.register("SpontaneousConversation", this.spontaneousConversationEventHandler);

            // Load the text bubble image.
            this.textbubbleImage = content.Load<Texture2D>("textbubble");
        }
 /// <summary>
 /// Randomly switch directions.
 /// </summary>
 private void switchDirection(Pantheon gameReference)
 {
     int dir = gameReference.rand.Next(8);
     switch (dir)
     {
         case 0:
             facing = Direction.forward;
             angleFacing = (float)Math.PI / 2;
             velocity = new Vector2(0, 3);
             sprite.changeState(currentState + " Forward");
             break;
         case 1:
             facing = Direction.forwardLeft;
             angleFacing = 3 * (float)Math.PI / 4;
             velocity = new Vector2(-3, 3);
             sprite.changeState(currentState + " Forward Left");
             break;
         case 2:
             facing = Direction.Left;
             angleFacing = (float)Math.PI;
             velocity = new Vector2(-3, 0);
             sprite.changeState(currentState + " Left");
             break;
         case 3:
             facing = Direction.backLeft;
             angleFacing = 5 * (float)Math.PI / 4;
             velocity = new Vector2(-3, -3);
             sprite.changeState(currentState + " Back Left");
             break;
         case 4:
             facing = Direction.back;
             angleFacing = 3 * (float)Math.PI / 2;
             velocity = new Vector2(0, -3);
             sprite.changeState(currentState + " Back");
             break;
         case 5:
             facing = Direction.backRight;
             angleFacing = 7 * (float)Math.PI / 4;
             velocity = new Vector2(3, -3);
             sprite.changeState(currentState + " Back Right");
             break;
         case 6:
             facing = Direction.Right;
             angleFacing = 0;
             velocity = new Vector2(3, 0);
             sprite.changeState(currentState + " Right");
             break;
         case 7:
             facing = Direction.forwardRight;
             angleFacing = (float)Math.PI / 4;
             velocity = new Vector2(3, 3);
             sprite.changeState(currentState + " Forward Right");
             break;
         default:
             facing = Direction.forward;
             angleFacing = (float)Math.PI / 2;
             velocity = new Vector2(0, 3);
             sprite.changeState(currentState + " Forward");
             break;
     }
 }
        /// <summary>
        /// Keeps DialogueManager up-to-date. Makes sure no conversations are still on going.
        /// Manages the checking of exit conditions for text bubbles.
        /// </summary>
        public void Update(GameTime gameTime, Pantheon gameReference)
        {
            LinkedListNode<TextBubble> currentNode;

            // Update the states...
            foreach (string key in this.npcStates.Keys)
            {
                if (!gameReference.currentLevel.Entities.Keys.Contains(key)) continue; // BAD, FIX

                Entity theEntity = gameReference.currentLevel.Entities[key];

                switch (this.npcStates[key])
                {
                    case DialogueManager.STATE_NONE:
                        if (this.npcStateBubbles[key] != null)
                        {
                            this.npcStateBubbles[key].isReadyForDeletion = true;
                            this.npcStateBubbles[key] = null;
                        }

                        break;

                    case DialogueManager.STATE_TALKING: // DON'T INTERRUPT, IT'S RUDE
                        if (this.npcStateBubbles[key] != null)
                        {
                            this.npcStateBubbles[key].isReadyForDeletion = true;
                            this.npcStateBubbles[key] = null;
                        }

                        break;

                    case DialogueManager.STATE_ALERT:
                        if (this.npcStateBubbles[key] == null)
                        {
                            this.npcStateBubbles[key] = new TextBubble(theEntity, "!");
                        }
                        else if (this.npcStateBubbles[key].Text != "!")
                        {
                            this.npcStateBubbles[key].isReadyForDeletion = true;
                            this.npcStateBubbles[key] = new TextBubble(theEntity, "!");
                        }

                        break;

                    case DialogueManager.STATE_TALKABLE:
                        if (this.npcStateBubbles[key] == null)
                        {
                            this.npcStateBubbles[key] = new TextBubble(theEntity, "...");
                        }
                        else if (this.npcStateBubbles[key].Text != "...")
                        {
                            this.npcStateBubbles[key].isReadyForDeletion = true;
                            this.npcStateBubbles[key] = new TextBubble(theEntity, "...");
                        }

                        break;
                }

                if(this.npcStateBubbles[key] != null)
                    this.npcStateBubbles[key].Update(gameTime, gameReference);
            }

            // Update each of the text bubbles...
            currentNode = this.activeTextBubbles.First;
            while (currentNode != null)
            {
                LinkedListNode<TextBubble> next = currentNode.Next;

                currentNode.Value.Update(gameTime, gameReference);

                if (currentNode.Value.isReadyForDeletion)
                    this.activeTextBubbles.Remove(currentNode);

                currentNode = next;
            }
        }
        /// <summary>
        /// Update the character class.
        /// </summary>
        /// <param name="gameTime">The game time object for letting you know how old you've gotten since starting the game.</param>
        /// <param name="gameReference">A deeper game reference to the game reference of doom.</param>
        public override void Update(GameTime gameTime, Pantheon gameReference)
        {
            base.Update(gameTime, gameReference);

            prevLocation = Location;

            //Move the player by velocity
            Location = new Vector2(Location.X + Velocity.X, Location.Y + Velocity.Y);

            //Update the equipped items
            foreach (Item item in EquippedItems.Values)
            {
                item.Update(gameTime, gameReference);
            }
        }
        public void Move(Pantheon gameReference)
        {
            Item temp;

            if (PlayerCharacter.inventory.unequipped.Union(PlayerCharacter.inventory.equipped).ElementAt(hoveredOver).isNull)
            {
                if (hoveredOver < 24)
                {
                    PlayerCharacter.inventory.unequipped.RemoveAt(hoveredOver);
                    PlayerCharacter.inventory.unequipped.Insert(hoveredOver, tempStorage);
                    tempStorage = new Item();
                    ((PlayerCharacter)gameReference.player).ArmedItem = PlayerCharacter.inventory.equipped.ElementAt(((PlayerCharacter)gameReference.player).CurrentArmedItem);
                }
                else if (hoveredOver >= 24)
                {
                    PlayerCharacter.inventory.equipped.RemoveAt(hoveredOver - 24);
                    PlayerCharacter.inventory.equipped.Insert(hoveredOver - 24, tempStorage);
                    tempStorage = new Item();
                    ((PlayerCharacter)gameReference.player).ArmedItem = PlayerCharacter.inventory.equipped.ElementAt(((PlayerCharacter)gameReference.player).CurrentArmedItem);
                }
                selected = -1;
            }
            else
            {
                if (hoveredOver < 24)
                {
                    temp = PlayerCharacter.inventory.unequipped.ElementAt(hoveredOver);
                    PlayerCharacter.inventory.unequipped.RemoveAt(hoveredOver);
                    PlayerCharacter.inventory.unequipped.Insert(hoveredOver, tempStorage);
                    tempStorage = temp;
                }
                else if (hoveredOver >= 24)
                {
                    temp = PlayerCharacter.inventory.equipped.ElementAt(hoveredOver - 24);
                    PlayerCharacter.inventory.equipped.RemoveAt(hoveredOver - 24);
                    PlayerCharacter.inventory.equipped.Insert(hoveredOver - 24, tempStorage);
                    tempStorage = temp;
                }
                selected = hoveredOver;
            }
        }
        /// <summary>
        /// Updates the location of the character. This is a subfunction of the update function
        /// meant to take some of the logic and stick it istor a logical subdivision. All
        /// game logic concerning movement and the player's character should go here.
        /// 
        /// Note: Forces the entity state into Idle if not moving. This should be overwritten
        /// by other functions which can update the state to Attack or some other relevant
        /// state.
        /// </summary>
        /// <param name="gameReference">A reference to the entire game for purposes of finding the holy grail.
        /// Also, provides access to the ControlManager class.</param>
        private void updateLocation(Pantheon gameReference)
        {
            ///<summary>
            ///TEMPORARY: This should be replaced by an entity feature... probably.
            ///</summary>
            int movementSpeed = 10;

            //Reset the velocity to nothing...
            velocity = Vector2.Zero;

            //Poll for input and update velocity accordingly
            if (gameReference.ControlManager.actions.MoveForward)
            {
                velocity += new Vector2(0, 1);
            }

            if (gameReference.ControlManager.actions.MoveBackward)
            {
                velocity += new Vector2(0, -1);
            }

            if (gameReference.ControlManager.actions.MoveLeft)
            {
                velocity += new Vector2(-1, 0);
            }

            if (gameReference.ControlManager.actions.MoveRight)
            {
                velocity += new Vector2(1, 0);
            }

            if (velocity != Vector2.Zero)
            {
                velocity.Normalize();
                velocity *= movementSpeed;
            }

            //Update the entity state to show movement
            if (velocity != Vector2.Zero)
            {
                currentState = "Move";
            }
            else
            {
                currentState = "Idle";
            }
        }
        /// <summary>
        /// Puts the laser in the right spot on screen.
        /// </summary>
        /// <param name="gameReference">Object to access the control manager.</param>
        private void updateLaser(Pantheon gameReference, Vector2 offset)
        {
            cursorLocation = gameReference.ControlManager.actions.CursorPosition;
            cursorLocation.X += Location.X - gameReference.GraphicsDevice.Viewport.Width / 2 + offset.X;
            cursorLocation.Y += Location.Y - gameReference.GraphicsDevice.Viewport.Height / 2 + offset.Y;
            angleFacing = (float)Math.Atan2(cursorLocation.Y - DrawingBox.Center.Y, cursorLocation.X - DrawingBox.Center.X);

            //Modify the direction in which the character faces
            if (gameReference.ControlManager.actions.isControlEnabled)
            {
                Facing = HamburgerHelper.reduceAngle(cursorLocation - new Vector2(DrawingBox.Center.X, DrawingBox.Center.Y));
            }
        }
Beispiel #22
0
        /// <summary>
        /// Turn the shield on.
        /// 
        /// Currently just draws the sheild. The sheild resources are handled in PlayerCharacter and CharcaterEntity.
        /// This may change in the future.
        /// </summary>
        /// <param name="gameReference">A reference so we can see where everything is.</param>
        /// <param name="holder">A reference to the character holding the weapon.</param>
        public override void activate(Pantheon gameReference, CharacterEntity holder)
        {
            base.activate(gameReference, holder);

            shieldOn = !shieldOn;
        }
        /// <summary>
        /// Updates the equipped items according to user input.
        /// </summary>
        /// <param name="gameReference">A reference to the game so that the items can do their jobs.</param>
        private void updateEquipped(Pantheon gameReference, GameTime gameTime)
        {
            //Fire all (one of) the weapons!
            if (gameReference.ControlManager.actions.Attack)
            {
                if (this.ArmedItem.type == (Item.Type.WEAPON) && !((Weapon)this.ArmedItem).Reloading)
                {
                    this.ArmedItem.activate(gameReference, this);
                }
            }

            //reload button
            if (this.ArmedItem.type == (Item.Type.WEAPON))
            {
                if (gameReference.ControlManager.actions.Reload && !((Weapon)this.ArmedItem).Reloading)
                {
                    //check if you have fired a shot before you reload your gun...otherwise, what's the point?
                    if(!(((Weapon)this.ArmedItem).CurrentAmmo.ToString().Equals(((Weapon)this.ArmedItem).TotalAmmo.ToString())))
                    {
                        gameReference.audioManager.playSoundEffect("reload");
                        ((Weapon)this.ArmedItem).Reload(gameTime);
                    }

                }
            }

            //Activate the shield (Actually a toggle)
            if (gameReference.ControlManager.actions.Shield == true)
            {
                if (!(inventory.equipped.ElementAt(6).isNull))
                {
                    EquippedItems["shield"].activate(gameReference, this);

                    gameReference.audioManager.playSoundEffect("shieldPower");
                }
            }

            //Bad hardcode that turns the shield off if it's on and we've unequipped the shield in the inventory
            if (((Shield)(EquippedItems["shield"])).ShieldOn && inventory.equipped.ElementAt(6).isNull)
            {
                EquippedItems["shield"].activate(gameReference, this);

            }

            //Ammo and shield cheat
            if (gameReference.ControlManager.actions.MoveBackward
                && gameReference.ControlManager.actions.MoveForward
                && gameReference.ControlManager.actions.MoveLeft
                && gameReference.ControlManager.actions.MoveRight)
            {
                if (this.Equippeditems.ContainsKey("weapon"))
                {
                    ((Weapon)this.EquippedItems["weapon"]).CurrentAmmo = ((Weapon)this.EquippedItems["weapon"]).TotalAmmo;
                }
                if (this.Equippeditems.ContainsKey("shield"))
                {
                    ((Shield)this.EquippedItems["shield"]).CurrentShield = ((Shield)this.EquippedItems["shield"]).TotalShield;
                }
            }
        }
        /// <summary>
        /// Updates the player entity.
        /// 
        /// Unlike the name suggests... (What did you think it did?)
        /// </summary>
        /// <param name="gameTime">The time object that lets the Update object know how old it is.</param>
        /// <param name="gameReference">A reference to the entire game universe for the purpose of making the player feel small.</param>
        public override void Update(GameTime gameTime, Pantheon gameReference)
        {
            //Update the velocity and facing
            updateLocation(gameReference);
            updateLaser(gameReference, Vector2.Zero);
            updateScope(gameReference);
            updateEquipped(gameReference, gameTime);
            updateInteractions(gameReference);

            if (gameReference.ControlManager.actions.beingDamaged == true)
            {
                Damage(10);
                gameReference.ControlManager.actions.beingDamaged = false;
            }
            if (currentArmor <= 0)
            {

                currentState = "Die";
                gameReference.ControlManager.disableControls(true);
                if (playOnce)
                {
                    gameReference.audioManager.playSoundEffect("Evil Laugh");
                    playOnce = false;
                }

            }
            if (!gameReference.ControlManager.actions.isControlEnabled)
            {
                drawLasar = false;
            }
            else
            {
                drawLasar = true;
            }

            // swap equipped weapons code goes here
            if (!gameReference.ControlManager.actions.Aim && gameReference.ControlManager.actions.SwitchWeapon)
            {
                if (currentArmedItem == 0)
                {
                    currentArmedItem = 1;
                }
                else
                {
                    currentArmedItem = 0;
                }

                ArmedItem = PlayerCharacter.inventory.equipped.ElementAt(currentArmedItem);
            }

            //Update the sprite appropriately
            updateSprite();

            //Equippeditems.

            base.Update(gameTime, gameReference);
        }
 /// <summary>
 /// This updates the bubble which mostly is sure to set up the structure defining the ending time.
 /// </summary>
 /// <param name="gameTime"></param>
 public void Update(GameTime gameTime, Pantheon gameReference)
 {
     // If the bubble is attached to a character, move it with the character.
     if (this.entity != null)
     {
         this.position = this.entity.Location;
         this.position.Y = this.position.Y - (float)(this.entity.DrawingBox.Height*1.1);
     }
 }
 /// <summary>
 /// Updates where the camera should be looking while the player is scoping.
 /// </summary>
 /// <param name="gameReference">The key to accessing the camera.</param>
 private void updateScope(Pantheon gameReference)
 {
     if (gameReference.ControlManager.actions.Aim && this.ArmedItem.type == Item.Type.WEAPON)
     {
         int offsetSpeed = 30;
         gameReference.ControlManager.disableMotion();
         if (offset.Length() == 0)
         {
             switch (Facing)
             {
                 case Direction.forward:
                     offset.Y = offsetSpeed;
                     break;
                 case Direction.forwardLeft:
                     offset.X = (int)(-offsetSpeed / Math.Sqrt(2));
                     offset.Y = (int)(offsetSpeed / Math.Sqrt(2));
                     break;
                 case Direction.Left:
                     offset.X = -offsetSpeed;
                     break;
                 case Direction.backLeft:
                     offset.X = (int)(-offsetSpeed / Math.Sqrt(2));
                     offset.Y = (int)(-offsetSpeed / Math.Sqrt(2));
                     break;
                 case Direction.back:
                     offset.Y = -offsetSpeed;
                     break;
                 case Direction.backRight:
                     offset.X = (int)(offsetSpeed / Math.Sqrt(2));
                     offset.Y = (int)(-offsetSpeed / Math.Sqrt(2));
                     break;
                 case Direction.Right:
                     offset.X = offsetSpeed;
                     break;
                 case Direction.forwardRight:
                     offset.X = (int)(offsetSpeed / Math.Sqrt(2));
                     offset.Y = (int)(offsetSpeed / Math.Sqrt(2));
                     break;
                 default:
                     offset = Vector2.Zero;
                     break;
             }
         }
         if (totalOffset.Length() < ((Weapon)ArmedItem).Range / 2)
         {
             gameReference.GetCamera().Pos += offset;
             totalOffset += offset;
         }
         updateLaser(gameReference, totalOffset);
     }
     else
     {
         gameReference.ControlManager.enableMotion();
         totalOffset = Vector2.Zero;
         offset = Vector2.Zero;
     }
 }
 /// <summary>
 /// Updates the OLDE MAN
 /// </summary>
 /// <param name="gameTime">SHOWS JUST HOW OLD OF A MAN HE IS.</param>
 /// <param name="gameReference">THE OLD MAN NEEDS NO SUCH REFERENCE BECAUSE HE ALREADY HAS THE WISDOM OF THE UNIVERSE.</param>
 public override void Update(GameTime gameTime, Pantheon gameReference)
 {
     base.Update(gameTime, gameReference);
 }
 /// <summary>
 /// Seems legit.
 /// </summary>
 /// <param name="gameREFERENCEOFDOOMFORTHESAVINGOFTHEUNIVERSE">yep</param>
 public void Unregister(Pantheon gameREFERENCEOFDOOMFORTHESAVINGOFTHEUNIVERSE)
 {
     gameREFERENCEOFDOOMFORTHESAVINGOFTHEUNIVERSE.EventManager.unregister("Interaction", this.interactionEventHandler);
     gameREFERENCEOFDOOMFORTHESAVINGOFTHEUNIVERSE.EventManager.unregister("InteractionAlert", this.interactionAlertEventHandler);
     gameREFERENCEOFDOOMFORTHESAVINGOFTHEUNIVERSE.EventManager.unregister("SpontaneousConversation", this.spontaneousConversationEventHandler);
 }
        /// <summary>
        /// Updates the interactions between the NPCs and the player,
        /// firing off an event for the DialogueManager to handle.
        /// </summary>
        /// <param name="gameReference">A reference to the entire game.</param>
        private void updateInteractions(Pantheon gameReference)
        {
            // Variable initialization --
            NPCCharacter theClosestDude = null;
            NPCCharacter theCurrentDude;

            string theClosestDudesName = "";

            // Get list of NPCs.
            var activeNPCs = from entity in gameReference.currentLevel.Entities where entity.Key.Contains("Friend") select entity.Key;

            // Cycle through and check the social bubbles of the NPCs.
            foreach (String entityKey in activeNPCs)
            {
                Event resetAlerts = new Event();
                resetAlerts.Type = "InteractionAlert";
                resetAlerts.GameReference = gameReference;
                resetAlerts.payload["EntityKey"] = entityKey;
                resetAlerts.payload["State"] = DialogueManager.STATE_NONE;

                gameReference.EventManager.notify(resetAlerts);

                theCurrentDude = (NPCCharacter)gameReference.currentLevel.Entities[entityKey];

                // INTERSECT, WITH YOUR SPLEEN
                if (this.BoundingBox.Intersects(theCurrentDude.ComfortZone))
                {
                    // If no dude, then he is the dude.
                    if (theClosestDude == null)
                    {
                        theClosestDude = theCurrentDude;
                        theClosestDudesName = entityKey;

                        continue;
                    }
                    // Check to see if we have a new dude.
                    else if (Vector2.Distance(theCurrentDude.ActionPoint, this.ActionPoint) < Vector2.Distance(theClosestDude.ActionPoint, this.ActionPoint))
                    {
                        theClosestDude = theCurrentDude;
                        theClosestDudesName = entityKey;
                    }
                }
            }

            // If there is a closest dude, we need to see if we want to interact with him, if so, shoot the event, if not, shoot the other event to make the bubbles appear on top of his head and into the sky.
            if (theClosestDude != null)
            {
                Event talkWithPeople = new Event();

                talkWithPeople.Type = "NONE";
                talkWithPeople.GameReference = gameReference;
                talkWithPeople.payload = new Dictionary<string,string>();

                talkWithPeople.payload["EntityKey"] = theClosestDudesName;

                if (gameReference.ControlManager.actions.Interact)
                {
                    talkWithPeople.Type = "Interaction";
                    //Button Click sound when you press interaction key in the area of an interaction
                    gameReference.audioManager.playSoundEffect("Button Click");
                }
                else
                {
                    talkWithPeople.Type = "InteractionAlert";
                    talkWithPeople.payload["State"] = DialogueManager.STATE_TALKABLE;
                }

                gameReference.EventManager.notify(talkWithPeople);
            }
        }
Beispiel #30
0
        public override void Update(GameTime gameTime, Pantheon gameReference)
        {
            base.Update(gameTime, gameReference);

            //Drain the shield when it's on.
            if (shieldOn && currentShield > 0)
            {
                //If the shield is just being turned on, add it to the level
                if (!gameReference.currentLevel.Entities.ContainsKey("character_shield"))
                {
                    gameReference.currentLevel.addList.Add("character_shield", energyField);
                }

                //Update the location of the energy field
                energyField.Location = gameReference.currentLevel.Entities["character"].Location;

                currentShield--;
            }
            else
            {
                //If the shield is just being turned off, then remove it from the level
                if (gameReference.currentLevel.Entities.ContainsKey("character_shield"))
                {
                    gameReference.currentLevel.removeList.Add("character_shield");
                }
            }

            // Make the shield fade with use
            energyField.Sprite.Opacity = (int)(((float)currentShield/totalShield) * 100.0) + 41;
        }