public ProductionOptionItem(string key, string label, AbstractWorker target) { Key = key; Label = label; Target = target; Click = new CommandHandler <ProductionOptionItem>(vm => vm.Apply()); }
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); }
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); }
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 }); }
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(); }
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; }
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; }
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; } }
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; } }
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) ); }
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; }
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(); }
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; }
private static void Main() { _worker = new VkBotWorker(@"bot/vkcache.txt", @"bot/vksub.txt", @"bot/vklang.txt"); _worker.Work(); }
public void openRestaurant() { AbstractWorker worker = (AbstractWorker)this.worker; worker.Restaurant.Working = true; }
public void closeRestaurant() { AbstractWorker worker = (AbstractWorker)this.worker; worker.Restaurant.Working = false; }
private static void Main() { _worker = new TelegramBotWorker(@"bot/telegramcache.txt", @"bot/telegramsub.txt", @"bot/telegramlang.txt"); _worker.Work(); }
protected IEnumerable <AbstractLocation> GetLocations(AbstractWorker worker) { return(FindObjectsOfType <AbstractLocation>()); }
public CleanerExtension(AbstractWorker worker) { this._rooms = 0; this.worker = worker; }