Esempio n. 1
0
    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++;
        }
    }
Esempio n. 2
0
    // 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);
    }
Esempio n. 3
0
    void UpdateProgressBar(Enums.Dinos dinoType)
    {
        progress.Show();

        float delay = DinoInfo.Instance.GetDinoTimerDelay(dinoType);

        tween.InterpolateProperty(
            progress, "value", 0, 100, delay
            );
        tween.Start();
    }
Esempio n. 4
0
 SelectorSprite GetDinoSelectorOrNull(Enums.Dinos dinoType)
 {
     foreach (SelectorSprite s in selectorList)
     {
         if (!s.isAbilitySelector && s.dinoType == dinoType)
         {
             return(s);
         }
     }
     return(null);
 }
Esempio n. 5
0
    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);
        }
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
    // 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);
    }
Esempio n. 8
0
    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);
    }
Esempio n. 9
0
    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
    }
Esempio n. 10
0
    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();
    }
Esempio n. 11
0
    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;
    }
Esempio n. 12
0
    // 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();
        }
    }
Esempio n. 13
0
    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]));
    }
Esempio n. 14
0
 public static void publishDinoFullySpawned(Enums.Dinos type) => dinoFullySpawned?.Invoke(type);
Esempio n. 15
0
 public void AddDinoUnlocked(Enums.Dinos dino)
 {
     dinosUnlocked.Add(dino);
     statsResource.SaveResource();
 }
Esempio n. 16
0
 void OnDinoDeployed(Enums.Dinos dinos)
 {
     UpdateCreds();
 }
Esempio n. 17
0
 public float GetDinoTimerDelay(Enums.Dinos dinoType)
 {
     return((float)GetDinoProperty(dinoType, "spawnDelay"));
 }
Esempio n. 18
0
    ///////////////////////////////////

    public static void publishDinoDeployed(Enums.Dinos type) => dinoDeployed?.Invoke(type);
Esempio n. 19
0
 public bool CanAffordDino(Enums.Dinos type)
 {
     return(CombatInfo.Instance.creds >= GetDinoDeployCost(type));
 }
Esempio n. 20
0
    public int GetDinoDeployCost(Enums.Dinos type)
    {
        UpgradeInfo info = GetDinoInfo(type);

        return(info.deployCost);
    }
Esempio n. 21
0
 public UpgradeInfo GetDinoInfo(Enums.Dinos dino)
 {
     return(upgradesInfo[dino]);
 }
Esempio n. 22
0
 void OnDinoDeployed(Enums.Dinos dino)
 {
     ValidateAffordStatus();
 }
Esempio n. 23
0
 public static void publishDinoDiedType(Enums.Dinos type) => dinoDiedType?.Invoke(type);