示例#1
0
        public bool BuildShip(ShipType type)
        {
            var data = EntityData.ShipTypes[type];

            foreach (var kvp in data.BuildCost)
            {
                if (Inventory.ResourceAmount(kvp.Key) < kvp.Value)
                {
                    return(false);
                }
            }

            foreach (var kvp in data.BuildCost)
            {
                Inventory.AddResource(kvp.Key, -kvp.Value);
            }

            var newItem = new BuildQueueItem()
            {
                Type     = type,
                Duration = data.BuildTime
            };

            BuildQueue.Enqueue(newItem);

            return(true);
        }
示例#2
0
        public bool BuildShip(ShipType type)
        {
            if (type == ShipType.Miner)
            {
                var minersInQueue = 0;

                foreach (var q in BuildQueue)
                {
                    if (q.ShipType == ShipType.Miner)
                    {
                        minersInQueue += 1;
                    }
                }

                if (GameplayState.WorldManager.Miners.Count + minersInQueue + 1 > (Config.BaseMinerLimit + GameplayState.UpgradeManager.BonusMaxMiners))
                {
                    return(false);
                }
            }

            var data = EntityData.ShipTypes[type];

            foreach (var kvp in data.BuildCost)
            {
                if (Inventory.ResourceAmount(kvp.Key) < kvp.Value)
                {
                    return(false);
                }
            }

            foreach (var kvp in data.BuildCost)
            {
                Inventory.AddResource(kvp.Key, -kvp.Value);
            }

            var newItem = new BuildQueueItem()
            {
                ShipType = type,
                Duration = data.BuildTime
            };

            BuildQueue.Add(newItem);

            return(true);
        }