コード例 #1
0
        public static int GetCapacity(Ship ship)
        {
            if (Definitions.ShipDef.Items.Item.FirstOrDefault(n => n.DefId == ship.DefId)?.Levels == null)
            {
                var capacity = Definitions.ShipDef.Items.Item.First(n => n.DefId == ship.DefId).CapacityLevels.Level
                               .FirstOrDefault(n => n.Id == ship.CapacityLevel)?.Capacity;
                if (capacity != null)
                {
                    return(capacity.Value);
                }
            }

            ShipDefenitions.Item first = null;
            foreach (var n in Definitions.ShipDef.Items.Item)
            {
                if (n.DefId == ship.DefId)
                {
                    first = n;
                    break;
                }
            }

            if (first != null)
            {
                var pr = first.Levels.Level.FirstOrDefault(n => n.Id == ship.Level);
                if (pr != null)
                {
                    return(pr.Capacity);
                }
            }

            return(0);
        }
コード例 #2
0
        public static int GetSailors(Ship ship)
        {
            if (Definitions.ShipDef.Items.Item.First(n => n.DefId == ship.DefId).SailorsLevels == null)
            {
                ShipDefenitions.Item first = null;
                foreach (var n in Definitions.ShipDef.Items.Item)
                {
                    if (n.DefId == ship.DefId)
                    {
                        first = n;
                        break;
                    }
                }

                if (first != null)
                {
                    return(first.Levels.Level.First(n => n.Id == ship.Level).Sailors);
                }
            }

            var sailors = Definitions.ShipDef.Items.Item.First(n => n.DefId == ship.DefId).SailorsLevels.Level
                          .First(n => n.Id == ship.SailorsLevel).Sailors;

            if (sailors != null)
            {
                return(sailors.Value);
            }

            return(int.MaxValue);
        }