Example #1
0
    public void Initialize(InvItemData [] shipMods, ShipBase parent)
    {
        ParentShip = parent;
        ShipMods   = new List <ShipMod>();

        //find the active mod
        int activeModIndex = -1;

        for (int i = 0; i < shipMods.Length && i < NumberOfSlots; i++)
        {
            if (shipMods[i] != null && shipMods[i].Item.GetStringAttribute("Equipment Type") == "ActiveShipMod")
            {
                activeModIndex = i;
                string className = shipMods[i].Item.GetStringAttribute("Active Mod Class Name");
                ActiveMod = (ShipMod)System.Activator.CreateInstance(System.Type.GetType(className));
                ActiveMod.Initialize(shipMods[i]);
                ShipMods.Add(ActiveMod);
                Debug.Log("Found ship mod " + ActiveMod.Type);
            }
        }

        //now add the passive mods. this ensures the active mod is always the first one in the list
        for (int i = 0; i < shipMods.Length && i < NumberOfSlots; i++)
        {
            if (shipMods[i] != null && i != activeModIndex)
            {
                ShipModType type = (ShipModType)Enum.Parse(typeof(ShipModType), shipMods[i].Item.GetStringAttribute("Ship Mod Type"));
                ShipMod     mod  = CreateShipModByType(type);
                mod.Initialize(shipMods[i]);
                ShipMods.Add(mod);
                Debug.Log("Found ship mod " + mod.Type);
            }
        }
    }
    //Some structure to hold collections of mods. And a way to access them

    public ModInventory()
    {
        //Allocate memory
        equipedMods   = new Dictionary <ShipModEnum.ModType, ShipMod>();
        availableMods = new Stack <ShipMod>();
        equippedBuffs = new List <BuffMod>();
        ModFactory factory = new ModFactory();

        lootTable = new BuffLootTable();

        //Build initial inventory of core system mods.
        ShipMod movementMod = factory.BuildMod(ShipModEnum.ModType.MovementCore);

        equipedMods.Add(movementMod.ShipModType, movementMod);
        ShipMod boostMod = factory.BuildMod(ShipModEnum.ModType.BoostCore);

        availableMods.Push(boostMod);
        ShipMod dodgeRollMod = factory.BuildMod(ShipModEnum.ModType.DodgeRollCore);

        availableMods.Push(dodgeRollMod);
        ShipMod shootMod = factory.BuildMod(ShipModEnum.ModType.ShooterCore);

        availableMods.Push(shootMod);
        Debug.Log("Available mods size: " + availableMods.Count);

        //Movement Mod must be enabled at start.
        highestUnlockedTier = 1;
    }
Example #3
0
 public Blueprint(ShipMod mod)
     : base(mod.Name, mod.Description)
 {
     Module = mod;
     AddRequirement(Item.Silver, 100);
     AddRequirement(Item.Platinum, 10);
     AddRequirement(Item.Gold, 50);
     AddRequirement(Item.Plutonium, 10);
 }
    public bool IsModEquippedActiveAtTier(ShipModEnum.ModType type, int tierLevel)
    {
        ShipMod checkedType = null;
        bool    found       = equipedMods.TryGetValue(type, out checkedType);

        if (!found)
        {
            return(false);
        }
        else if (checkedType != null)
        {
            return(checkedType.TierLevel <= tierLevel);
        }
        else
        {
            Debug.LogError("Passed type is not equipped. This should not happen...What have you done???");
            return(false);
        }
    }
 public void EquipNextMod(int tier)
 {
     if (tier <= highestUnlockedTier)
     {
         return; //We've been here already, so no new unlock
     }
     //Otherwise:
     highestUnlockedTier = tier;
     if (availableMods.Count != 0)
     {
         ShipMod nextMod = availableMods.Pop();
         Debug.Log("equiping next Mod: " + nextMod.ShipModType.ToString());
         equipedMods.Add(nextMod.ShipModType, nextMod);
     }
     else
     {
         availableBuffsForUserSelection = GenerateBuffOptions(tier);
     }
 }
Example #6
0
    public ShipMod BuildMod(ShipModEnum.ModType type)
    {
        ShipMod newMod = null;

        switch (type)
        {
        case ShipModEnum.ModType.MovementCore:
            newMod = new ShipMod(type, 1);
            break;

        case ShipModEnum.ModType.ShooterCore:
            newMod = new ShipMod(type, 2);
            break;

        case ShipModEnum.ModType.DodgeRollCore:
            newMod = new ShipMod(type, 3);
            break;

        case ShipModEnum.ModType.BoostCore:
            newMod = new ShipMod(type, 4);
            break;
        }
        return(newMod);
    }