Пример #1
0
 /// <summary>
 /// Unit Constructor Class
 /// </summary>
 /// <param name="_unit">Unit type, player or enemy.</param>
 /// <param name="_unitComp">Unit Component attatched to this object.</param>
 /// <param name="_health">Health of the Unit</param>
 /// <param name="_damage">Damage of the Unit</param>
 /// <param name="_intelligence">Intelligence of the unit. Used for deciding if they fall into traps. 0 : none 1: full intelligence</param>
 /// <param name="_helmet"> Helmet Gameobject to spawn on the unit</param>
 /// <param name="_weapon">Weapon Gameobject to spawn on the unit</param>
 public Unit(unitTypes _unit, UnitComponent _unitComp, float _health, float _damage, GameObject _helmet, GameObject _weapon)
 {
     unitType = _unit;
     unitComp = _unitComp;
     health   = _health;
     damage   = _damage;
     helmet   = _helmet;
     weapon   = _weapon;
 }
Пример #2
0
    public void playerUnitConstructor()
    {
        unitTypes  _unitType = unitTypes.player;
        float      _health   = Random.Range(m_lowestHealthPlayer, m_highestHealthPlayer);
        float      _damage   = Random.Range(m_lowestDamagePlayer, m_highestDamagePlayer);
        GameObject _helmet   = m_helmets[Random.Range(0, m_helmets.Count)];
        GameObject _weapon   = m_weapons[Random.Range(0, m_weapons.Count)];

        m_unitBody.material = m_playerMaterials[Random.Range(0, m_playerMaterials.Count)];

        unit = new Unit(_unitType, this, _health, _damage, _helmet, _weapon);
    }
Пример #3
0
    private unitTypes UpgradingUnit = unitTypes.none; // uchovava, ktora jednotka bude upgradovana

    #endregion Fields

    #region Methods

    void OnGUI()
    {
        if(InShop == 0)
        {
            if( GUI.Button(new Rect(10, 10, 80, 30), "Upgrade") )
            {
                InShop = 1;
            }
        }
        else if(InShop == 1)
        {
            if( GUI.Button(new Rect(150, 10, 150, 20), "Upgrade warrior") )
            {
                UpgradingUnit = (unitTypes.warrior);
                InShop = 2;
            }
            if( GUI.Button(new Rect(150, 40, 150, 20), "Upgrade spearman") )
            {
                UpgradingUnit = (unitTypes.spearman);
                InShop = 2;
            }
            if( GUI.Button(new Rect(150, 70, 150, 20), "Upgrade axeman") )
            {
                UpgradingUnit = (unitTypes.axeman);
                InShop = 2;
            }
            if( GUI.Button(new Rect(150, 100, 150, 20), "Upgrade knight") )
            {
                UpgradingUnit = (unitTypes.knight);
                InShop = 2;
            }
            if( GUI.Button(new Rect(150, 130, 150, 20), "Upgrade crossbowman") )
            {
                UpgradingUnit = (unitTypes.crossbowman);
                InShop = 2;
            }
            if( GUI.Button(new Rect(150, 160, 150, 20), "Upgrade bowman") )
            {
                UpgradingUnit = (unitTypes.bowman);
                InShop = 2;
            }
            if( GUI.Button(new Rect(150, 190, 150, 20), "Cancel") )
            {
                InShop = 0;
            }
        }
        else if(InShop == 2)
        {
            if( GUI.Button(new Rect(150, 10, 150, 20), "Max HP") )
            {
                UpgradeUnitStat(unitData.maxHP);
            }
            if( GUI.Button(new Rect(150, 40, 150, 20), "Damage") )
            {
                UpgradeUnitStat(unitData.damage);
            }
            if( GUI.Button(new Rect(150, 70, 150, 20), "Armor") )
            {
                UpgradeUnitStat(unitData.armor);
            }
            if( GUI.Button(new Rect(150, 100, 150, 20), "Attack speed") )
            {
                UpgradeUnitStat(unitData.attackSpeed);
            }
            if( GUI.Button(new Rect(150, 130, 150, 20), "Movement speed") )
            {
                UpgradeUnitStat(unitData.moveSpeed);
            }
            if( GUI.Button(new Rect(150, 160, 150, 20), "Back") )
            {
                InShop = 1;
                UpgradingUnit = unitTypes.none;
            }
        }
    }
Пример #4
0
 private void UpgradeUnitStat(unitData stat)
 {
     UnitUpgrades [(int) UpgradingUnit][(int)stat] *= (float) 1.25;
     InShop = 0;
     UpgradingUnit = unitTypes.none;
 }