public static Vector2 GetCoordinateInsideScreen(Vector2 pos, Game1 Game)
        {
            Vector2 windowDimensions = GetWindowDimensions(Game);
            Vector2 cameraPos        = Game.camera.cameraPos;

            var coordLocation = GetCoordinateLocation(pos, Game, cameraPos);

            float newXPos;
            float newYPos;

            if (coordLocation == CoordinateLocation.left || coordLocation == CoordinateLocation.right)
            {
                int lowerYBound = (int)(cameraPos.Y - (windowDimensions.Y / 2));
                int upperYBound = (int)(Game.camera.cameraPos.Y + (windowDimensions.Y / 2));

                newYPos = MathFunctions.GetExternalRandomInt(lowerYBound, upperYBound);

                if (coordLocation == CoordinateLocation.left)
                {
                    newXPos = pos.X + windowDimensions.X;
                }
                else
                {
                    newXPos = pos.X - windowDimensions.X;
                }
            }
            else if (coordLocation == CoordinateLocation.above || coordLocation == CoordinateLocation.below)
            {
                int lowerXBound = (int)(cameraPos.X - (windowDimensions.X / 2));
                int upperXBound = (int)(Game.camera.cameraPos.X + (windowDimensions.X / 2));

                newXPos = MathFunctions.GetExternalRandomInt(lowerXBound, upperXBound);

                if (coordLocation == CoordinateLocation.above)
                {
                    newYPos = pos.Y + windowDimensions.Y;
                }
                else
                {
                    newYPos = pos.Y - windowDimensions.Y;
                }
            }
            else if (coordLocation == CoordinateLocation.inside)
            {
                newXPos = pos.X;
                newYPos = pos.Y;
            }
            else
            {
                throw new ArgumentException("Non-valid situation encountered!");
            }
            return(new Vector2(newXPos, newYPos));
        }
        private ItemVariety GetRandomVariety()
        {
            int randVal = MathFunctions.GetExternalRandomInt(0, 100);

            if (randVal < 60)
            {
                return(ItemVariety.Low);
            }
            else if (randVal < 90)
            {
                return(ItemVariety.Regular);
            }
            else
            {
                return(ItemVariety.High);
            }
        }
Beispiel #3
0
        private ItemVariety GetRandomItemVariety()
        {
            var val = MathFunctions.GetExternalRandomInt(0, 2);

            switch (val)
            {
            case 0:
                return(ItemVariety.Low);

            case 1:
                return(ItemVariety.Regular);

            case 2:
                return(ItemVariety.High);

            default:
                throw new ArgumentException("Invalid number of cases.");
            }
        }
Beispiel #4
0
 public override void OnEnter()
 {
     base.OnEnter();
     rumorIndex = MathFunctions.GetExternalRandomInt(0, rumorStrings.Count - 1);
 }
 public PirateEncounterOE() :
     base(interactText, rebelLevels[MathFunctions.GetExternalRandomInt(0, rebelLevels.Count - 1)], moneyReward, itemRewards, levelCompleted, levelFailed)
 {
 }