void SetupSelectors() { int selectorPositionInList = 1; foreach (KeyValuePair <Enums.Dinos, StreamTexture> n in d.dinoIcons) { // skip if not unlocked the dino yet if (!PlayerStats.Instance.dinosUnlocked.Contains(n.Key)) { continue; } SelectorSprite newSelector = (SelectorSprite)selectorScene.Instance(); newSelector.spriteTexture = n.Value; newSelector.dinoType = n.Key; newSelector.text = selectorPositionInList.ToString(); newSelector.Shortcut = new ShortCut(); newSelector.Shortcut.Shortcut = new InputEventKey(); ((InputEventKey)newSelector.Shortcut.Shortcut).Scancode = ((int)Godot.KeyList.Key0) + (uint)selectorPositionInList; hBox.AddChild(newSelector); selectorPositionInList++; } foreach (KeyValuePair <Enums.SpecialAbilities, StreamTexture> n in d.specialAbilityIcons) { Enums.Dinos associatedDino = d.GetDinoTypeFromAbility(n.Key); // skip if not unlocked the speical for the dino yet or if not unlocked the dino itself if (!PlayerStats.Instance.dinosUnlocked.Contains(associatedDino) || !d.GetDinoInfo(associatedDino).UnlockedSpecial()) { continue; } SelectorSprite newSelector = (SelectorSprite)selectorScene.Instance(); newSelector.isAbilitySelector = true; newSelector.spriteTexture = n.Value; newSelector.abilityType = n.Key; newSelector.dinoType = Enums.Dinos.None; newSelector.abilitySelectorAssociatedDino = associatedDino; newSelector.text = selectorPositionInList.ToString(); newSelector.customScale = new Vector2(0.07f, 0.07f); newSelector.Shortcut = new ShortCut(); newSelector.Shortcut.Shortcut = new InputEventKey(); ((InputEventKey)newSelector.Shortcut.Shortcut).Scancode = ((int)Godot.KeyList.Key0) + (uint)selectorPositionInList; hBox.AddChild(newSelector); selectorPositionInList++; } }
// Instance dino, get variable we want, then remove it public object GetDinoProperty(Enums.Dinos dinoType, string property) { PackedScene DinoScene = dinoList[dinoType]; BaseDino DinoInstance = (BaseDino)DinoScene.Instance(); object DinoProperty = DinoInstance.Get(property); DinoInstance.QueueFree(); return(DinoProperty); }
void UpdateProgressBar(Enums.Dinos dinoType) { progress.Show(); float delay = DinoInfo.Instance.GetDinoTimerDelay(dinoType); tween.InterpolateProperty( progress, "value", 0, 100, delay ); tween.Start(); }
SelectorSprite GetDinoSelectorOrNull(Enums.Dinos dinoType) { foreach (SelectorSprite s in selectorList) { if (!s.isAbilitySelector && s.dinoType == dinoType) { return(s); } } return(null); }
SelectorSprite GetDinoSelector(Enums.Dinos dinoType) { var dinoSelector = GetDinoSelectorOrNull(dinoType); if (dinoSelector == null) { throw new KeyNotFoundException("Couldn't find dino selector for passed in parameter: " + dinoType); } else { return(dinoSelector); } }
void OnDinoDeployed(Enums.Dinos _dinoType) { // only bother if the dino being deployed is our associated ID if (_dinoType != this.dinoType) { return; } float delay = DinoInfo.Instance.GetDinoTimerDelay(dinoType); dinoTimer.Start(delay); UpdateProgressBar(dinoType); }
// returns location of Dino stats save public string GetDinoSaveLocation(Enums.Dinos dinoType) { string dinoNameNoSpaces = EnumUtils.GetDinoName(dinoType).Replace(" ", string.Empty); string userSaveLocation = $"user://{dinoNameNoSpaces}StatsSave.tres"; // make a savefile in the user:// location if none exists yet if (!ResourceLoader.Exists(userSaveLocation)) { string projectStatsLocation = $"res://src/combat/dinos/stats/{dinoNameNoSpaces}.tres"; ResourceSaver.Save(userSaveLocation, ResourceLoader.Load <DinoInfoResource>(projectStatsLocation, null, true)); } return(userSaveLocation); }
public override void _Ready() { if (type == Enums.SpecialAbilities.None) { GD.PushError("DinoProjectile type must be set"); GD.PrintStack(); GetTree().Quit(1); } this.Hide(); Enums.Dinos associatedDino = DinoInfo.Instance.GetDinoTypeFromAbility(this.type); Enums.Biomes currentBiome = CityInfo.Instance.currentCity.biome; isEnhanced = CityInfo.Instance.biomeFavoredDinos[currentBiome].Contains(associatedDino); }
void OnDinoDiedType(Enums.Dinos dino) { // go through each dino and check if we can afford them // if we can afford even one, then we haven't lost yet, and we quit the function // otherwise, if we can't afford any, then set allMoneyExpended to true foreach (Enums.Dinos d in PlayerStats.Instance.dinosUnlocked) { if (DinoInfo.Instance.CanAffordDino(d)) { return; } allMoneyExpended = true; } // note: the logic for numDinosLeft is done in BaseDino.cs so that it happens after the dino fades away }
async void OnDinoDeployed(Enums.Dinos _dinoType) { // only bother if the dino being deployed is our associated ID // and if we're a dino selector if (_dinoType != this.dinoType || isAbilitySelector) { return; } FadeSprite(); c.dinosDeploying.Add(dinoType); // Add to list of dinos just deployed, prevents it from being deployed till cooldown over cooldownTimer.Start(d.GetDinoTimerDelay(dinoType)); await ToSignal(cooldownTimer, "timeout"); c.dinosDeploying.Remove(dinoType); // remove from list, let it be deployed again UnFadeSprite(); }
public void Reset() { CityInfoResource currentCity = CityInfo.Instance.currentCity; selectedDinoType = Enums.Dinos.Mega; dinosDeploying.Clear(); selectorTimerList.Clear(); abilitiesUsed.Clear(); lanesInDanger.Clear(); currentRound = 1; maxRounds = currentCity.rounds; creds = currentCity.roundWinCreditBonus[0]; allMoneyExpended = false; }
// when dinos are spawned/die, check if any associated special abilities should be enabled/disabled void ValidateAbilityStatus(Enums.Dinos dinoType) { // get ability selector for associated dino type // then turn it on/off according var selector = GetAbilitySelectorOrNull(d.dinoTypesAndAbilities[dinoType]); if (selector == null) { return; } if (CombatInfo.Instance.IsAbilityDeployable(dinoType)) { selector.EnableSprite(); } else { selector.DisableSprite(); } }
public bool IsAbilityDeployable(Enums.Dinos dinoType) { DinoInfo d = DinoInfo.Instance; var dinosLeft = GetTree().GetNodesInGroup("dinos"); bool specificDinoTypeLeft = false; foreach (BaseDino baseDino in dinosLeft) { if (baseDino.dinoType == dinoType) { specificDinoTypeLeft = true; } } // check for 3 things // 1. there are dinos of dinoType left that are still alive // 2. user has unlocked the special ability // 3. the associated ability for dinoType has not been used yet return(specificDinoTypeLeft && d.GetDinoInfo(dinoType).UnlockedSpecial() && !abilitiesUsed.Contains(DinoInfo.Instance.dinoTypesAndAbilities[dinoType])); }
public static void publishDinoFullySpawned(Enums.Dinos type) => dinoFullySpawned?.Invoke(type);
public void AddDinoUnlocked(Enums.Dinos dino) { dinosUnlocked.Add(dino); statsResource.SaveResource(); }
void OnDinoDeployed(Enums.Dinos dinos) { UpdateCreds(); }
public float GetDinoTimerDelay(Enums.Dinos dinoType) { return((float)GetDinoProperty(dinoType, "spawnDelay")); }
/////////////////////////////////// public static void publishDinoDeployed(Enums.Dinos type) => dinoDeployed?.Invoke(type);
public bool CanAffordDino(Enums.Dinos type) { return(CombatInfo.Instance.creds >= GetDinoDeployCost(type)); }
public int GetDinoDeployCost(Enums.Dinos type) { UpgradeInfo info = GetDinoInfo(type); return(info.deployCost); }
public UpgradeInfo GetDinoInfo(Enums.Dinos dino) { return(upgradesInfo[dino]); }
void OnDinoDeployed(Enums.Dinos dino) { ValidateAffordStatus(); }
public static void publishDinoDiedType(Enums.Dinos type) => dinoDiedType?.Invoke(type);