public override void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
        {
            if (entity is SpaceMarauders.Entity.Player)
            {
                currentKeyboardState = Keyboard.GetState();
                currentMouseState    = Mouse.GetState();
                UpdateInventoryLogic();

                if (slot1.itemID != -1)
                {
                    slot1.Update(gameTime, entity);

                    if (currentMouseState.LeftButton == ButtonState.Pressed && !drawInventory)
                    {
                        slot1.Use(entity);
                        slot1.inUse = true;
                    }
                    else
                    {
                        slot1.inUse = false;
                    }
                }
            }
            else
            {
                //slot1.Use(entity);
                //slot1.inUse = true;
            }

            previousMouseState = currentMouseState;
            base.Update(gameTime, entity);
        }
Exemplo n.º 2
0
        public override void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
        {
            CheckCollisionInMovementDirection(entity);
            position  = entity.position;
            cellIndex = entity.cellIndex;

            this.entity = entity;
        }
Exemplo n.º 3
0
        public Vector2 Evade(SpaceMarauders.Entity.Entity target)
        {
            float   distance       = Vector2.Distance(target.position, position);
            float   ahead          = distance / 10;
            Vector2 futurePosition = target.position + ((PhysicsComponent)target.GetComponent("PhysicsComponent")).velocity * ahead;

            return(Flee(futurePosition));
        }
        public override void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
        {
            Vector2 direction = Game1.worldPosition - entity.position;

            direction.Normalize();

            entity.rotation = (float)Math.Atan2(direction.Y, direction.X);

            //base.Update(gameTime, entity);
        }
Exemplo n.º 5
0
        void CheckCollisionInMovementDirection(SpaceMarauders.Entity.Entity entity)
        {
            /*
             * physicsThread = new Thread(() => CheckCollisionInPartitionNumber(entity));
             * physicsThread.Start();
             * physicsThread.Join();
             */

            CheckCollisionInPartitionNumber(entity);
        }
        public override void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
        {
            rectangle = entity.collisionRectanlge;
            // = entity;

            if (destroy)
            {
                entity.Detroy();
            }
            base.Update(gameTime, entity);
        }
Exemplo n.º 7
0
        public override void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
        {
            keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.W))
            {
                Event moveEvent = new Event();
                moveEvent.id = "AddVelocity";
                moveEvent.parameters.Add("Velocity", new Vector2(0, -2));
                entity.FireEvent(moveEvent);
            }

            if (keyboardState.IsKeyDown(Keys.S))
            {
                Event moveEvent = new Event();
                moveEvent.id = "AddVelocity";
                moveEvent.parameters.Add("Velocity", new Vector2(0, 2));
                entity.FireEvent(moveEvent);
            }

            if (keyboardState.IsKeyDown(Keys.A))
            {
                Event moveEvent = new Event();
                moveEvent.id = "AddVelocity";
                moveEvent.parameters.Add("Velocity", new Vector2(-2, 0));
                entity.FireEvent(moveEvent);
            }

            if (keyboardState.IsKeyDown(Keys.D))
            {
                Event moveEvent = new Event();
                moveEvent.id = "AddVelocity";
                moveEvent.parameters.Add("Velocity", new Vector2(2, 0));
                entity.FireEvent(moveEvent);
            }

            if (keyboardState.IsKeyDown(Keys.Tab) && oldKeyboardState.IsKeyUp(Keys.Tab))
            {
                Event openInventoryEvent = new Event();
                openInventoryEvent.id = "OpenInventory";
                entity.FireEvent(openInventoryEvent);
            }


            oldKeyboardState = keyboardState;
        }
Exemplo n.º 8
0
        public Vector2 Arrive(SpaceMarauders.Entity.Entity target, float slowingDistance)
        {
            Vector2 desiredVelocity = target.position - position;
            float   distance        = desiredVelocity.Length();

            if (distance < slowingDistance)
            {
                desiredVelocity.Normalize();
                desiredVelocity *= maxVelocity * (distance / slowingDistance);
            }
            else
            {
                desiredVelocity.Normalize();
                desiredVelocity *= maxVelocity;
            }
            Vector2 steering = desiredVelocity - velocity;

            return(steering);
        }
Exemplo n.º 9
0
        /// <summary>
        /// This is where velocity is added
        /// </summary>
        /// <param name="entity"></param>
        public void CheckCollisionInPartitionNumber(SpaceMarauders.Entity.Entity entity)
        {
            /// ** FUTURE PLANS AFTER TESTING **
            /// main "univererse" partition
            /// secondary space station partition
            /// -----------------------------------
            /// update (currentUniverseCell)
            ///     update(membersInUniverseCell)  these can have their own partitions \ 
            ///         update(performPhysicsChecksOnMembersInUniverseCell)


            // for now were just updating the one space station


            entity.oldPosition = entity.position;

            velocity *= .85f;
            if (!(entity is SpaceMarauders.Entity.Player))
            {
                velocity += Separation();
                //Console.WriteLine(entity.position.X + " " + velocity.X);
            }

            float j = 1.2f;

            entity.position.X += (int)velocity.X;

            if (Game1.world.FireGlobalEvent(FireCollisionEvent(entity), entity))
            {
                entity.position.X = entity.oldPosition.X;
                velocity.X        = -velocity.X * j;
                //Console.WriteLine("hit");
            }

            entity.position.Y += (int)velocity.Y;
            if (Game1.world.FireGlobalEvent(FireCollisionEvent(entity), entity))
            {
                entity.position.Y = entity.oldPosition.Y;
                velocity.Y        = -velocity.Y * j;
            }
        }
Exemplo n.º 10
0
        public Event FireCollisionEvent(SpaceMarauders.Entity.Entity entity)
        {
            entity.collisionRectanlge = new Rectangle(
                (int)entity.position.X - (int)(SpaceMarauders.Utilities.MathHelper.CenterOfImage(SpaceMarauders.Utilities.TextureManager.bodyParts[0]).X * .5f),
                (int)entity.position.Y - (int)(SpaceMarauders.Utilities.MathHelper.CenterOfImage(SpaceMarauders.Utilities.TextureManager.bodyParts[0]).Y * .5f),
                (int)(SpaceMarauders.Utilities.TextureManager.bodyParts[0].Width * .7f),
                (int)(SpaceMarauders.Utilities.TextureManager.bodyParts[0].Height * .7f));

            Event physicsEvent = new Event
            {
                id = "Collider"
            };

            physicsEvent.parameters.Add("rectangle", (Rectangle)entity.collisionRectanlge);
            physicsEvent.parameters.Add("entity", (SpaceMarauders.Entity.Entity)entity);
            if (entity is SpaceMarauders.Entity.NPC)
            {
                physicsEvent.parameters.Add("npc", 0);
            }
            return(physicsEvent);
        }
Exemplo n.º 11
0
 public override void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
 {
 }
Exemplo n.º 12
0
        public override void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
        {
            currentEquippedItem = ((InventoryComponent)entity.GetComponent("InventoryComponent")).slot1;

            if (currentEquippedItem != null)
            {
                if (entity is SpaceMarauders.Entity.Player)
                {
                    SpaceMarauders.Entity.Player tempPlayer = ((SpaceMarauders.Entity.Player)(entity));
                    rotation = entity.rotation;
                    int[] handIndex = tempPlayer.body.GetHandIndexes();


                    itemPosition = SpaceMarauders.Utilities.MathHelper.Vec2ToEntitySpace(
                        new Vector2(10, 0),
                        tempPlayer.body.bodyParts[handIndex[0]].positon, entity.rotation);

                    if (currentEquippedItem.itemID != -1)
                    {
                        center = SpaceMarauders.Utilities.MathHelper.CenterOfImage(
                            SpaceMarauders.Utilities.TextureManager.guiItemTextures[currentEquippedItem.guiItemID]);
                        currentEquippedItem.position = itemPosition;
                        ////.rotation = rotation;
                        tempPlayer.body.bodyParts[3].offset = new Vector2(60, 44);
                        //tempPlayer.body.bodyParts[2].offset = new Vector2(50, 12);
                    }
                    else
                    {
                        tempPlayer.body.bodyParts[3].offset = new Vector2(30, 44);
                        //tempPlayer.body.bodyParts[2].offset = new Vector2(15, -22);
                    }
                }
                else
                {
                    SpaceMarauders.Entity.NPC tempPlayer = ((SpaceMarauders.Entity.NPC)(entity));
                    rotation = entity.rotation;
                    int[] handIndex = tempPlayer.body.GetHandIndexes();
                    currentEquippedItem = ((InventoryComponent)entity.GetComponent("InventoryComponent")).slot1;

                    itemPosition = SpaceMarauders.Utilities.MathHelper.Vec2ToEntitySpace(
                        new Vector2(10, 0),
                        tempPlayer.body.bodyParts[handIndex[0]].positon, entity.rotation);

                    if (currentEquippedItem.itemID != -1)
                    {
                        center = SpaceMarauders.Utilities.MathHelper.CenterOfImage(
                            SpaceMarauders.Utilities.TextureManager.guiItemTextures[currentEquippedItem.guiItemID]);
                        currentEquippedItem.position        = itemPosition;
                        currentEquippedItem.rotation        = rotation;
                        tempPlayer.body.bodyParts[3].offset = new Vector2(60, 44);
                        //tempPlayer.body.bodyParts[2].offset = new Vector2(50, 12);
                    }
                    else
                    {
                        tempPlayer.body.bodyParts[3].offset = new Vector2(30, 44);
                        tempPlayer.body.bodyParts[2].offset = new Vector2(15, -22);
                    }
                }
            }

            base.Update(gameTime, entity);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Gives entity a solid collider that makes it impassible
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="parentID"></param>
 public SolidColliderComponent(SpaceMarauders.Entity.Entity entity, int parentID) : base(parentID)
 {
     ComponentName = "SolidColliderComponent";
     rectangle     = entity.collisionRectanlge;
 }
Exemplo n.º 14
0
 public virtual void Update(GameTime gameTime, SpaceMarauders.Entity.Entity entity)
 {
 }
Exemplo n.º 15
0
 void DoCollisionStepWithThread(SpaceMarauders.Entity.Entity entity)
 {
 }