Пример #1
0
    public UnitStats RandomlySelectUnit()
    {
        // get number of active unit types remaining
        int numTypes = activeUnitTypes.Count;

        if (numTypes == 0)
        {
            return(null);
            //bad
        }

        int index = UnityEngine.Random.Range(0, numTypes);

        // randomly generate a number between 0 - numTypes

        UnitType unitType = activeUnitTypes.ElementAt(index);


        // fix unitAmounts & types
        int numUnits = activeUnitNumbers.GetNumber(unitType);

        if (numUnits == 1)
        {
            activeUnitTypes.Remove(unitType);
        }

        activeUnitNumbers.Remove(unitType);

        return(UnitStatsFactory.Create(unitType));
    }
Пример #2
0
    private void SetUnitStats()
    {
        UnitStats stats = UnitStatsFactory.Create(type);

        unitStats.text = string.Format("Damage: {0} \nHealth: {1}", stats.attackDamage, stats.health);
    }