Exemplo n.º 1
0
 public void setHull(HullType hullType, Sprite image)
 {
     this.hullType         = hullType;
     hullImage.sprite      = image;
     hullName.text         = hullType.getName();
     hullHealth.text       = "HP: " + hullType.getMaxHealth();
     weaponCount.text      = hullType.getWeaponSlots().ToString();
     armorCount.text       = hullType.getArmorSlots().ToString();
     shieldCount.text      = hullType.getShieldSlots().ToString();
     generatorCount.text   = hullType.getGeneratorSlots().ToString();
     repairDroidCount.text = hullType.getRepairDroidSlots().ToString();
     harvesterCount.text   = hullType.getHarvesterSlots().ToString();
     updateCost();
 }
Exemplo n.º 2
0
    public void initializeRandomShip(HullType initType)
    {
        if (initialized)
        {
            return;
        }

        setHullType(initType, initType.getMaxHealth());

        int generatorSlots = hullType.getGeneratorSlots();
        int harvesterSlots = hullType.getHarvesterSlots();
        int repairDroids   = hullType.getRepairDroidSlots();
        int shieldSlots    = hullType.getShieldSlots();
        int weaponSlots    = hullType.getWeaponSlots();
        int armorSlots     = hullType.getArmorSlots();

        Item radar = null, engine = null, generator_1 = null, generator_2 = null, generator_3 = null,
             harvester_1 = null, harvester_2 = null,
             repairDroid_1 = null, repairDroid_2 = null, repairDroid_3 = null, repairDroid_4 = null,
             shield_1 = null, shield_2 = null, shield_3 = null,
             weapon_1 = null, weapon_2 = null, weapon_3 = null, weapon_4 = null, weapon_5 = null,
             armor_1 = null, armor_2 = null, armor_3 = null, armor_4 = null, armor_5 = null;

        radar  = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        engine = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        if (generatorSlots >= 1)
        {
            generator_1 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (generatorSlots >= 2)
        {
            generator_2 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (generatorSlots >= 3)
        {
            generator_3 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (harvesterSlots >= 1)
        {
            harvester_1 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (harvesterSlots >= 2)
        {
            harvester_2 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (repairDroids >= 1)
        {
            repairDroid_1 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (repairDroids >= 2)
        {
            repairDroid_2 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (repairDroids >= 3)
        {
            repairDroid_3 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (repairDroids >= 4)
        {
            repairDroid_4 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (shieldSlots >= 1)
        {
            shield_1 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (shieldSlots >= 2)
        {
            shield_2 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (shieldSlots >= 3)
        {
            shield_3 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (weaponSlots >= 1)
        {
            weapon_1 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (weaponSlots >= 2)
        {
            weapon_2 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (weaponSlots >= 3)
        {
            weapon_3 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (weaponSlots >= 4)
        {
            weapon_4 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (weaponSlots >= 5)
        {
            weapon_5 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (armorSlots >= 1)
        {
            armor_1 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (armorSlots >= 2)
        {
            armor_2 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (armorSlots >= 3)
        {
            armor_3 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (armorSlots >= 4)
        {
            armor_4 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }
        if (armorSlots >= 5)
        {
            armor_5 = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>();
        }

        getSlot(HullSlot.Type.RADAR, 0).setItem(radar);
        getSlot(HullSlot.Type.ENGINE, 0).setItem(engine);
        if (generatorSlots >= 1)
        {
            getSlot(HullSlot.Type.GENERATOR, 0).setItem(generator_1);
        }
        if (generatorSlots >= 2)
        {
            getSlot(HullSlot.Type.GENERATOR, 1).setItem(generator_2);
        }
        if (generatorSlots >= 3)
        {
            getSlot(HullSlot.Type.GENERATOR, 2).setItem(generator_3);
        }
        if (harvesterSlots >= 1)
        {
            getSlot(HullSlot.Type.HARVESTER, 0).setItem(harvester_1);
        }
        if (harvesterSlots >= 2)
        {
            getSlot(HullSlot.Type.HARVESTER, 1).setItem(harvester_2);
        }
        if (repairDroids >= 1)
        {
            getSlot(HullSlot.Type.REPAIR_DROID, 0).setItem(repairDroid_1);
        }
        if (repairDroids >= 2)
        {
            getSlot(HullSlot.Type.REPAIR_DROID, 1).setItem(repairDroid_2);
        }
        if (repairDroids >= 3)
        {
            getSlot(HullSlot.Type.REPAIR_DROID, 2).setItem(repairDroid_3);
        }
        if (repairDroids >= 4)
        {
            getSlot(HullSlot.Type.REPAIR_DROID, 3).setItem(repairDroid_4);
        }
        if (shieldSlots >= 1)
        {
            getSlot(HullSlot.Type.SHIELD, 0).setItem(shield_1);
        }
        if (shieldSlots >= 2)
        {
            getSlot(HullSlot.Type.SHIELD, 1).setItem(shield_2);
        }
        if (shieldSlots >= 3)
        {
            getSlot(HullSlot.Type.SHIELD, 2).setItem(shield_3);
        }
        if (weaponSlots >= 1)
        {
            getSlot(HullSlot.Type.WEAPON, 0).setItem(weapon_1);
        }
        if (weaponSlots >= 2)
        {
            getSlot(HullSlot.Type.WEAPON, 1).setItem(weapon_2);
        }
        if (weaponSlots >= 3)
        {
            getSlot(HullSlot.Type.WEAPON, 2).setItem(weapon_3);
        }
        if (weaponSlots >= 4)
        {
            getSlot(HullSlot.Type.WEAPON, 3).setItem(weapon_4);
        }
        if (weaponSlots >= 5)
        {
            getSlot(HullSlot.Type.WEAPON, 4).setItem(weapon_5);
        }
        if (armorSlots >= 1)
        {
            getSlot(HullSlot.Type.ARMOR, 0).setItem(armor_1);
        }
        if (armorSlots >= 2)
        {
            getSlot(HullSlot.Type.ARMOR, 1).setItem(armor_2);
        }
        if (armorSlots >= 3)
        {
            getSlot(HullSlot.Type.ARMOR, 2).setItem(armor_3);
        }
        if (armorSlots >= 4)
        {
            getSlot(HullSlot.Type.ARMOR, 3).setItem(armor_4);
        }
        if (armorSlots >= 5)
        {
            getSlot(HullSlot.Type.ARMOR, 4).setItem(armor_5);
        }

        radar.init(ItemFactory.createRadarData());
        engine.init(ItemFactory.createEngineData());
        if (generatorSlots >= 1)
        {
            generator_1.init(ItemFactory.createGeneratorData());
        }
        if (generatorSlots >= 2)
        {
            generator_2.init(ItemFactory.createGeneratorData());
        }
        if (generatorSlots >= 3)
        {
            generator_3.init(ItemFactory.createGeneratorData());
        }
        if (harvesterSlots >= 1)
        {
            harvester_1.init(ItemFactory.createHarvesterData());
        }
        if (harvesterSlots >= 2)
        {
            harvester_2.init(ItemFactory.createHarvesterData());
        }
        if (repairDroids >= 1)
        {
            repairDroid_1.init(ItemFactory.createRepairDroidData());
        }
        if (repairDroids >= 2)
        {
            repairDroid_2.init(ItemFactory.createRepairDroidData());
        }
        if (repairDroids >= 3)
        {
            repairDroid_3.init(ItemFactory.createRepairDroidData());
        }
        if (repairDroids >= 4)
        {
            repairDroid_4.init(ItemFactory.createRepairDroidData());
        }
        if (shieldSlots >= 1)
        {
            shield_1.init(ItemFactory.createShieldData());
        }
        if (shieldSlots >= 2)
        {
            shield_2.init(ItemFactory.createShieldData());
        }
        if (shieldSlots >= 3)
        {
            shield_3.init(ItemFactory.createShieldData());
        }
        if (weaponSlots >= 1)
        {
            weapon_1.init(ItemFactory.createWeaponData());
        }
        if (weaponSlots >= 2)
        {
            weapon_2.init(ItemFactory.createWeaponData());
        }
        if (weaponSlots >= 3)
        {
            weapon_3.init(ItemFactory.createWeaponData());
        }
        if (weaponSlots >= 4)
        {
            weapon_4.init(ItemFactory.createWeaponData());
        }
        if (weaponSlots >= 5)
        {
            weapon_5.init(ItemFactory.createWeaponData());
        }
        if (armorSlots >= 1)
        {
            armor_1.init(ItemFactory.createArmorData());
        }
        if (armorSlots >= 2)
        {
            armor_2.init(ItemFactory.createArmorData());
        }
        if (armorSlots >= 3)
        {
            armor_3.init(ItemFactory.createArmorData());
        }
        if (armorSlots >= 4)
        {
            armor_4.init(ItemFactory.createArmorData());
        }
        if (armorSlots >= 5)
        {
            armor_5.init(ItemFactory.createArmorData());
        }

        arrangeItemsToSlots();

        setCurrentShield(getShield());
        setCurrentHealth(hullType.getMaxHealth());
        calculateRepairCost();

        initialized = true;
    }