Exemple #1
0
 public void AddResearchOption(ResearchOption option)
 {
     _all.Add(option);
     option.Init();
     OnResearchAdded?.Invoke(option);
     Message.Send($"New research option {option.Name}' available.", Message.Type.Minor);
 }
Exemple #2
0
        public void CancelResearch(ResearchOption option)
        {
            _inProgress.Remove(option);
            option.OnCompleted -= ResearchCompleted;

            _resourceContainer.AddResources(option.ResourceCost);
            OnResearchCancelled?.Invoke(option);
        }
Exemple #3
0
        private void ResearchCompleted(ResearchOption option)
        {
            _completed.Add(option);
            _inProgress.Remove(option);

            option.OnUniquePrerequisiteCompleted -= ResearchCompleted;
            Message.Send($"Research '{option.Name}' completed.", Message.Type.Minor);

            OnResearchCompleted?.Invoke(option);
        }
Exemple #4
0
        public void BeginResearch(ResearchOption option)
        {
            if (_resourceContainer.TrySpend(option.ResourceCost))
            {
                option.OnCompleted += ResearchCompleted;
                _inProgress.Add(option);

                option.BeginResearch();
                OnResearchBegun?.Invoke(option);
            }
        }
Exemple #5
0
 private bool PrerequisitesCompleted(ResearchOption option)
 {
     return(option.PrerequisiteIdentifiers.All(x => _completed.Exists(y => y.Identifier == x)));
 }
Exemple #6
0
 private void ResearchProgressed(ResearchOption option)
 {
     OnResearchProgressed?.Invoke(option);
 }