void ConfigureExplorationBar(CityBuildingModel model) { if (model.IsExplored) { ExploredBar.MaxValue = Mathf.Max(model.RequiredExploreStages, 1); ExploredBar.Value = Mathf.Max(model.StagesExplored, 1); } else { ExploredBar.MaxValue = model.RequiredExploreStages; ExploredBar.Value = model.StagesExplored; if (model.AssignedSurvivors.Count > 0) { ExploredBar.PreviewValue = model.AssignedSurvivors.Count; } else { ExploredBar.PreviewValue = 0; } } ExploredBar.ForceUpdate(); SecuredText.gameObject.SetActive(model.IsExplored); }
void OnZoomToTarget(ZoomToTargetEvent e) { if (e.Survivor != null) { CityBuildingModel target = e.Survivor.AssignedBuilding != null ? e.Survivor.AssignedBuilding : CityBuildingModel.CurrentBase; animationTarget = target.transform; } }
void DropOnBuilding() { CityBuildingModel hoveredBuilding = CityRaycaster.GetHoveredBuilding(); if (hoveredBuilding != null && !(hoveredBuilding.IsExplored && !hoveredBuilding.OccupiableAfterSecuring)) { Model.AssignToBuilding(hoveredBuilding); UpdateView(); } }
void ConfigureDangerText(CityBuildingModel model) { if (model.IsExplored) { DangerLabel.text = "-"; return; } DangerLabel.text = GetLimitString(model.GetDangerLevel(), DANGER_LIMITS); }
private void Awake() { LinkedModel = GetComponent <CityBuildingModel>(); AssignedSurvivorsParent = Instantiate(PrefabDictionary.Singleton.SurvivorAssignParentPrefab, UIManager.Singleton.SurvivorAssignParent).transform; AssignedSurvivorsParent.GetComponent <SurvivorAssignmentParent>().CityBuilding = this; EventSystem.Subscribe <CityBuildingHoverEvent>(OnCityBuildingHovered, this); UpdateOutlineColor(false); }
void OnCityBuildingHovered(CityBuildingHoverEvent e) { if (currentModel == null) { return; } CityBuildingModel cityBuilding = e.Building; if (cityBuilding == null) { cityBuilding = currentModel.AssignedBuilding; } ConfigureAndShowForModel(currentModel, cityBuilding); }
public void InitialiseNew() { List <CityBuildingModel> createdModels = new List <CityBuildingModel>(); foreach (CityBuildingSpawnSlot spawnSlot in SpawnSlots) { CityBuildingModel model = Instantiate(PrefabDictionary.GetRandomBuildingModelForSpawnSlot(spawnSlot).gameObject, transform).GetComponent <CityBuildingModel>(); model.RandomizeProperties(); model.RandomizeDanger(); model.transform.position = model.Location = spawnSlot.transform.position; model.transform.rotation = model.Rotation = spawnSlot.transform.rotation; createdModels.Add(model); } BuildingModels = createdModels.ToArray(); }
void ConfigureForBuilding(CityBuildingModel model) { currentModel = model; if (model == null) { Fader.FadeOut(); return; } Title.text = model.Name; ConfigureDangerText(model); ConfigureFoodText(model); ConfigureMaterialsText(model); ConfigureExplorationBar(model); Fader.FadeIn(); }
void ConfigureAndShowForModel(SurvivorModel model, CityBuildingModel building) { currentModel = model; CityBuildingStatModifiers statModifiers = new CityBuildingStatModifiers(); if (building == null) { statModifiers = CityBuildingModel.CurrentBase.StatModifiers; } else if (!building.IsExplored) { statModifiers = CityBuildingModel.ScavengingModifiers; } else if (building.IsExplored) { statModifiers = building.StatModifiers; } SurvivorName.text = model.Name; ShootingBar.ConfigureForModel(model, model.ShootingSkill, statModifiers.ShootingChange); FitnessBar.ConfigureForModel(model, model.FitnessSkill, statModifiers.FitnessChange); StrengthBar.ConfigureForModel(model, model.StrengthSkill, statModifiers.StrengthChange); HungerBar.MaxValue = SurvivorModel.MAX_HUNGER; HungerBar.Value = model.Hunger; HungerBar.PreviewValue = 1; HungerBar.ForceUpdate(); TirednessBar.MaxValue = SurvivorModel.MAX_TIREDNESS; TirednessBar.Value = Mathf.Min(model.Tiredness, model.Tiredness + statModifiers.TirednessChange); TirednessBar.PreviewValue = Mathf.Abs(statModifiers.TirednessChange); TirednessBar.ForceUpdate(); Fader.FadeIn(); }
public CityBuildingHoverEvent(CityBuildingModel building) { Building = building; }
public SurvivorAssignmentUpdatedEvent(SurvivorModel survivorModel, CityBuildingModel cityBuilding, bool added) { SurvivorModel = survivorModel; CityBuilding = cityBuilding; Added = added; }
void ConfigureMaterialsText(CityBuildingModel model) { BuildingResourcesLabel.text = GetLimitString(model.GetBuildingMaterialsRemaining(), RESOURCE_LIMITS); }
void ConfigureFoodText(CityBuildingModel model) { FoodLabel.text = GetLimitString(model.GetFoodRemaining(), RESOURCE_LIMITS); }
private void Awake() { EventSystem.Subscribe((NewGameEvent e) => { currentModel = null; }, this); EventSystem.Subscribe<CityBuildingHoverEvent>(OnCityBuildingHovered, this); EventSystem.Subscribe<SurvivorAssignmentUpdatedEvent>(OnSurvivorAssignmentUpdated, this); }