override public void OnEnterState()
        {
            // Using Sibling Index is hacky as f**k, but this should work for our purposes FRN.
            // VERY dependent on the view.
            MapModel    map        = AmbitionApp.GetModel <MapModel>();
            PartyModel  model      = AmbitionApp.GetModel <PartyModel>();
            UController controller = _machine._uflow.GetController(_machine);
            int         index      = controller.transform.GetSiblingIndex();

            if (index < map.Room.Guests.Length && map.Room.Guests[index] != null)
            {
                int[] chart = map.Room.Guests[index].State == GuestState.Charmed
                    ? model.CharmedGuestActionChance
                    : model.GuestActionChance;
                if (Util.RNG.Generate(chart[map.Room.Difficulty - 1]) > 0)
                {
                    map.Room.Guests[index].Action = null;
                }
                else
                {
                    GuestActionFactory factory = (GuestActionFactory)AmbitionApp.GetFactory <string, GuestActionVO>();
                    GuestActionVO[]    actions = factory.Actions.Values.ToArray();
                    actions = Array.FindAll(actions, a => a.Difficulty <= map.Room.Difficulty);
                    int choice = actions.Select(a => a.Chance).Sum();
                    int i      = 0;
                    for (choice = Util.RNG.Generate(choice); actions[i].Chance <= choice; i++)
                    {
                        choice -= actions[i].Chance;
                    }
                    map.Room.Guests[index].Action = actions[i];
                }
            }
            else
            {
                controller.gameObject.SetActive(false);
            }
        }
Esempio n. 2
0
 public void Initialize()
 {
     _map     = AmbitionApp.GetModel <MapModel>();
     _model   = AmbitionApp.GetModel <PartyModel>();
     _remarks = new RemarkVO[_model.HandSize];
 }
Esempio n. 3
0
        public bool CheckRequirements(CommodityVO[] requirments)
        {
            GameModel model = AmbitionApp.GetModel <GameModel>();

            foreach (CommodityVO req in requirments)
            {
                switch (req.Type)
                {
                case CommodityType.Item:
                    InventoryModel inventory = AmbitionApp.GetModel <InventoryModel>();
                    ItemVO         item      = inventory.Inventory.Find(i => i.Name == req.ID);
                    if (item == null || item.Quantity < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Livre:
                    if (model.Livre < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Location:
                    ParisModel paris = AmbitionApp.GetModel <ParisModel>();
                    if (!paris.Locations.Contains(req.ID))
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Reputation:
                    FactionModel factions = AmbitionApp.GetModel <FactionModel>();
                    return((req.ID != null && factions.Factions.ContainsKey(req.ID))
                            ? factions[req.ID].Reputation >= req.Value
                            : model.Reputation >= req.Value);

                case CommodityType.Servant:
                    ServantModel servants = AmbitionApp.GetModel <ServantModel>();
                    if (!servants.Servants.ContainsKey(req.ID))
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Date:
                    CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>();
                    if (calendar.Today.Ticks < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Mark:
                    MapModel map = AmbitionApp.GetModel <MapModel>();
                    return(Array.Exists(map.Map.Rooms, r => r.HostHere && r.Cleared));
                }
            }
            return(true);
        }