public ActionResult Index(EnginesModel model)
        {
            model = model ?? new EnginesModel();

            if (!string.IsNullOrEmpty(model.UploadName) && model.upload != null)
            {
                model.Message = UploadEngine(model.UploadName, model.UploadPlatforms);
            }

            var defaultPlatform = EnginePlatforms[0];

            var winBasePath = Path.Combine(Server.MapPath("~"), "engine", defaultPlatform);
            if (!Directory.Exists(winBasePath)) Directory.CreateDirectory(winBasePath);

            var items = new List<EngineItem>();
            foreach (var name in new DirectoryInfo(winBasePath).GetFiles().Select(x => x.Name).Select(Path.GetFileNameWithoutExtension))
            {
                var item = new EngineItem() { Name = name, Platforms = new List<string>() { defaultPlatform }, IsDefault = name == MiscVar.DefaultEngine};

                foreach (var p in EnginePlatforms.Where(x => x != defaultPlatform))
                {
                    if (System.IO.File.Exists(Path.Combine(Server.MapPath("~"), "engine", p, $"{name}.zip"))) item.Platforms.Add(p);
                }
                items.Add(item);
            }

            if (model.SearchName != null) items = items.Where(x => x.Name.Contains(model.SearchName)).ToList();

            model.Data = items.OrderByDescending(x => x.Name).AsQueryable();

            return View("EnginesIndex", model);
        }
Example #2
0
 public static ItemAbstract newItem(string type, int tier)
 {
     if (WeaponItem.isWeaponType(type))
     {
         return(new WeaponItem(type, tier));
     }
     else if (EngineItem.isEngineType(type))
     {
         return(new EngineItem(type, tier));
     }
     return(new WeaponItem(WeaponItem.WeaponType.Error, 0));
 }
Example #3
0
 public void reloadItems()
 {
     print(engines + " " + weapons + " " + engineBlueprints + " " + weaponBlueprints);
     inventoryDisplay.GetComponent <ItemListHandler>().removeAllItems();
     foreach (string key in inventory.Keys)
     {
         if (inventory[key] <= 0)
         {
             continue;
         }
         ItemAbstract item = ItemDefinitions.stringToItem(key);
         print(key + "->" + item.getType() + ":" + item.getTier());
         if (item.getType() == "Error")
         {
             continue;
         }
         if (WeaponItem.isWeaponType(item.getType()))
         {
             if (item.getTier() < 4)
             {
                 if (weapons)
                 {
                     addNumItems(item, inventory[key]);
                 }
             }
             else
             {
                 if (weaponBlueprints)
                 {
                     addNumItems(item, inventory[key]);
                 }
             }
         }
         else if (EngineItem.isEngineType(item.getType()))
         {
             if (item.getTier() < 4)
             {
                 if (engines)
                 {
                     addNumItems(item, inventory[key]);
                 }
             }
             else
             {
                 if (engineBlueprints)
                 {
                     addNumItems(item, inventory[key]);
                 }
             }
         }
     }
 }
        public ActionResult Index(EnginesModel model)
        {
            model = model ?? new EnginesModel();

            if (!string.IsNullOrEmpty(model.UploadName) && model.upload != null)
            {
                model.Message = UploadEngine(model.UploadName, model.UploadPlatforms);
            }

            var defaultPlatform = EnginePlatforms[0];

            var winBasePath = Path.Combine(Server.MapPath("~"), "engine", defaultPlatform);

            if (!Directory.Exists(winBasePath))
            {
                Directory.CreateDirectory(winBasePath);
            }

            var items = new List <EngineItem>();

            foreach (var name in new DirectoryInfo(winBasePath).GetFiles().Select(x => x.Name).Select(Path.GetFileNameWithoutExtension))
            {
                var item = new EngineItem()
                {
                    Name = name, Platforms = new List <string>()
                    {
                        defaultPlatform
                    }, IsDefault = name == MiscVar.DefaultEngine
                };

                foreach (var p in EnginePlatforms.Where(x => x != defaultPlatform))
                {
                    if (System.IO.File.Exists(Path.Combine(Server.MapPath("~"), "engine", p, $"{name}.zip")))
                    {
                        item.Platforms.Add(p);
                    }
                }
                items.Add(item);
            }

            if (model.SearchName != null)
            {
                items = items.Where(x => x.Name.Contains(model.SearchName)).ToList();
            }

            model.Data = items.OrderByDescending(x => x.Name).AsQueryable();

            return(View("EnginesIndex", model));
        }
Example #5
0
 public static ItemAbstract intToItem(int index)
 {
     if (index < WeaponItem.numWeaponTypes)
     {
         if (index == 0)
         {
             return(new WeaponItem(WeaponItem.WeaponType.Error));
         }
         WeaponItem item;
         try
         {
             WeaponItem.WeaponType type = (WeaponItem.WeaponType)Enum.Parse(typeof(WeaponItem.WeaponType),
                                                                            (index / 6).ToString());
             int tier = index % 6 + 1;
             item = new WeaponItem(type, tier);
         }
         catch (ArgumentException err)
         {
             item = new WeaponItem(WeaponItem.WeaponType.Error);
         }
         return(item);
     }
     else if (index <= WeaponItem.numWeaponTypes + EngineItem.numEngineTypes)
     {
         index -= WeaponItem.numWeaponTypes;
         if (index == 0)
         {
             return(new EngineItem(EngineItem.EngineType.Error));
         }
         EngineItem item;
         try
         {
             EngineItem.EngineType type = (EngineItem.EngineType)Enum.Parse(typeof(EngineItem.EngineType),
                                                                            (index / 6).ToString());
             int tier = index % 6 + 1;
             item = new EngineItem(type, tier);
         }
         catch (ArgumentException err)
         {
             item = new EngineItem(EngineItem.EngineType.Error);
         }
         return(item);
     }
     return(new WeaponItem(WeaponItem.WeaponType.Error));
 }
Example #6
0
 // used for indexing item quantities
 public static int itemToInt(ItemAbstract item)
 {
     if (WeaponItem.isWeaponType(item.getType()))
     {
         WeaponItem itemW = (WeaponItem)item;
         if (itemW.type == WeaponItem.WeaponType.Error)
         {
             return(0);
         }
         return((6 * (int)itemW.type) - 5 + itemW.tier);
     }
     else if (EngineItem.isEngineType(item.getType()))
     {
         EngineItem itemE = (EngineItem)item;
         if (itemE.type == EngineItem.EngineType.Error)
         {
             return(0);
         }
         return((6 * (int)itemE.type) - 5 + itemE.tier + WeaponItem.numWeaponTypes);
     }
     return(0);
 }
Example #7
0
    public void applyBuff(ItemAbstract item)
    {
        if (!EngineItem.isEngineType(item.getType()))
        {
            return;
        }

        EngineItem itemE = (EngineItem)item;

        switch (itemE.type)
        {
        case EngineItem.EngineType.Spinjet:
            break;

        case EngineItem.EngineType.Standard:
            break;

        case EngineItem.EngineType.Thruster:
            break;
        }
        //process item
    }
        private void AddDetailItem(Detail detail, Spaceship spaceship, int level = 1, bool isBody = true)
        {
            DetailItem newItem = new DetailItem(detail, level);

            if (detail is Engine engine)
            {
                newItem = new EngineItem(engine, level);
            }
            else if (detail is Tank tank)
            {
                newItem = new TankItem(tank, level);
            }
            newItem.detachButton.Click += (o, e) => { world.Detach(detail); UpdateList(); };
            if (isBody)
            {
                newItem.detachButton.Dispose();
            }
            layoutFlowPanel.Controls.Add(newItem);
            foreach (Detail child in detail.Children)
            {
                AddDetailItem(child, spaceship, level + 1, false);
            }
        }
Example #9
0
    // Use this for initialization
    void Start()
    {
        //Camera camera = Camera.main;
        //camera.orthographicSize = 640 / Screen.width * Screen.height / 2;
        if (shipName == "")
        {
            shipName = ShipDefinitions.generateName();
        }
        GameObject parent = GameObject.Find("GameLogic").GetComponent <PrefabHost>().getEmptyObject();

        this.health = GameObject.Find("GameLogic").GetComponent <PrefabHost>().getHealthObject();
        this.ammo   = GameObject.Find("GameLogic").GetComponent <PrefabHost>().getAmmoObject();
        this.text   = GameObject.Find("GameLogic").GetComponent <PrefabHost>().getLabelObject();
        health.transform.SetParent(parent.transform);
        ammo.transform.SetParent(parent.transform);
        text.transform.SetParent(parent.transform);
        transform.SetParent(parent.transform);
        text.GetComponent <ShipLabel>().setText(shipName);
        health.GetComponent <HealthBar>().setTarget(gameObject);
        ammo.GetComponent <AmmoBar>().setTarget(gameObject);
        text.GetComponent <ShipLabel>().setTarget(gameObject);
        if (inventory == null)
        {
            inventory = new List <ItemAbstract>();
        }
        GameObject engineObj;

        if (engType == ShipDefinitions.EngineType.Engine1)
        {
            engineObj = GameObject.Find("GameLogic").GetComponent <PrefabHost>()
                        .getEngineLvl1Object();
        }
        else
        {
            engineObj = GameObject.Find("GameLogic").GetComponent <PrefabHost>()
                        .getEngineLvl2Object();
        }
        engineObj.transform.parent     = gameObject.transform;
        engineObj.transform.position   = gameObject.transform.position;
        engineObj.transform.localScale = new Vector3(1.5f, 1.5f, 0);

        engine = engineObj.GetComponent <EngineModule>();
        switch (weapType)
        {
        case ShipDefinitions.WeaponType.Crown:
            weapon = gameObject.AddComponent <CrownMod>();
            break;

        case ShipDefinitions.WeaponType.Laser:
            weapon = gameObject.AddComponent <PewPewLaserMod>();
            break;

        case ShipDefinitions.WeaponType.Missile:
            weapon = gameObject.AddComponent <MissileMod>();
            break;

        case ShipDefinitions.WeaponType.Flame:
            weapon = gameObject.AddComponent <FlameMod>();
            break;

        default:
            weapon = gameObject.AddComponent <DummyFiringMod>();
            break;
        }

        foreach (ItemAbstract item in inventory)
        {
            if (WeaponItem.isWeaponType(item.getType()))
            {
                weapon.applyBuff(item);
            }
            else if (EngineItem.isEngineType(item.getType()))
            {
                engine.applyBuff(item);
            }
        }

        ShipDefinitions.Faction faction = ShipDefinitions.stringToFaction(gameObject.tag);
        if (faction == ShipDefinitions.Faction.Enemy)
        {
            if (shipType == ShipDefinitions.ShipType.Ruby)
            {
                SpriteRenderer spr = gameObject.GetComponent <SpriteRenderer>();
                if (spr == null)
                {
                    spr = gameObject.AddComponent <SpriteRenderer>();
                }
                spr.sprite = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                             shipRubyPirateSprite;
                gameObject.AddComponent <Animator>().runtimeAnimatorController
                    = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                      shipRubyPirateAnimator;
            }
            else
            {
                SpriteRenderer spr = gameObject.GetComponent <SpriteRenderer>();
                if (spr == null)
                {
                    spr = gameObject.AddComponent <SpriteRenderer>();
                }
                spr.sprite = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                             shipPeacockPirateSprite;
                gameObject.AddComponent <Animator>().runtimeAnimatorController
                    = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                      shipPeacockPirateAnimator;
            }
        }
        else
        {
            if (shipType == ShipDefinitions.ShipType.Ruby)
            {
                SpriteRenderer spr = gameObject.GetComponent <SpriteRenderer>();
                if (spr == null)
                {
                    spr = gameObject.AddComponent <SpriteRenderer>();
                }
                spr.sprite = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                             shipRubySprite;
                gameObject.AddComponent <Animator>().runtimeAnimatorController
                    = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                      shipRubyAnimator;
            }
            else
            {
                SpriteRenderer spr = gameObject.GetComponent <SpriteRenderer>();
                if (spr == null)
                {
                    spr = gameObject.AddComponent <SpriteRenderer>();
                }
                spr.sprite = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                             shipPeacockSprite;
                gameObject.AddComponent <Animator>().runtimeAnimatorController
                    = GameObject.Find("GameLogic").GetComponent <PrefabHost>().
                      shipPeacockAnimator;
            }
        }

        gameObject.AddComponent <BoxCollider2D>();
        gameObject.GetComponent <BoxCollider2D>().isTrigger = true;

        //string id = shipName.Substring(shipName.Length - 4);
        parent.name     = "Parent-" + shipName;
        gameObject.name = "Ship-" + shipName;
        health.name     = "Health-" + shipName;
        ammo.name       = "Ammo-" + shipName;
        text.name       = "Text-" + shipName;
        initialized     = true;
    }
Example #10
0
    // getImage will return the appropriate icon for a given item
    public Sprite getImage(ItemAbstract item)
    {
        Sprite img = defaultSprite;

        if (WeaponItem.isWeaponType(item.getType()))
        {
            WeaponItem itemW = (WeaponItem)item;
            if (itemW.type == WeaponItem.WeaponType.FlameModAmmoCap ||
                itemW.type == WeaponItem.WeaponType.FlameModDamage ||
                itemW.type == WeaponItem.WeaponType.FlameModFireRate ||
                itemW.type == WeaponItem.WeaponType.FlameModRange ||
                itemW.type == WeaponItem.WeaponType.FlameModRechargeRate ||
                itemW.type == WeaponItem.WeaponType.FlameModSpeed ||
                itemW.type == WeaponItem.WeaponType.FlameModSpread ||
                itemW.type == WeaponItem.WeaponType.FlameModFireRate ||
                itemW.type == WeaponItem.WeaponType.FlameModRange ||
                itemW.type == WeaponItem.WeaponType.FlameModRechargeRate ||
                itemW.type == WeaponItem.WeaponType.FlameModSpeed ||
                itemW.type == WeaponItem.WeaponType.FlameModSpread)
            {
                switch (itemW.tier)
                {
                case 1:
                    img = fireSpriteLvl1;
                    break;

                case 2:
                    img = fireSpriteLvl2;
                    break;

                case 3:
                    img = fireSpriteLvl3;
                    break;

                case 4:
                    img = blueprintFireSpriteLvl1;
                    break;

                case 5:
                    img = blueprintFireSpriteLvl2;
                    break;

                case 6:
                    img = blueprintFireSpriteLvl3;
                    break;
                }
            }
            else if (itemW.type == WeaponItem.WeaponType.LaserModAmmoCap ||
                     itemW.type == WeaponItem.WeaponType.LaserModDamage ||
                     itemW.type == WeaponItem.WeaponType.LaserModFireRate ||
                     itemW.type == WeaponItem.WeaponType.LaserModRange ||
                     itemW.type == WeaponItem.WeaponType.LaserModRechargeRate ||
                     itemW.type == WeaponItem.WeaponType.LaserModSpeed)
            {
                switch (itemW.tier)
                {
                case 1:
                    img = laserSpriteLvl1;
                    break;

                case 2:
                    img = laserSpriteLvl2;
                    break;

                case 3:
                    img = laserSpriteLvl3;
                    break;

                case 4:
                    img = blueprintLaserSpriteLvl1;
                    break;

                case 5:
                    img = blueprintLaserSpriteLvl2;
                    break;

                case 6:
                    img = blueprintLaserSpriteLvl3;
                    break;
                }
            }
            else if (itemW.type == WeaponItem.WeaponType.CrownModAmmoCap ||
                     itemW.type == WeaponItem.WeaponType.CrownModDamage ||
                     itemW.type == WeaponItem.WeaponType.CrownModRange ||
                     itemW.type == WeaponItem.WeaponType.CrownModRechargeRate)
            {
                switch (itemW.tier)
                {
                case 1:
                    img = crownSpriteLvl1;
                    break;

                case 2:
                    img = crownSpriteLvl2;
                    break;

                case 3:
                    img = crownSpriteLvl3;
                    break;

                case 4:
                    img = blueprintCrownSpriteLvl1;
                    break;

                case 5:
                    img = blueprintCrownSpriteLvl2;
                    break;

                case 6:
                    img = blueprintCrownSpriteLvl3;
                    break;
                }
            }
            else if (itemW.type == WeaponItem.WeaponType.MissileModAmmoCap ||
                     itemW.type == WeaponItem.WeaponType.MissileModDamage ||
                     itemW.type == WeaponItem.WeaponType.MissileModFireRate ||
                     itemW.type == WeaponItem.WeaponType.MissileModRange ||
                     itemW.type == WeaponItem.WeaponType.MissileModRechargeRate ||
                     itemW.type == WeaponItem.WeaponType.MissileModSpeed)
            {
                switch (itemW.tier)
                {
                case 1:
                    img = missileSpriteLvl1;
                    break;

                case 2:
                    img = missileSpriteLvl2;
                    break;

                case 3:
                    img = missileSpriteLvl3;
                    break;

                case 4:
                    img = blueprintMissileSpriteLvl1;
                    break;

                case 5:
                    img = blueprintMissileSpriteLvl2;
                    break;

                case 6:
                    img = blueprintMissileSpriteLvl3;
                    break;
                }
            }
            else
            {
                img = defaultSprite;
            }
        }
        else
        if (EngineItem.isEngineType(item.getType()))
        {
            EngineItem itemE = (EngineItem)item;
            if (itemE.type == EngineItem.EngineType.Standard)
            {
                switch (itemE.tier)
                {
                case 1:
                    img = engineStandardLvl1;
                    break;

                case 2:
                    img = engineStandardLvl2;
                    break;

                case 3:
                    img = engineStandardLvl3;
                    break;

                case 4:
                    img = blueprintEngineStandardLvl1;
                    break;

                case 5:
                    img = blueprintEngineStandardLvl2;
                    break;

                case 6:
                    img = blueprintEngineStandardLvl3;
                    break;
                }
            }
            else if (itemE.type == EngineItem.EngineType.Spinjet)
            {
                switch (itemE.tier)
                {
                case 1:
                    img = engineSpinjetLvl1;
                    break;

                case 2:
                    img = engineSpinjetLvl2;
                    break;

                case 3:
                    img = engineSpinjetLvl3;
                    break;

                case 4:
                    img = blueprintEngineSpinjetLvl1;
                    break;

                case 5:
                    img = blueprintEngineSpinjetLvl2;
                    break;

                case 6:
                    img = blueprintEngineSpinjetLvl3;
                    break;
                }
            }
            else if (itemE.type == EngineItem.EngineType.Thruster)
            {
                switch (itemE.tier)
                {
                case 1:
                    img = engineThrusterLvl1;
                    break;

                case 2:
                    img = engineThrusterLvl2;
                    break;

                case 3:
                    img = engineThrusterLvl3;
                    break;

                case 4:
                    img = blueprintEngineThrusterLvl1;
                    break;

                case 5:
                    img = blueprintEngineThrusterLvl2;
                    break;

                case 6:
                    img = blueprintEngineThrusterLvl3;
                    break;
                }
            }
        }
        return(img);
    }