Ejemplo n.º 1
0
 public ProductionOptionItem(string key, string label, AbstractWorker target)
 {
     Key    = key;
     Label  = label;
     Target = target;
     Click  = new CommandHandler <ProductionOptionItem>(vm => vm.Apply());
 }
Ejemplo n.º 2
0
        public AbstractWorkerItemTaskViewModel(AbstractWorker recieveUpdatesFrom, IEnumerable <string> productionOptions)
        {
            recieveUpdatesFrom.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == PropertyName(() => recieveUpdatesFrom.CurrentProduction))
                {
                    Detail = recieveUpdatesFrom.CurrentProduction;
                }
                if (e.PropertyName == PropertyName(() => recieveUpdatesFrom.ProductionCounter))
                {
                    Tokens = MakeTokens(recieveUpdatesFrom.ProductionCounter);
                }
            };

            var lookup = ObjectFactory.ProductionLookup();

            ProductionOptions = productionOptions
                                .Select(key => new ProductionOptionItem(key, lookup.GetLabelFor(key), recieveUpdatesFrom))
                                .Concat(new[] { new ProductionOptionItem(null, "None", recieveUpdatesFrom) })
                                .ToList();

            Label     = lookup.GetLabelFor(recieveUpdatesFrom.ResourceKey);
            Detail    = recieveUpdatesFrom.CurrentProduction;
            SpriteUri = ObjectFactory.AssetName(lookup.GetGlyphKeyFor(recieveUpdatesFrom.ResourceKey));
            Tokens    = MakeTokens(recieveUpdatesFrom.ProductionCounter);
        }
Ejemplo n.º 3
0
        public bool RequirementsMet(Player player, AbstractWorker worker)
        {
            var cost = Settings.cost;

            return(worker.Stamina.Value >= cost.stamina &&
                   player.Gold.Value >= cost.gold &&
                   player.Infamy.Value >= cost.infamy);
        }
Ejemplo n.º 4
0
        private void InvokeMethod(AbstractWorker workerInstance, string workerMethod, object workerMethodParameterValue)
        {
            var method = workerInstance.GetType().GetTypeInfo().DeclaredMethods.FirstOrDefault(f => f.Name == workerMethod);

            if (method == null)
            {
                throw new NotImplementedException($"Method {workerMethod} not found on Worker {workerInstance.GetType().Name}");
            }

            method.Invoke(workerInstance, new[] { workerMethodParameterValue });
        }
Ejemplo n.º 5
0
        public void PlaceWorker(AbstractWorker worker, Job job)
        {
            worker.transform.parent = transform;
            worker.gameObject.SetActive(true);
            worker.transform.localPosition = Vector3.zero;

            jobAssignment = jobAssignmentFactory.Create(job, worker);

            job.TakeCost(player, worker);

            onWorkerPlacement.Invoke();
        }
Ejemplo n.º 6
0
        public void GivePerTurnReward(Player player, AbstractWorker worker)
        {
            var reward      = Settings.reward;
            var stamina     = reward.stamina;
            var gold        = reward.gold;
            var infamy      = reward.infamy;
            var goldPerTurn = reward.goldPerTurn;

            ModifyRewardWithSynergies(worker, ref stamina, ref gold, ref infamy, ref goldPerTurn);

            player.Gold.Value += reward.goldPerTurn;
        }
Ejemplo n.º 7
0
        public void GiveCost(Player player, AbstractWorker worker)
        {
            var cost    = Settings.cost;
            var stamina = cost.stamina;
            var gold    = cost.gold;
            var infamy  = cost.infamy;

            ModifyCostWithSynergies(worker, ref stamina, ref gold, ref infamy);

            worker.Stamina.Value += cost.stamina;
            player.Gold.Value    += cost.gold;
            player.Infamy.Value  += cost.infamy;
        }
Ejemplo n.º 8
0
        private void ModifyCostWithSynergies(AbstractWorker worker, ref int stamina, ref int gold, ref int infamy)
        {
            foreach (var synergy in Settings.synergyModifiers)
            {
                if (worker.workerSettings.type != synergy.type)
                {
                    continue;
                }

                stamina += synergy.cost.stamina;
                gold    += synergy.cost.gold;
                infamy  += synergy.cost.infamy;
            }
        }
Ejemplo n.º 9
0
        private void ModifyRewardWithSynergies(AbstractWorker worker, ref int stamina, ref int gold, ref int infamy, ref int goldPerTurn)
        {
            foreach (var synergy in Settings.synergyModifiers)
            {
                if (worker.workerSettings.type != synergy.type)
                {
                    continue;
                }

                stamina     += synergy.reward.stamina;
                gold        += synergy.reward.gold;
                infamy      += synergy.reward.infamy;
                goldPerTurn += synergy.reward.goldPerTurn;
            }
        }
Ejemplo n.º 10
0
        public JobAssignment(Job job, AbstractWorker worker, EventDirector eventDirector, Player player)
        {
            Job         = job;
            Worker      = worker;
            this.player = player;
            turnCount   = new ReactiveX.ReactiveProperty <int>(0);
            TurnCount   = new ReactiveX.ReadOnlyReactiveProperty <int>(turnCount);

            subscriptions.Add(eventDirector.onSimulateEnd.AsObservable().Subscribe(_ =>
            {
                OnTurnEnd();
            }));

            subscriptions.Add(
                worker.Location.Value.OnCollisionEnter2DAsObservable()
                .Subscribe(CheckTravelerCollision)
                );
        }
Ejemplo n.º 11
0
        public void GiveCollisionReward(Player player, AbstractWorker worker, Traveler traveler)
        {
            var collisionAction = Settings.collisionAction;

            if (!collisionAction.enabled)
            {
                throw new Exception("Do not call this method when the collision action is disabled.");
            }

            var gold = collisionAction.goldReceived + traveler.goldValue;

            if (worker.workerSettings.type == collisionAction.modifierType)
            {
                gold += collisionAction.goldReceivedModifier;
            }

            player.Gold.Value += gold;
        }
Ejemplo n.º 12
0
        public MainWindow()
        {
            InitializeComponent();

            var colony = new Colony();

            StorageContainer.Small().Link(colony);
            StorageContainer.Small().Link(colony);
            StorageContainer.Medium().Link(colony);
            new Habitat().Link(colony);


            //new BasicWorker(colony).Link(colony);
            var abstractWorker = new AbstractWorker(new Domain.State.AbstractWorkerState
            {
                ResourceKey       = "basicworker",
                ProductionOptions = ObjectFactory.ProductionLookup().GetProductionOptionsFor("basicworker").ToList(),
                Sprite            = ObjectFactory.AssetName(ObjectFactory.ProductionLookup().GetGlyphKeyFor("basicworker")),
                SubCategoryKey    = "basicworker"
            }, 10);

            abstractWorker.Link(colony);

            var mine = ObjectFactory.ImprovementFactory().BuildImprovement("basicmine");

            mine.Link(colony);

            colony.GetInventory("stone").Add(50);

            //colony = new Persister().Load("Save.xml");

            ViewModel = new MainWindowViewModel(new ColonyController(colony));

            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Send);
            dispatcherTimer.Tick    += new EventHandler(OnUpdate);
            dispatcherTimer.Interval = timePerFrame;
            dispatcherTimer.Start();
        }
Ejemplo n.º 13
0
        public void Configure(AbstractWorker workerPrefab, BanditWorkerSettings workerSetting, AvailableWorkers availableWorkers, EventDirector eventDirector)
        {
            workerPrefab.gameObject.SetActive(false);
            Worker = Instantiate(workerPrefab);

            Worker.Init(workerSetting, eventDirector);
            workerPrefab.gameObject.SetActive(true);

            Worker.onPlacement.AsObservable().Subscribe(_ =>
            {
                onPlacement.Invoke();
            });

            var onReclamation    = Worker.onReclaimation.AsObservable();
            var onJobComplete    = Worker.onJobAssignmentComplete.AsObservable();
            var onBanditReturned = onReclamation.Merge(onJobComplete);

            onBanditReturned.Subscribe(_ =>
            {
                onReturn.Invoke();
            });

            this.availableWorkers = availableWorkers;
        }
Ejemplo n.º 14
0
 private static void Main()
 {
     _worker = new VkBotWorker(@"bot/vkcache.txt", @"bot/vksub.txt", @"bot/vklang.txt");
     _worker.Work();
 }
Ejemplo n.º 15
0
        public void openRestaurant()
        {
            AbstractWorker worker = (AbstractWorker)this.worker;

            worker.Restaurant.Working = true;
        }
Ejemplo n.º 16
0
        public void closeRestaurant()
        {
            AbstractWorker worker = (AbstractWorker)this.worker;

            worker.Restaurant.Working = false;
        }
Ejemplo n.º 17
0
 private static void Main()
 {
     _worker = new TelegramBotWorker(@"bot/telegramcache.txt", @"bot/telegramsub.txt", @"bot/telegramlang.txt");
     _worker.Work();
 }
Ejemplo n.º 18
0
 protected IEnumerable <AbstractLocation> GetLocations(AbstractWorker worker)
 {
     return(FindObjectsOfType <AbstractLocation>());
 }
Ejemplo n.º 19
0
 public CleanerExtension(AbstractWorker worker)
 {
     this._rooms = 0;
     this.worker = worker;
 }