Beispiel #1
0
 public Lobby(Func <string> getAddress, string player)
 {
     _players    = player;
     _getAddress = getAddress;
     World.Subscribe(EventSubscription.Create <ConnectionFailed>(x => Leave(), this));
     World.Subscribe(EventSubscription.Create <PlayerConnected>(x => _players = $"{_players}\n{x.Name}", this));
 }
Beispiel #2
0
 public FoodCounter(TileLocation location)
 {
     Tile     = new ClickableTile("2/table2", location, true, EatFood, 2);
     FoodTile = new ClickableTile("transparent", location, true, 3);
     _foods   = new List <Food>();
     World.Subscribe(EventSubscription.Create <FoodDelivered>((f) => { _foods.Add(f.Food); FoodTile.TextureName = "2/food"; }, this));
 }
 public ReturnsCallReadyUI()
 {
     Branch  = new ClickUIBranch("Ready Button", (int)ClickUIPriorities.Pad);
     _button = ImageTextButtonFactory.Create("Ready", Vector2.Zero, StartCall);
     Branch.Add(_button);
     World.Subscribe(EventSubscription.Create <CallResolved>(x => AtEndCall(), this));
 }
Beispiel #4
0
 public ExcusesUI()
 {
     Branch        = new ClickUIBranch("Excuses", (int)ClickUIPriorities.Pad);
     _excuseButton = ImageTextButtonFactory.Create("Soothe", new Vector2(0, 0), MakeExcuse);
     World.Subscribe(EventSubscription.Create <CallStarted>(OnCallStart, this));
     World.Subscribe(EventSubscription.Create <CallResolved>(x => OnCallResolved(), this));
 }
        public NewPurchaseHistoriesUI(Size2 size)
        {
            Branch = new ClickUIBranch("Purchases", (int)ClickUIPriorities.Pad);
            _grid  = new GridLayout(size,
                                    new List <Definition> {
                new ConcreteDefinition(120), new ShareDefintion(), new ConcreteDefinition(120)
            }, 1);

            var backButton      = ImageTextButtonFactory.CreateRotated("<<", Vector2.Zero, NavigateBack, () => _index != 0 && _isInCall);
            var smartBackButton = new SmartControl(backButton, (int)ClickUIPriorities.Pad);

            Branch.Add(smartBackButton.Branch);
            _grid.AddSpatial(smartBackButton, backButton.Transform, 1, 1);

            var forwardButton      = ImageTextButtonFactory.CreateRotated(">>", Vector2.Zero, NavigateForward, () => (_purchaseSupplier?.Current != null || _index + _ordersPerPage < _purchaseUIs.Count) && _isInCall);
            var smartForwardButton = new SmartControl(forwardButton, (int)ClickUIPriorities.Pad);

            Branch.Add(smartForwardButton.Branch);
            _grid.AddSpatial(smartForwardButton, forwardButton.Transform, 3, 1);

            _branches.Add(smartForwardButton.Branch);
            _branches.Add(smartBackButton.Branch);

            World.Subscribe(EventSubscription.Create <PurchaseInspected>(x => Inspect(), this));
            World.Subscribe(EventSubscription.Create <PurchasesListed>(x => ListPurchases(), this));
            World.Subscribe(EventSubscription.Create <CallResolved>(x => EndCall(), this));
            World.Subscribe(EventSubscription.Create <CallStarted>(x => StartCall(x.Call), this));
        }
        public InGameMenu(ClickUI clickUi)
        {
            _clickUI = clickUi;
            var ctx = new Buttons.MenuContext {
                X = _menuX, Y = _menuY, Width = _menuWidth, FirstButtonYOffset = 50
            };

            var menu = new UiImage
            {
                Transform = new Transform2(new Rectangle(_menuX, _menuY, _menuWidth, _menuHeight)),
                Image     = "UI/menu-wide-panel.png"
            };

            var mainMenuButton  = Buttons.Text(ctx, 4, "Return to Main Menu", () => Scene.NavigateTo("MainMenu"), () => true);
            var characterStatus = Buttons.Text(ctx, 3, "Character Status", () => Event.Publish(new DisplayCharacterStatusRequested(GameWorld.CurrentCharacter)), () => true);

            _visuals.Add(new ColoredRectangle
            {
                Color     = UiColors.InGameMenu_FullScreenRectangle,
                Transform = new Transform2(new Size2(1920, 1080))
            });
            _visuals.Add(menu);
            _visuals.Add(mainMenuButton);
            _visuals.Add(characterStatus);
            _interceptLayer.Add(new ScreenClickable(HideDisplay));
            _branch.Add(mainMenuButton);
            _branch.Add(characterStatus);
            Input.On(Control.Menu, ToggleMenu);
            Event.Subscribe(EventSubscription.Create <MenuRequested>(x => PresentOptions(), this));
            Event.Subscribe(EventSubscription.Create <SubviewRequested>(x => HideDisplay(), this));
            Event.Subscribe(EventSubscription.Create <SubviewDismissed>(x => PresentOptions(), this));
        }
Beispiel #7
0
 public NewPurchaseUI(Size2 size)
 {
     Branch = new ClickUIBranch("Purchase UI", (int)ClickUIPriorities.Pad);
     _grid  = new GridLayout(size - new Size2(Sizes.Margin * 2, Sizes.Margin * 2),
                             new List <Definition>
     {
         new ConcreteDefinition(50),
         new ShareDefintion(),
         new ShareDefintion(),
         new ShareDefintion(),
         new ConcreteDefinition(50)
     },
                             new List <Definition>
     {
         new ShareDefintion(2),
         new ShareDefintion(),
         new ShareDefintion(),
         new ShareDefintion(),
         new ShareDefintion(),
         new ShareDefintion(),
         new ShareDefintion(),
         new ShareDefintion(),
         new ShareDefintion(),
         new ConcreteDefinition(90)
     });
     _viewList = new ViewPurchaseListUI();
     Branch.Add(_viewList.Branch);
     World.Subscribe(EventSubscription.Create <PurchaseInspected>(x => OnPurchaseInspected(x.Purchase), this));
     World.Subscribe(EventSubscription.Create <PurchasesListed>(x => OnPurchasesListed(), this));
 }
Beispiel #8
0
 public CharacterTurns(IReadOnlyList <Character> characters)
 {
     _characters      = characters.OrderByDescending(x => x.Stats.Agility).ToList();
     CurrentCharacter = _characters.First();
     Event.Subscribe(EventSubscription.Create <TurnEnded>(BeginNextTurn, this));
     Event.Subscribe(EventSubscription.Create <CharacterDeceased>(OnCharacterDeath, this));
 }
Beispiel #9
0
 public Landlord(Rent rent, PlayerAccount acct)
 {
     _currentRent    = rent;
     _rentersAccount = acct;
     World.Subscribe(EventSubscription.Create <DayEnded>(IncreaseRent, this));
     World.Subscribe(EventSubscription.Create <RentPaid>(RentPaid, this));
 }
Beispiel #10
0
        public void Init()
        {
            _tooltipLabel = new Label
            {
                Transform           = new Transform2(new Vector2(1270, 124), new Size2(500, 60)),
                BackgroundColor     = Color.Transparent,
                HorizontalAlignment = HorizontalAlignment.Right,
                TextColor           = UiStyle.TextLightPurple
            };

            _confirmationVisuals = new List <IVisual>();
            _confirmationBranch  = new ClickUIBranch("Confirm", 3);
            AddConfirmationButton(UiButtons.MenuRed("Quit", new Vector2(960 - 360 - 100, 500), Confirm));
            AddConfirmationButton(UiButtons.MenuRed("Cancel", new Vector2(960 + 0 + 100, 500), Cancel));
            _confirmationBranch.Add(new ScreenClickable(() => { }));

            _clickables = new List <VisualClickableUIElement>();
            AddIconButton(() => Scene.NavigateTo(GameResources.DilemmasSceneName), "Icons/Dilemmas", "Dilemmas");
            AddIconButton(() => Scene.NavigateTo(GameResources.DialogueMemoriesScene), "Icons/Conversations", "Conversations");
            AddIconButton(() => Scene.NavigateTo(GameResources.OptionsSceneName), "Icons/Options", "Options");
            AddIconButton(() => Scene.NavigateTo(GameResources.SaveLoadSceneName), "Icons/Save", "Save / Load");
            AddIconButton(OpenConfirmationMenu, "Icons/ExitToMenu", "Main Menu");
            HudBranch = new ClickUIBranch("HUD", 2);
            _clickables.ForEach(x => HudBranch.Add(x));
            _newIcon = new ImageBox
            {
                Transform = new Transform2(new Size2(43, 43)),
                Image     = "UI/NewRedIconBorderless"
            };

            Event.SubscribeForever(EventSubscription.Create <ActiveElementChanged>(UpdateTooltip, this));
        }
 public ReturnsCallMessengerUI(Transform2 transform)
 {
     _timer     = new Timer(UpdateMessenger, 1000);
     _transform = transform;
     World.Subscribe(EventSubscription.Create <CallStarted>(x => AddMessages(x.Call.Chat), this));
     World.Subscribe(EventSubscription.Create <CallResolved>(x => Clear(), this));
 }
Beispiel #12
0
        public GameOverMenu(ClickUI clickUi)
        {
            _clickUI = clickUi;
            var ctx = new Buttons.MenuContext {
                X = _menuX, Y = _menuY, Width = _menuWidth, FirstButtonYOffset = 50
            };

            var mainMenuButton = Buttons.Text(ctx, 7, "Return to Main Menu",
                                              () =>
            {
                AudioPlayer.Instance.StopAll();
                Scene.NavigateTo("MainMenu");
            }, () => true);

            _visuals.Add(_black);
            _fade = new ScreenFade
            {
                ToAlpha   = 255,
                FromAlpha = 0,
                Duration  = TimeSpan.FromSeconds(2)
            };
            _visuals.Add(_fade);
            _visuals.Add(new UiImage
            {
                Image     = "UI/game-over.png",
                Transform = new Transform2(new Vector2(0.5.VW() - 329, 0.3.VH()), new Size2(639, 150))
            });

            _visuals.Add(mainMenuButton);
            _interceptLayer.Add(new ScreenClickable(() => { }));
            _branch.Add(mainMenuButton);
            Event.Subscribe(EventSubscription.Create <GameOver>(e => Enable(), this));
        }
Beispiel #13
0
 public PolicyPageUI(ActivePolicies policies, int pagePolicyIndex, int pagePolicyCount)
 {
     _policies        = policies;
     _pagePolicyIndex = pagePolicyIndex;
     _pagePolicyCount = pagePolicyCount;
     UpdatePolicies();
     World.Subscribe(EventSubscription.Create <PoliciesChanged>(x => UpdatePolicies(), this));
 }
Beispiel #14
0
 public CallSummaryUI()
 {
     Transform = new Transform2(new Size2(600, Sizes.Label.Height));
     _label    = new ImageLabel("", "Images/UI/label", Transform);
     World.Subscribe(EventSubscription.Create <CallStarted>(x => OnCallStart(), this));
     World.Subscribe(EventSubscription.Create <CallResolved>(x => OnCallResolved(x.Resolution), this));
     World.Subscribe(EventSubscription.Create <TechnicalMistakeOccurred>(x => OnTechnicalMistake(), this));
 }
Beispiel #15
0
 public ChoicesUI(Transform2 transform)
 {
     Branch    = new ClickUIBranch("Choices", (int)ClickUIPriorities.Pad);
     Transform = transform;
     _grid     = new GridLayout(transform.Size, 3, 1);
     World.Subscribe(EventSubscription.Create <CallStarted>(x => OnCallStart(x.Call), this));
     World.Subscribe(EventSubscription.Create <CallResolved>(x => OnCallResolved(), this));
 }
Beispiel #16
0
 public PlayerEnergy(int energyUsedPerHour, int energyPerHourSlept)
 {
     _energyUsedPerHour  = energyUsedPerHour;
     _energyPerHourSlept = energyPerHourSlept;
     World.Subscribe(EventSubscription.Create <MinuteChanged>(MinuteChanged, this));
     World.Subscribe(EventSubscription.Create <WentToBed>(WentToBed, this));
     World.Subscribe(EventSubscription.Create <EnergyRecovery>(EnergyRecovered, this));
 }
Beispiel #17
0
 public MegaBuyReporting()
 {
     World.Subscribe(EventSubscription.Create <CallRated>(FeedbackReceived, this));
     World.Subscribe(EventSubscription.Create <DayEnded>(SendReport, this));
     World.Subscribe(EventSubscription.Create <CallStarted>(x => _currentCalls++, this));
     World.Subscribe(EventSubscription.Create <AgentCallStatusChanged>(UpdateWorkStatus, this));
     World.Subscribe(EventSubscription.Create <MinuteChanged>(ClockWork, this));
 }
Beispiel #18
0
 private void InitSubscriptions()
 {
     World.Subscribe(EventSubscription.Create <PadOpened>(x => _isPadOpen = true, this));
     World.Subscribe(EventSubscription.Create <PadClosed>(x => _isPadOpen = false, this));
     World.Subscribe(EventSubscription.Create <WentToBed>((e) => WentToBed(), this));
     World.Subscribe(EventSubscription.Create <Awaken>(Awaken, this));
     World.Subscribe(EventSubscription.Create <CollapsedWithExhaustion>((e) => WentToBed(), this));
 }
 public ViewPurchaseListUI()
 {
     Branch  = new ClickUIBranch("View List Button", (int)ClickUIPriorities.Pad);
     _button = ImageTextButtonFactory.Create("Purchases", Vector2.Zero, () => World.Publish(new PurchasesListed()));
     Branch.Add(_button);
     World.Subscribe(EventSubscription.Create <PurchaseInspected>(x => OnPurchaseInspected(), this));
     World.Subscribe(EventSubscription.Create <PurchasesListed>(x => OnPurchasesListed(), this));
 }
Beispiel #20
0
 public Hunger(int hungerPerHour)
 {
     _hungerPerHour = hungerPerHour;
     World.Subscribe(EventSubscription.Create <MinuteChanged>(IncreaseHunger, this));
     World.Subscribe(EventSubscription.Create <FoodEaten>(EatFood, this));
     World.Subscribe(EventSubscription.Create <WentToBed>((w) => _isSleeping = true, this));
     World.Subscribe(EventSubscription.Create <Awaken>((a) => _isSleeping    = false, this));
 }
Beispiel #21
0
        public CallerNameUI()
        {
            var transform = new Transform2(new Size2(250, 50));

            Transform = transform;
            _name     = new ImageLabel("", "Images/UI/call-detail", Transform);
            World.Subscribe(EventSubscription.Create <CallStarted>(x => OnCallStart(x.Call), this));
            World.Subscribe(EventSubscription.Create <CallResolved>(x => OnCallResolved(), this));
        }
Beispiel #22
0
 public TogglePad()
 {
     _open    = ImageTextButtonFactory.CreateTrapazoid("Open", Vector2.Zero, () => World.Publish(new PadOpened()));
     _close   = ImageTextButtonFactory.CreateTrapazoid("Close", Vector2.Zero, () => World.Publish(new PadClosed()));
     Branch   = new ClickUIBranch("Toggle Pad", (int)ClickUIPriorities.Overlay);
     _current = _open;
     Branch.Add(_open);
     World.Subscribe(EventSubscription.Create <PadOpened>(x => PadOpened(), this));
     World.Subscribe(EventSubscription.Create <PadClosed>(x => PadClosed(), this));
 }
Beispiel #23
0
 public MegaBuyEmployment(ActivePolicies policies)
 {
     _policies = policies;
     _job      = Job.ReturnSpecialistLevel1;
     World.Subscribe(EventSubscription.Create <HourChanged>(HourChanged, this));
     World.Subscribe(EventSubscription.Create <CallResolved>(CallResolved, this));
     World.Subscribe(EventSubscription.Create <TechnicalMistakeOccurred>(TechnicalMistakeOccurred, this));
     World.Subscribe(EventSubscription.Create <JobAccepted>(x => AcceptPromotion(x.Job), this));
     World.Subscribe(EventSubscription.Create <JobDeclined>(x => DeclinePromotion(), this));
 }
Beispiel #24
0
 public Call(Chat chat, CallScenario scenario, CallResolution correctResolution, List <ICallOption> options)
 {
     _activePolicies    = CurrentGameState.State.ActivePolicies;
     Chat               = chat;
     Scenario           = scenario;
     _correctResolution = correctResolution;
     Options            = options;
     CurrentScene.Add(this);
     World.Subscribe(EventSubscription.Create <CallResolved>(ResolveCall, this));
 }
Beispiel #25
0
 public CallerUi()
 {
     _info = new Label
     {
         BackgroundColor = Color.Transparent,
         TextColor       = Color.White,
         Transform       = new Transform2(new Vector2(0, 400 + Sizes.Margin), new Size2(250, 260))
     };
     World.Subscribe(EventSubscription.Create <CallStarted>(x => StartCall(x.Call), this));
     World.Subscribe(EventSubscription.Create <CallResolved>(x => EndCall(), this));
 }
Beispiel #26
0
 public Pad(ClickUIBranch parentBranch)
 {
     _branch = new ClickUIBranch("Pad", (int)ClickUIPriorities.Pad);
     parentBranch.Add(_branch);
     _menuBar    = new MenuBar(_branch);
     _currentApp = new NoneApp();
     World.Subscribe(EventSubscription.Create <AppChanged>(x => OpenApp(x.App), this));
     // @todo #1 Fix the state transfer architecture
     OpenApp(App.Notification);
     OpenApp(App.Call);
 }
Beispiel #27
0
 public GameState()
 {
     Event.SubscribeForever(EventSubscription.Create <ItemViewed>(x => ChangeState(() => _viewedItems.Add(x.Item)), this));
     Event.SubscribeForever(EventSubscription.Create <ThoughtGained>(x => ChangeState(() => _thoughts.Add(x.Thought)), this));
     Event.SubscribeForever(EventSubscription.Create <ThoughtLost>(x => ChangeState(() => _thoughts.Remove(x.Thought)), this));
     Event.SubscribeForever(EventSubscription.Create <DialogMemoryGained>(x => ChangeState(() =>
     {
         _viewedItems.Add(x.Dialog);
         _memories.Add(x.Dialog, x.Location);
     }), this));
 }
Beispiel #28
0
 public Caller(Chat chat, string name, int patienceLossRateMs, Dictionary <string, string> traits)
 {
     _chat                       = chat;
     _lastChatMessage            = _chat.Count;
     Traits                      = traits;
     Name                        = name;
     _originalPatienceLossRateMs = patienceLossRateMs;
     ResetPatience();
     World.Subscribe(EventSubscription.Create <SocialMistakeOccurred>(SocialMistakeOccurred, this));
     World.Subscribe(EventSubscription.Create <CallResolved>(x => Dispose(), this));
     World.Subscribe(EventSubscription.Create <CallerHangupFinished>(x => OnCallerHangupFinished(), this));
 }
Beispiel #29
0
        public TurnBasedCombat(GameMap map, IReadOnlyList <Character> characters)
        {
            Map = map;
            if (characters.Any(x => !x.IsInitialized))
            {
                throw new InvalidOperationException("All Characters must be initialized before Level begins.");
            }

            Event.Subscribe(EventSubscription.Create <ActionResolved>(OnActionResolved, this));
            Event.Subscribe(EventSubscription.Create <MovementOptionsAvailable>(x => AvailableMoves = x.AvailableMoves, this));
            Event.Subscribe(EventSubscription.Create <RangedTargetsAvailable>(x => Targets          = x.Targets, this));
        }
 public MegaBuyAccounting(IAccount playerAccount)
 {
     _playerAccount   = playerAccount;
     _currentRate     = new PerCallRate(0);
     _pendingPayments = new List <int>();
     _dayPayment      = new DayPayment();
     World.Subscribe(EventSubscription.Create <HourChanged>(HourChanged, this));
     World.Subscribe(EventSubscription.Create <CallSucceeded>(CallSucceeded, this));
     World.Subscribe(EventSubscription.Create <CallRated>(CallRated, this));
     World.Subscribe(EventSubscription.Create <TechnicalMistakeOccurred>(TechnicalMistakeOccurred, this));
     World.Subscribe(EventSubscription.Create <CallFailed>(CallFailed, this));
     World.Subscribe(EventSubscription.Create <JobChanged>(JobRoleChanged, this));
 }