コード例 #1
0
    private void spawnPlayerEntity(int iEntityType, bool isPlayer)
    {
        Vector3 pos;
        float   targetPos;

        if (isPlayer)
        {
            pos       = playerSpawnPointTran.position;
            targetPos = enemySpawnPointTran.position.x;
        }
        else
        {
            pos       = enemySpawnPointTran.position;
            targetPos = playerSpawnPointTran.position.x;
        }

        int           unitIndex     = getUnitIndex(iEntityType);
        GameObject    entity        = Instantiate(unitObjs[unitIndex], pos, Quaternion.identity);
        Unit          unitScript    = entity.AddComponent <Unit>();
        UnitTypeStats unitTypeStats = upgradesScript.returnUnitStats(isPlayer, iEntityType);

        unitScript.setUnitAttributes(unitTypeStats.getHealth(), unitTypeStats.getMinDamage(), unitTypeStats.getMaxDamage(), unitTypeStats.getDamageDelay(), unitTypeStats.getRange(), unitTypeStats.getSpeed());
        unitScript.setUnit(targetPos, isPlayer, iEntityType, getID(isPlayer));
        gameManager.addToArmy(unitScript, isPlayer, entity);
    }
コード例 #2
0
ファイル: Upgrades.cs プロジェクト: owenwould/PortfolioGame
    private void setMediumUnit()
    {
        UnitTypeStats medium = new UnitTypeStats(constants.MEDIUM_HEALTH, constants.MEDIUM_MIN_DAMAGE,
                                                 constants.MEDIUM_MAX_DAMAGE, constants.MEDIUM_DAMAGE_DELAY, constants.MEDIUM_RANGE, constants.MEDIUM_SPEED);

        UnitTypeStats mediumEnemy = new UnitTypeStats(constants.MEDIUM_HEALTH, constants.MEDIUM_MIN_DAMAGE,
                                                      constants.MEDIUM_MAX_DAMAGE, constants.MEDIUM_DAMAGE_DELAY, constants.MEDIUM_RANGE, constants.MEDIUM_SPEED);

        playerUnitStats.Add(constants.MEDIUM_UNIT_TYPE, medium);
        enemyUnitStats.Add(constants.MEDIUM_UNIT_TYPE, mediumEnemy);
    }
コード例 #3
0
ファイル: Upgrades.cs プロジェクト: owenwould/PortfolioGame
    private void setRangedUnit()
    {
        UnitTypeStats range = new UnitTypeStats(constants.RANGED_HEALTH, constants.RANGED_MIN_DAMAGE,
                                                constants.RANGED_MAX_DAMAGE, constants.RANGED_DAMAGE_DELAY, constants.RANGED_RANGE, constants.RANGED_SPEED);

        UnitTypeStats rangeEnemy = new UnitTypeStats(constants.RANGED_HEALTH, constants.RANGED_MIN_DAMAGE,
                                                     constants.RANGED_MAX_DAMAGE, constants.RANGED_DAMAGE_DELAY, constants.RANGED_RANGE, constants.RANGED_SPEED);

        playerUnitStats.Add(constants.RANGED_UNIT_TYPE, range);
        enemyUnitStats.Add(constants.RANGED_UNIT_TYPE, rangeEnemy);
    }
コード例 #4
0
ファイル: Upgrades.cs プロジェクト: owenwould/PortfolioGame
    private void setHeavyUnit()
    {
        //Never use the same object in both dictionaries - they share the same memory address and will both update together
        UnitTypeStats heavy = new UnitTypeStats(constants.HEAVY_HEALTH, constants.HEAVY_MIN_DAMAGE,
                                                constants.HEAVY_MAX_DAMAGE, constants.HEAVY_DAMAGE_DELAY, constants.HEAVY_RANGE, constants.HEAVY_SPEED);

        UnitTypeStats heavyEnemy = new UnitTypeStats(constants.HEAVY_HEALTH, constants.HEAVY_MIN_DAMAGE,
                                                     constants.HEAVY_MAX_DAMAGE, constants.HEAVY_DAMAGE_DELAY, constants.HEAVY_RANGE, constants.HEAVY_SPEED);

        playerUnitStats.Add(constants.HEAVY_UNIT_TYPE, heavy);
        enemyUnitStats.Add(constants.HEAVY_UNIT_TYPE, heavyEnemy);
    }
コード例 #5
0
ファイル: Upgrades.cs プロジェクト: owenwould/PortfolioGame
    private void setLightUnit()
    {
        //Light - damage/health
        UnitTypeStats light = new UnitTypeStats(constants.LIGHT_HEALTH,
                                                constants.LIGHT_MIN_DAMAGE, constants.LIGHT_MAX_DAMAGE, constants.LIGHT_DAMAGE_DELAY,
                                                constants.LIGHT_RANGE, constants.LIGHT_SPEED);

        UnitTypeStats lightEnemy = new UnitTypeStats(constants.LIGHT_HEALTH,
                                                     constants.LIGHT_MIN_DAMAGE, constants.LIGHT_MAX_DAMAGE, constants.LIGHT_DAMAGE_DELAY,
                                                     constants.LIGHT_RANGE, constants.LIGHT_SPEED);

        playerUnitStats.Add(constants.LIGHT_UNIT_TYPE, light);
        enemyUnitStats.Add(constants.LIGHT_UNIT_TYPE, lightEnemy);
    }