Exemple #1
0
 public UIEventWindow(Vector2 position, UIEventWindowType windowtype, WorldEvent worldevent, SpriteFont font)
 {
     uiEventWindowPosition = new Rectangle((int)position.X, (int)position.Y, 0, 0);
     if (windowtype == UIEventWindowType.WorldEvent)
     {
         titleText    = worldevent.ReturnEventTitleText();
         eventOptions = worldevent.GetEventOptions();
         uiEventWindowPosition.Width  = getCardWidth(font);
         descriptionTextLines         = getEventWindowDescriptionLines(worldevent.ReturnEventDescriptionText(), font);
         uiEventWindowPosition.Height = GetCardHeight(descriptionTextLines.Count, worldevent.GetCountofEventOptions());
         PopulateEventOptionCollisions();
     }
     thisEventWindowType = windowtype;
 }
Exemple #2
0
        public void CreateEventUI(WorldEvent worldevent)
        {
            Vector2 position = new Vector2(backbuffersize.X / 2, backbuffersize.Y / 2);

            uiEventWindows.Add(new UIEventWindow(position, UIEventWindow.UIEventWindowType.WorldEvent, worldevent, mainFont));
        }
 public void ClearWorldEvent()
 {
     currentWorldEvent = null;
 }
        void CheckForValidEvents(PlayerHandler player, DataManager datamanager, Random rando, GridTile.GridTerrain terraintype, Boolean isonroad, WorldMap world, int hour)
        {
            List <Event>      possibleEvents      = new List <Event>();
            List <WorldEvent> possibleWorldEvents = new List <WorldEvent>();

            //check for world events
            foreach (KeyValuePair <String, WorldEvent> e in datamanager.worldEventData)
            {
                WorldEvent worldevent = e.Value;
                //check if the mark is eligible to make a decision for options
                //party members aren't checked, but are affected by the mark's choice
                worldevent.DetermineEventOptionAvailability(player);
                //check grid and other reqs, then add to possible events
                if (worldevent.CheckForGridRequirements(terraintype, isonroad) == true &&
                    worldevent.ValidCreatureIfApplicable(world, currentGridLocation, rando, hour) == true)
                {
                    //determine the text used
                    worldevent.DetermineValidText(rando);
                    //add to possible events
                    possibleWorldEvents.Add(worldevent);
                }
            }


            //check for passive events
            foreach (KeyValuePair <String, Event> e in datamanager.passiveEventData)
            {
                //check if can occur when travelling
                if (e.Value.CanOccurWhenTravelling() == true)
                {
                    //add any eligible people to event
                    Event newevent = CheckIfPeopleEligible(e.Value, player);
                    //determine the item
                    newevent.DetermineValidItem(datamanager, rando);
                    //determine the text used
                    newevent.DetermineValidText(rando);
                    //if eligible people exist, add to event
                    if (newevent.IsEligibleExists() == true && newevent.CheckForGridRequirements(terraintype, isonroad) == true &&
                        newevent.CheckForPartySizeRequirements(player.partyMembers.Count) == true)
                    {
                        possibleEvents.Add(newevent);
                    }
                }
            }


            //check against list of posible world events
            for (int i = 0; i < possibleWorldEvents.Count; ++i)
            {
                int rand = rando.Next(0, 101);
                if (rand < possibleWorldEvents[i].ReturnEventChance())
                {
                    currentWorldEvent = possibleWorldEvents[i];
                    break;
                }
            }


            //check against list of possible passive events, only if a world event isn't going on
            if (currentWorldEvent == null)
            {
                for (int i = 0; i < possibleEvents.Count; ++i)
                {
                    int rand = rando.Next(0, 101);
                    if (rand < possibleEvents[i].ReturnEventChance())
                    {
                        SetCurrentPassiveEvent(possibleEvents[i], true, rando, player, "");
                        break;
                    }
                }
            }
        }