//Allows creating wall in 2d, as Y is 0 anyway. Using the 2d Y as Z
        public SolidWall(GraphicsDevice graphicsDevice,
            Vector2 btmFrontLeftNoY, Vector2 btmFrontRightNoY,
            Vector2 btmBackRightNoY, Vector2 btmBackLeftNoY,
            float height = GameConstants.WALL_HEIGHT)
        {
            Vector3 btmFrontLeft = new Vector3(btmFrontLeftNoY.X, 0, btmFrontLeftNoY.Y);
            Vector3 btmFrontRight = new Vector3(btmFrontRightNoY.X, 0, btmFrontRightNoY.Y);
            Vector3 btmBackRight = new Vector3(btmBackRightNoY.X, 0, btmBackRightNoY.Y);
            Vector3 btmBackLeft = new Vector3(btmBackLeftNoY.X, 0, btmBackLeftNoY.Y);

            sides = new NormalMappedWall[5];
            //+Z wall
            sides[0] = new NormalMappedWall(graphicsDevice, btmFrontRight * GameConstants.MAP_SCALE, btmFrontLeft * GameConstants.MAP_SCALE, Vector3.Backward, height * GameConstants.MAP_SCALE);

            //-Z wall
            sides[1] = new NormalMappedWall(graphicsDevice, btmBackLeft * GameConstants.MAP_SCALE, btmBackRight * GameConstants.MAP_SCALE, Vector3.Forward, height * GameConstants.MAP_SCALE);

            //-X wall
            sides[2] = new NormalMappedWall(graphicsDevice, btmFrontLeft * GameConstants.MAP_SCALE, btmBackLeft * GameConstants.MAP_SCALE, Vector3.Left, height * GameConstants.MAP_SCALE);

            //+X wall
            sides[3] = new NormalMappedWall(graphicsDevice, btmBackRight * GameConstants.MAP_SCALE, btmFrontRight * GameConstants.MAP_SCALE, Vector3.Right, height * GameConstants.MAP_SCALE);

            Vector3 topFrontLeft = new Vector3(btmFrontLeftNoY.X, GameConstants.WALL_HEIGHT, btmFrontLeftNoY.Y);
            Vector3 topFrontRight = new Vector3(btmFrontRightNoY.X, GameConstants.WALL_HEIGHT, btmFrontRightNoY.Y);
            Vector3 topBackRight = new Vector3(btmBackRightNoY.X, GameConstants.WALL_HEIGHT, btmBackRightNoY.Y);
            Vector3 topBackLeft = new Vector3(btmBackLeftNoY.X, GameConstants.WALL_HEIGHT, btmBackLeftNoY.Y);
            //+X wall
            sides[4] = new NormalMappedWall(graphicsDevice, topFrontLeft, topFrontRight, topBackRight, topBackLeft, Vector3.Up);

            aabb = new AABB(btmFrontLeft * GameConstants.MAP_SCALE, btmFrontRight * GameConstants.MAP_SCALE, btmBackRight * GameConstants.MAP_SCALE, btmBackLeft * GameConstants.MAP_SCALE, height * GameConstants.MAP_SCALE);
        }
 public void OnChestOpen(AABB chestOpener)
 {
     if (!Game.player.inv.HaveItemOfType("compass"))
     {
         Game.SoundManager.PlaySound("Loot");
         Game.player.inv.AddItem(new InventoryItem(this, "compass"));
     }
 }
        public static List<AABB> GetInteractablesInRange(AABB you)
        {
            List<AABB> retList = new List<AABB>();

            foreach (AABB aabb in World.currentArea.Interactables)
            {
                if (IsInRange(you, aabb))
                    retList.Add(aabb);
            }
            return retList;
        }
 public static Vector3 CheckCollision(AABB you)
 {
     Vector3 returnValue = Vector3.Zero;
     foreach (AABB aabb in Collidables)
     {
         if (!aabb.Equals(you))
         {
             returnValue += aabb.CheckCollision(you);
         }
     }
     return returnValue;
 }
        public override void LoadContent(GraphicsDevice device, ContentManager contentMan)
        {
            base.LoadContent(device, contentMan);

            GenerateWalls();
            GenerateCeiling();
            GenerateFloors();
            GenerateEnemies();
            GenInteractiveEnvironment();

            StartArea4AABB = new AABB(new Vector2(0, 5000), new Vector2(5000, 5500));
        }
        public SolidWall(GraphicsDevice graphicsDevice, 
            Vector3 btmFrontLeft, Vector3 btmFrontRight,
            Vector3 btmBackRight, Vector3 btmBackLeft,
            float height = GameConstants.WALL_HEIGHT)
        {
            sides = new NormalMappedWall[4];
            //+Z wall
            sides[0] = new NormalMappedWall(graphicsDevice, btmFrontRight * GameConstants.MAP_SCALE, btmFrontLeft * GameConstants.MAP_SCALE, Vector3.Backward, height * GameConstants.MAP_SCALE);

            //-Z wall
            sides[1] = new NormalMappedWall(graphicsDevice, btmBackLeft * GameConstants.MAP_SCALE, btmBackRight * GameConstants.MAP_SCALE, Vector3.Forward, height * GameConstants.MAP_SCALE);

            //-X wall
            sides[2] = new NormalMappedWall(graphicsDevice, btmFrontLeft * GameConstants.MAP_SCALE, btmBackLeft * GameConstants.MAP_SCALE, Vector3.Left, height * GameConstants.MAP_SCALE);

            //+X wall
            sides[3] = new NormalMappedWall(graphicsDevice, btmBackRight * GameConstants.MAP_SCALE, btmFrontRight * GameConstants.MAP_SCALE, Vector3.Right, height * GameConstants.MAP_SCALE);

            aabb = new AABB(btmFrontLeft * GameConstants.MAP_SCALE, btmFrontRight * GameConstants.MAP_SCALE, btmBackRight * GameConstants.MAP_SCALE, btmBackLeft * GameConstants.MAP_SCALE, height * GameConstants.MAP_SCALE);
        }
 public Door(ContentManager content,
     Vector3 position, Vector3 rotation,
     Vector3 moveToPos,
     float scale, Vector3 openFromDirection,
     ref List<AABB> collisionList,
     string openedByKeyWithID,
     DoorState state = DoorState.CLOSED, bool canToggle = false)
     : base(@"Models\Environment\SecretDoor", content, position, rotation, scale)
 {
     base.color = new Vector3(0.2f, 0.2f, 0.2f);
     this.OpenedByKeyWithID = openedByKeyWithID;
     this.doorState = state;
     CreateUseAABB(openFromDirection, position, 150, 150);
     Interactables.AddInteractable(this);
     emitter = new AudioEmitter();
     emitter.Position = position;
     orgOpenPos = moveToPos;
     orgMoveToPos = moveToPos;
     this.canToggle = canToggle;
     collisionAABB = new AABB();
     CreateCollision(position, rotation, scale);
     collisionList.Add(collisionAABB);
     velocity = Vector3.Subtract(moveToPos, position);
 }
 public void Use(AABB interactingParty)
 {
     currentState = GateState.OPENING;
 }
 public void Use(AABB interactingParty)
 {
     if (currentState == GateState.CLOSED)
     {
         currentState = GateState.OPENING;
     }
 }
 public void Use(AABB interactingParty)
 {
     if (!submerged && !submerging)
     {
         StartRotation(90, 15);
         this.interactingPartyForCallback = interactingParty;
         Game.SoundManager.PlaySound("PillarRotate", this);
     }
 }
예제 #11
0
        /// <summary>
        /// NOTE: ONLY CEHCKING COLLISION IN X AND Z AXIS! if at any point
        /// Y axis collision is needed, it must be edited inn.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public Vector3 minimumTranslation(AABB other)
        {
            Vector2 amin = new Vector2(minPoint.X, minPoint.Z);
            Vector2 amax = new Vector2(maxPoint.X, maxPoint.Z);
            Vector2 bmin = new Vector2(other.MinPoint.X, other.MinPoint.Z);
            Vector2 bmax = new Vector2(other.MaxPoint.X, other.MaxPoint.Z);

            Vector2 mtd = new Vector2();

            float left = (bmin.X - amax.X);
            float right = (bmax.X - amin.X);
            float top = (bmin.Y - amax.Y);
            float bottom = (bmax.Y - amin.Y);

            // box dont intersect
            if (left > 0 || right < 0) throw new Exception("no intersection");
            if (top > 0 || bottom < 0) throw new Exception("no intersection");

            // box intersect. work out the mtd on both x and y axes.
            if (Math.Abs(left) < right)
                mtd.X = left;
            else
                mtd.X = right;

            if (Math.Abs(top) < bottom)
                mtd.Y = top;
            else
                mtd.Y = bottom;

            // 0 the axis with the largest mtd value.
            if (Math.Abs(mtd.X) < Math.Abs(mtd.Y))
                mtd.Y = 0;
            else
                mtd.X = 0;
            return new Vector3(mtd.X, 0, mtd.Y);
        }
예제 #12
0
 public void Use(AABB interactingParty)
 {
     if (gateState == GateState.OPEN)
     {
         CloseGate();
     }
     else if (gateState == GateState.CLOSED)
     {
         OpenGate();
     }
     if (interactingParty is IInteractableObject)
     {
         IInteractableObject obj = (IInteractableObject)interactingParty;
         if (!interactingParties.Contains(obj))
             interactingParties.Add(obj);
     }
 }
 public static void RemoveInteractable(AABB interactableToRemove)
 {
     World.currentArea.Interactables.Remove(interactableToRemove);
     //interactables.Remove(interactableToRemove);
 }
        public void Use(AABB interactingParty)
        {
            if (!isOpen)
            {
                if (!lever1Used)
                {
                    if (interactingParty.CheckCollision(lever1) != Vector3.Zero)
                    {
                        lever1Used = true;
                        lever1UsedDuration = 0.0f;
                        Game.SoundManager.PlaySound("Clock", lever2, timesToPlay);

                        lever1.Use(null);
                    }
                }
                if (!lever2Used)
                {
                    if (interactingParty.CheckCollision(lever2) != Vector3.Zero)
                    {
                        lever2Used = true;
                        lever2UsedDuration = 0.0f;
                        Game.SoundManager.PlaySound("Clock", lever1, timesToPlay);

                        lever2.Use(null);
                    }
                }
                if (lever1Used && lever2Used)
                {
                    Game.SoundManager.StopSound("Clock");
                    OnUseObject.Use(interactingParty);
                    lever1Used = false;
                    lever2Used = false;
                    isOpen = true;
                }
            }
        }
 public static void AddCollidable(AABB collidable)
 {
     if (!Collidables.Contains(collidable))
         Collidables.Add(collidable);
 }
 public void Use(AABB interactingParty)
 {
     if (cooldownTimer > cooldown)
     {
         if (interactingParty is Player)
         {
             subbedForPorting = true;
             cooldownTimer = 0.0f;
             player = (Player)interactingParty;
             Game.SoundManager.PlaySound("PortalUse", null, 0, false);
         }
         else
             throw new Exception("interacting party (with portal) is not player");
     }
 }
예제 #17
0
 public void Use(AABB interactingParty)
 {
     if (interactingParty is Player)
     {
         Game.SoundManager.PlaySound("GemPickup");
         Game.SoundManager.StopSound(effectName);
         Interactables.RemoveInteractable(this);
         Game.player.inv.AddItem(new InventoryItem(this, gemType));
         World.currentArea.RemoveEnvironmentItem(this);
     }
 }
예제 #18
0
 public void Use(AABB interactingParty)
 {
     if (doorState == DoorState.CLOSED)
     {
         //check if player have the key, then open
         if (interactingParty is Player)
         {
             Player player = (Player)interactingParty;
             if(player.inv.HaveItemOfType(OpenedByKeyWithID))
             {
                 player.inv.RemoveItemsOfType(OpenedByKeyWithID);
                 Game.SoundManager.PlaySound("DoorOpen", this);
                 openTimer = 0.0f;
                 doorState = DoorState.OPENING;
             }
         }
     }
 }
예제 #19
0
 public void Use(AABB interactingParty)
 {
     if (interactingParty is Player)
     {
         Game.SoundManager.PlaySound("Loot");
         Interactables.RemoveInteractable(this);
         Game.player.inv.AddItem(new InventoryItem(this, KeyID));
         World.currentArea.RemoveEnvironmentItem(this);
     }
 }
 public void Use(AABB interactingParty)
 {
     if (interactingParty is Player)
     {
         Player player = (Player)interactingParty;
         if (player.inv.HaveItemOfType(attatchedGem))
         {
             if (attatchedGem == "GemRed")
             {
                 Game.SoundManager.PlaySound("RedGemEntered", this);
             }
             else if (attatchedGem == "GemYellow")
             {
                 Game.SoundManager.PlaySound("YellowGemEntered", this);
             }
             else if (attatchedGem == "GemBlue")
             {
                 Game.SoundManager.PlaySound("BlueGemEntered", this);
             }
             Gem gem = (Gem)player.inv.GetAndRemoveItem(attatchedGem);
             if (gem != null)
             {
                 gem.AttatchToPedistal(new Vector3(position.X, 150, position.Z));
                 World.currentArea.AddEnvironmentObjectToEnvironment(gem);
                 IsUnlocked = true;
             }
             else
                 throw new Exception("Player did not have the gem after all hurpdurp");
         }
     }
 }
 //public static List<AABB> interactables = new List<AABB>();
 public static void AddInteractable(AABB interactable)
 {
     if (!World.currentArea.Interactables.Contains(interactable))
         World.currentArea.Interactables.Add(interactable);
 }
        public void Use(AABB interactingParty)
        {
            if (!isUsed)
            {
                Game.SoundManager.PlaySound("LeverUsed", this);
                base.SetModel(usedModel);
                if (onUseObject != null && interactingParty != null)
                {
                    onUseObject.Use(this);
                }

                isUsed = true;
            }
        }
 public static bool IsInRange(AABB you, AABB target)
 {
     return (you.CheckCollision(target) != Vector3.Zero);
 }
예제 #24
0
        public Vector3 CheckCollision(AABB otherAABB)
        {
            if (maxPoint.Z < otherAABB.MinPoint.Z) return Vector3.Zero;
            if (minPoint.Z > otherAABB.MaxPoint.Z) return Vector3.Zero;
            if (maxPoint.X < otherAABB.MinPoint.X) return Vector3.Zero;
            if (maxPoint.Y < otherAABB.MinPoint.Y) return Vector3.Zero;
            if (minPoint.X > otherAABB.MaxPoint.X) return Vector3.Zero;
            if (minPoint.Y > otherAABB.MaxPoint.Y) return Vector3.Zero;

            return minimumTranslation(otherAABB);
        }
 public void Use(AABB interactingParty)
 {
     if (isClosed)
     {
         Game.SoundManager.PlaySound("ChestOpen");
         base.SetModel(openModel);
         isClosed = false;
     }
     else
     {
         if (ChestInventory.Count == 0)
         {
             Game.SoundManager.PlaySound("ChestClose");
             base.SetModel(closedModel);
             isClosed = true;
         }
         else
         {
             if (interactingParty is Player)
             {
                 Player player = (Player)interactingParty;
                 foreach(IChestItem item in ChestInventory)
                 {
                     item.OnChestOpen(interactingParty);
                 }
                 ChestInventory.Clear();
             }
         }
     }
 }
예제 #26
0
 public void OnChestOpen(AABB chestOpener)
 {
     if (chestOpener is Player)
     {
         Game.SoundManager.PlaySound("Loot");
         Interactables.RemoveInteractable(this);
         Game.player.inv.AddItem(new InventoryItem(this, KeyID));
         World.currentArea.RemoveEnvironmentItem(this);
     }
 }