예제 #1
0
파일: RTS.cs 프로젝트: klyed/Zone-Assets
        public void newStructure(Vehicle veh, Player player)
        {
            Structure newStruct = new Structure(this);

            newStruct._vehicle         = veh;
            newStruct._state           = veh._state;
            newStruct._productionLevel = 1;
            newStruct._id   = (ushort)(_database.getLastStructureID(_fileName) + 1);
            newStruct._key  = _fileName;
            newStruct._type = veh._type;

            switch (veh._type.Name)
            {
            case "[RTS] Shack":
            {
                newStruct._upgradeCost        = c_baseShackUpgrade;
                newStruct._productionQuantity = c_baseShackProduction;
                newStruct._nextProduction     = DateTime.Now.AddHours(c_shackProductionInterval);
            }
            break;

            case "[RTS] House":
            {
                newStruct._upgradeCost        = c_baseHouseUpgrade;
                newStruct._productionQuantity = c_baseHouseProduction;
                newStruct._nextProduction     = DateTime.Now.AddHours(c_houseProductionInterval);
            }
            break;

            case "[RTS] Villa":
            {
                newStruct._upgradeCost        = c_basevillaUpgrade;
                newStruct._productionQuantity = c_baseVillaProduction;
                newStruct._nextProduction     = DateTime.Now.AddHours(c_villaProductionInterval);
            }
            break;

            case "[RTS] Scrapyard":
            {
                newStruct._productionItem     = AssetManager.Manager.getItemByID(2026);
                newStruct._upgradeCost        = c_baseScrapUpgrade;
                newStruct._productionQuantity = c_baseScrapProduction;
                newStruct._nextProduction     = DateTime.Now.AddHours(c_baseScrapProductionInterval);
            }
            break;

            case "[RTS] Iron Mine":
            {
                newStruct._productionItem     = AssetManager.Manager.getItemByID(2027);
                newStruct._upgradeCost        = c_baseIronMineUpgrade;
                newStruct._productionQuantity = c_baseIronProduction;
                newStruct._nextProduction     = DateTime.Now.AddHours(c_baseIronProductionInterval);
            }
            break;

            case "[RTS] Command Center":
            {
                newStruct._upgradeCost = c_baseCCUpgrade;
            }
            break;

            default:
            {
                newStruct._productionItem     = AssetManager.Manager.getItemByID(323);
                newStruct._productionQuantity = 0;
                newStruct._productionLevel    = 1;
            }
            break;
            }


            newStruct.initState(veh);

            _database.addStructure(newStruct, _fileName);
            _structures.Add(newStruct._id, newStruct);
        }
예제 #2
0
파일: RTS.cs 프로젝트: klyed/Zone-Assets
        public bool playerMakeVehicle(Player player, ItemInfo.VehicleMaker item, short posX, short posY)
        {
            int       count         = _arena.Vehicles.Count(veh => veh._type.Id == item.vehicleID);
            int       totalCount    = _structures.Count;
            bool      bSuccess      = false;
            VehInfo   vehicle       = AssetManager.Manager.getVehicleByID(item.vehicleID);
            Structure commandCenter = _structures.Values.FirstOrDefault(st => st._vehicle._type.Id == 414);

            //Max Structures?
            if (totalCount >= c_maxStructures)
            {
                player.sendMessage(-1, "You have met or exceeded the maximum amount of structures allowed. " +
                                   "To build more, you must sell another building");

                player.inventoryModify(item, 1);
                return(false);
            }

            //Do we have a command center even?
            if (commandCenter == null && item.vehicleID != 414)
            {
                player.sendMessage(-1, "You currently do not have a active Command Center, please build one to continue..");
                player.inventoryModify(item, 1);
                return(false);
            }

            switch (item.vehicleID)
            {
            //Command Center
            case 414:
            {
                if (count > 0)
                {
                    player.sendMessage(-1, "You may only have one active Command Center.");
                    player.syncState();
                    bSuccess = false;
                }
                else if (!isAreaOpen(posX, posY, vehicle.PhysicalRadius))
                {
                    player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                    bSuccess = false;
                }
                else
                {
                    //Building!
                    bSuccess = true;
                }
            }
            break;

            //Power Station
            case 423:
            {
                if (!isAreaOpen(posX, posY, vehicle.PhysicalRadius))
                {
                    player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                    bSuccess = false;
                }
                else
                {
                    //Building!
                    bSuccess = true;
                }
            }
            break;

            //House
            case 424:
            {
                int maxCount = commandCenter._productionLevel * 4;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Iron Mine
            case 427:
            {
                int maxCount = commandCenter._productionLevel * 3;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Scrapyard
            case 428:
            {
                int maxCount = commandCenter._productionLevel * 3;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Villa
            case 425:
            {
                int maxCount = commandCenter._productionLevel * 4;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Shack
            case 415:
            {
                int maxCount = commandCenter._productionLevel * 4;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Catch all
            default:
            {
                bSuccess = canBuildInArea(player, vehicle);
            }
            break;
            }
            //Give them back their kit if it failed.
            if (!bSuccess)
            {
                player.inventoryModify(item, 1);
            }

            return(bSuccess);
        }
예제 #3
0
        public bool tryProductionMenu(Player player, Computer computer, VehInfo.Computer.ComputerProduct product)
        {
            int       idx       = Convert.ToInt32(product.Title.Substring(0, 2));
            Structure structure = getStructureByVehicleID(computer._id);

            switch (idx)
            {
            //1 - Refinery - Iron (200 Iron)
            case 1:
            {
                if (player.getInventoryAmount(2027) < 200)
                {
                    player.sendMessage(-1, "&You don't have enough iron for this option");
                    return(false);
                }

                player.inventoryModify(2027, -200);
                player.inventoryModify(197, 1);
                player.sendMessage(0, "1 [RTS] Refinery - Iron has been added to your inventory");
                player.syncState();
            }
            break;

            //2 - Iron Mine (100 Iron)
            case 2:
            {
                if (player.getInventoryAmount(2027) < 100)
                {
                    player.sendMessage(-1, "&You don't have enough iron for this option");
                    return(false);
                }

                player.inventoryModify(2027, -100);
                player.inventoryModify(205, 1);
                player.sendMessage(0, "1 [RTS] Iron Mine Kit has been added to your inventory");
                player.syncState();
            }
            break;

            //3 - Scrapyard (100 Iron)
            case 3:
            {
                if (player.getInventoryAmount(2027) < 100)
                {
                    player.sendMessage(-1, "&You don't have enough iron for this option");
                    return(false);
                }

                player.inventoryModify(2027, -100);
                player.inventoryModify(206, 1);
                player.sendMessage(0, "1 [RTS] Scrapyard Kit has been added to your inventory");
                player.syncState();
            }
            break;

            //16 - Click For Info
            case 16:
            {
                player.sendMessage(0, "$ - Factory - Production");
                int repairCost = calculateRepairCost(structure._vehicle);
                player.sendMessage(0, String.Format("& --- Repair Cost: {0}", repairCost));
                player.sendMessage(0, "& --- Refinery - Iron (Refines scrap metal into Refined Iron)");
                player.sendMessage(0, "& --- Iron Mine (Produces Refined Iron at hourly intervals)");
                player.sendMessage(0, "& --- Scrapyard (Produces Scrap Metal at hourly intervals)");
            }
            break;

            //15 - Repair
            case 15:
            {
                int repairCost = calculateRepairCost(structure._vehicle);

                if (player.getInventoryAmount(2026) < repairCost)
                {
                    player.sendMessage(-1, "I'm sorry, you don't have enough scrap metal to repair this building");
                    return(false);
                }

                structure._vehicle._state.health = (short)structure._vehicle._type.Hitpoints;

                player.inventoryModify(2026, -repairCost);
                player.sendMessage(0, "Structure repaired");
                player.syncState();
            }
            break;

            //14 - Sell
            case 14:
            {
                player.inventoryModify(2026, structure._vehicle._type.DropItemQuantity);
                player.syncState();

                player.sendMessage(0, String.Format("&Structure sold ({0} Scrap added to your inventory)", structure._type.DropItemQuantity));

                structure.destroyed(structure._vehicle, player);
                structure._vehicle.destroy(false);
            }
            break;
            }
            return(false);
        }
예제 #4
0
        public bool tryIronRefinery(Player player, Computer computer, VehInfo.Computer.ComputerProduct product)
        {
            int       idx       = Convert.ToInt32(product.Title.Substring(0, 2));
            Structure structure = getStructureByVehicleID(computer._id);

            switch (idx)
            {
            //1 - 1 Iron (2 Scrap Metal)
            case 1:
            {
                if (player.getInventoryAmount(2026) < 2)
                {
                    player.sendMessage(-1, "Refinery Worker> I'm sorry, you don't have enough scrap metal for this option");
                    return(false);
                }

                player.inventoryModify(2027, 1);
                player.inventoryModify(2026, -2);
                player.sendMessage(0, "1 Iron has been added to your inventory");
                player.syncState();
            }
            break;

            //2 - 5 Iron (10 Scrap Metal)
            case 2:
            {
                if (player.getInventoryAmount(2026) < 10)
                {
                    player.sendMessage(-1, "Refinery Worker> I'm sorry, you don't have enough scrap metal for this option");
                    return(false);
                }

                player.inventoryModify(2027, 5);
                player.inventoryModify(2026, -10);
                player.sendMessage(0, "5 Iron has been added to your inventory");
                player.syncState();
            }
            break;

            //3 - 10 Iron (18 Scrap Metal)
            case 3:
            {
                if (player.getInventoryAmount(2026) < 18)
                {
                    player.sendMessage(-1, "Refinery Worker> I'm sorry, you don't have enough scrap metal for this option");
                    return(false);
                }
                player.inventoryModify(2027, 10);
                player.inventoryModify(2026, -18);
                player.sendMessage(0, "10 Iron has been added to your inventory");
                player.syncState();
            }
            break;

            //4 - 35 Iron (25 Scrap Metal)
            case 4:
            {
                if (player.getInventoryAmount(2026) < 25)
                {
                    player.sendMessage(-1, "Refinery Worker> I'm sorry, you don't have enough scrap metal for this option");
                    return(false);
                }

                player.inventoryModify(2027, 35);
                player.inventoryModify(2026, -25);
                player.sendMessage(0, "35 Iron has been added to your inventory");
                player.syncState();
            }
            break;

            //5 - 50 Iron (30 Scrap Metal)
            case 5:
            {
                if (player.getInventoryAmount(2026) < 30)
                {
                    player.sendMessage(-1, "Refinery Worker> I'm sorry, you don't have enough scrap metal for this option");
                    return(false);
                }

                player.inventoryModify(2027, 50);
                player.inventoryModify(2026, -30);
                player.sendMessage(0, "50 Iron has been added to your inventory");
                player.syncState();
            }
            break;

            //15 - Repair
            case 15:
            {
                int repairCost = calculateRepairCost(structure._vehicle);

                if (player.getInventoryAmount(2026) < repairCost)
                {
                    player.sendMessage(-1, "I'm sorry, you don't have enough scrap metal to repair this building");
                    return(false);
                }

                structure._vehicle._state.health = (short)structure._vehicle._type.Hitpoints;

                player.inventoryModify(2026, -repairCost);
                player.sendMessage(0, "Structure repaired");
                player.syncState();
            }
            break;

            //16 - Info
            case 16:
            {
                int repairCost = calculateRepairCost(structure._vehicle);
                player.sendMessage(0, String.Format("&-Repair Cost: {0}", repairCost));
            }
            break;

            //14 - Sell
            case 14:
            {
                player.inventoryModify(2026, structure._vehicle._type.DropItemQuantity);
                player.syncState();

                player.sendMessage(0, String.Format("&Structure sold ({0} Scrap added to your inventory)", structure._type.DropItemQuantity));

                structure.destroyed(structure._vehicle, player);
                structure._vehicle.destroy(false);
            }
            break;
            }

            return(false);
        }
예제 #5
0
        public bool tryBarracksMenu(Player player, Computer computer, VehInfo.Computer.ComputerProduct product, DefenseProduction type)
        {
            int       idx       = Convert.ToInt32(product.Title.Substring(0, 2));
            Structure structure = getStructureByVehicleID(computer._id);

            if (_units.Count >= _botMax)
            {
                player.sendMessage(-1, "You have reach the maximum amount of units you can train/Have active at one time.");
                return(false);
            }

            switch (idx)
            {
            //1 - Train 1 Normal ($500)
            case 1:
            {
                if (player.Cash < 500)
                {
                    player.sendMessage(-1, "Insufficient funds for this option");
                    return(false);
                }
                player.Cash -= 500;
                player.sendMessage(0, "Unit Ready");
                player.syncState();
                switch (type)
                {
                case DefenseProduction.Marine:
                    newUnit(BotType.Marine, null, null, BotLevel.Normal, player._state);
                    break;

                case DefenseProduction.Ripper:
                    newUnit(BotType.Ripper, null, null, BotLevel.Normal, player._state);
                    break;
                }
            }
            break;

            //2 - Train 1 Adept ($1000)
            case 2:
            {
                if (player.Cash < 1000)
                {
                    player.sendMessage(-1, "Insufficient funds for this option");
                    return(false);
                }
                player.Cash -= 1000;
                player.sendMessage(0, "Unit Ready");
                player.syncState();
                switch (type)
                {
                case DefenseProduction.Marine:
                    newUnit(BotType.Marine, null, null, BotLevel.Adept, player._state);
                    break;

                case DefenseProduction.Ripper:
                    newUnit(BotType.Ripper, null, null, BotLevel.Adept, player._state);
                    break;
                }
            }
            break;

            //3 - Train 1 Elite ($1500)
            case 3:
            {
                if (player.Cash < 1500)
                {
                    player.sendMessage(-1, "Insufficient funds for this option");
                    return(false);
                }
                player.Cash -= 1500;
                player.sendMessage(0, "Unit Ready");
                player.syncState();
                switch (type)
                {
                case DefenseProduction.Marine:
                    newUnit(BotType.EliteMarine, null, null, BotLevel.Elite, player._state);
                    break;

                case DefenseProduction.Ripper:
                    newUnit(BotType.EliteHeavy, null, null, BotLevel.Elite, player._state);
                    break;
                }
            }
            break;

            //14 - Sell
            case 14:
            {
                player.inventoryModify(2026, structure._vehicle._type.DropItemQuantity);
                player.syncState();

                player.sendMessage(0, String.Format("&Structure sold ({0} Scrap added to your inventory)", structure._type.DropItemQuantity));

                structure.destroyed(structure._vehicle, player);
                structure._vehicle.destroy(false);
            }
            break;

            //15 - Repair
            case 15:
            {
                int repairCost = calculateRepairCost(structure._vehicle);

                if (player.getInventoryAmount(2026) < repairCost)
                {
                    player.sendMessage(-1, "I'm sorry, you don't have enough scrap metal to repair this building");
                    return(false);
                }

                structure._vehicle._state.health = (short)structure._vehicle._type.Hitpoints;

                player.inventoryModify(2026, -repairCost);
                player.sendMessage(0, "Structure repaired");
                player.syncState();
            }
            break;

            //16 - Click For Info
            case 16:
            {
                player.sendMessage(0, "$Barracks Info:");
                player.sendMessage(0, "& --- The barracks allows you to train new units (bots) that will guard your city.");
                int repairCost = calculateRepairCost(structure._vehicle);
                player.sendMessage(0, String.Format("& --- Repair Cost: {0}", repairCost));
            }
            break;
            }
            return(false);
        }
예제 #6
0
        public bool tryCollectionMenu(Player player, Computer computer, VehInfo.Computer.ComputerProduct product, ProductionBuilding buildingType)
        {
            int       idx       = Convert.ToInt32(product.Title.Substring(0, 1));
            Structure structure = getStructureByVehicleID(computer._id);

            //Sanity
            if (structure == null)
            {
                return(false);
            }

            int level            = structure._productionLevel;
            int cash             = calculateProduction(level, buildingType);
            int cashNextLevel    = calculateProduction(level + 1, buildingType);
            int upgradeNextLevel = calculateUpgradeCost(structure._upgradeCost, buildingType);


            switch (idx)
            {
            //1 - Collect
            case 1:
            {
                //Are we ready?
                if (!IsProductionReady(structure))
                {
                    player.sendMessage(0, "&This building is not ready for collection yet.");
                    return(false);
                }

                //Produce!
                structure.produce(player);
            }
            break;

            //2 - Upgrade (100 Iron)
            case 2:
            {
                if (player.getInventoryAmount(2027) < structure._upgradeCost)
                {
                    player.sendMessage(-1, "&You do not have sufficient iron to upgrade this building");
                    return(false);
                }

                player.inventoryModify(2027, -structure._upgradeCost);
                player.syncState();

                //Up the cost for the next level
                structure._upgradeCost = upgradeNextLevel;
                structure._productionLevel++;
                structure._productionQuantity = cashNextLevel;

                player.sendMessage(0, String.Format("&Structure upgraded, Next collection: {0}", structure._productionQuantity));
            }
            break;

            //3 More Info
            case 3:
            {
                player.sendMessage(0, String.Format("&Building Info:"));
                player.sendMessage(0, String.Format("Current Level: {0}", structure._productionLevel));
                player.sendMessage(0, String.Format("Upgrade Cost for next level: {0} Iron", structure._upgradeCost));
                player.sendMessage(0, String.Format("Next Collection amount: {0}", structure._productionQuantity));
                player.sendMessage(0, String.Format("Next Level Collection amount: {0}", cashNextLevel));

                TimeSpan remaining = _baseScript.timeTo(structure._nextProduction.TimeOfDay);
                player.sendMessage(0, String.Format("Next collection ready in {0} Hour(s) & {1} minute(s)", remaining.Hours, remaining.Minutes));
            }
            break;
            }
            return(false);
        }