コード例 #1
0
        public void SetupSeedFilters()
        {
            // Set up the score filter.
            // TODO: Better way of doing this.
            SeedGeneration tomatoSeeds = SeedManager.GetLatestGenerationOfCropType("Tomato");

            tomatoSeeds.ScoreFilter.Add("DistanceFromGoal", -1);
            tomatoSeeds.ScoreFilter.Add("AliveTime", 0.5f);
            tomatoSeeds.ScoreFilter.Add("MaxConcurrentSeenCreatures", 0.1f);
            tomatoSeeds.ScoreFilter.Add("EnemyDamageDealt", 1.5f);
            tomatoSeeds.ScoreFilter.Add("EnemyKills", 2);

            SeedGeneration asparagusSeeds = SeedManager.GetLatestGenerationOfCropType("Asparagus");

            asparagusSeeds.ScoreFilter.Add("DistanceFromGoal", -1);
            asparagusSeeds.ScoreFilter.Add("AliveTime", 2f);
            asparagusSeeds.ScoreFilter.Add("MaxConcurrentSeenCreatures", 0.1f);
            asparagusSeeds.ScoreFilter.Add("EnemyDamageDealt", 1.5f);
            asparagusSeeds.ScoreFilter.Add("FriendlyDamageDealt", -2f);
            asparagusSeeds.ScoreFilter.Add("EnemyKills", 2);
            asparagusSeeds.ScoreFilter.Add("FriendlyKills", -3);
            asparagusSeeds.ScoreFilter.Add("ClosestHit", -4.5f);
            asparagusSeeds.ScoreFilter.Add("BestAngle", 3);
            asparagusSeeds.ScoreFilter.Add("OffMap", -1.5f);
        }
コード例 #2
0
        public void InitialiseFromGeneration(ModalWindowController modalWindowController, ISelectionBar <SeedGeneration> selectionBar, Tooltip tooltip, SeedGeneration seedGeneration)
        {
            // Set the seed generation.
            this.seedGeneration = seedGeneration;

            // Bind the main button to select this generation.
            selectionButton.onClick.AddListener(() => selectionBar.OnButtonSelected(seedGeneration));

            // Bind the filter button to create a new filter window.
            filterButton.onClick.AddListener(() =>
            {
                FilterWindowController filterWindowController = modalWindowController.CreateModalWindow <FilterWindowController>(filterWindowPrefab.gameObject);
                filterWindowController.CreateFrom(modalWindowController, this.seedGeneration);
            });

            // Hide the filter button if the generation is 0, as that's the infinite pool of seeds.
            if (this.seedGeneration.Generation == 0)
            {
                filterButton.gameObject.SetActive(false);
            }

            // Set the tooltip object of anything that needs it.
            foreach (TooltipActivator tooltipActivator in GetComponentsInChildren <TooltipActivator>())
            {
                tooltipActivator.Tooltip = tooltip;
            }

            // Refresh the display.
            Refresh();
        }
コード例 #3
0
        public void AddGeneration(SeedGeneration seedGeneration)
        {
            // If the given generation does not have a display, create one.
            if (!generationsByNumber.TryGetValue(seedGeneration.Generation, out SeedGenerationDisplay seedGenerationDisplay))
            {
                // Create the display object and add it to the list.
                GameObject generationObject = Instantiate(seedGenerationDisplayPrefab.gameObject, generationListPane.transform);

                // Get the generation display component from the created object.
                seedGenerationDisplay = generationObject.GetComponent <SeedGenerationDisplay>();

                // Initialise the display with the generation.
                seedGenerationDisplay.InitialiseFromGeneration(modalWindowController, seedListController, tooltip, seedGeneration);

                // Add the display to the collection.
                generationsByNumber.Add(seedGeneration.Generation, seedGenerationDisplay);

                // In true Unity fashion, the list does not automatically update. I spent an hour and a half on this, and this was the only way I could make it work. Change this at your own risk.
                parentList.enabled = false;
                LayoutRebuilder.ForceRebuildLayoutImmediate(parentList.transform as RectTransform);
                parentList.enabled = true;
            }
            // Otherwise; if the generation exists, just refresh it.
            else
            {
                seedGenerationDisplay.Refresh();
            }
        }
コード例 #4
0
 public void RefreshGeneration(SeedGeneration seedGeneration)
 {
     // If the generation has a display, handle it.
     if (generationsByNumber.TryGetValue(seedGeneration.Generation, out SeedGenerationDisplay seedGenerationDisplay))
     {
         // If the number of seeds within the generation is 0 and the generation isn't the infinite seed pool (generation 0), destroy it.
         if (seedGeneration.Generation != 0 && seedGeneration.Count == 0)
         {
             Destroy(seedGenerationDisplay.gameObject);
             generationsByNumber.Remove(seedGeneration.Generation);
         }
         // Otherwise, just refresh it.
         else
         {
             seedGenerationDisplay.Refresh();
         }
     }
 }
コード例 #5
0
        /// <summary> Initialises the window from the given <paramref name="seedGeneration"/>. </summary>
        /// <param name="modalWindowController"> The modal window controller used to close this window. </param>
        /// <param name="seedGeneration"> The generation to manage. </param>
        public void CreateFrom(ModalWindowController modalWindowController, SeedGeneration seedGeneration)
        {
            // Ensure this window is not being set up twice.
            if (SeedGeneration != null)
            {
                Debug.LogError("Cannot initialise window twice.");
                return;
            }

            // Set the window controller.
            this.modalWindowController = modalWindowController;

            // Set the seed generation.
            SeedGeneration = seedGeneration;

            // Set the title.
            titleText.text = $"{seedGeneration.CropTileName} seed generation {seedGeneration.Generation} filter options";

            // Populate the stat lists.
            availableStatsPane.Populate();
            statValuePane.Populate();
        }