private void OnTankConfigurationChanged(ConfigurationAspect aspect, IXQueryable oldValue, IXQueryable newValue)
 {
     if (this.TankConfigurationChanged != null)
     {
         this.TankConfigurationChanged(this, new ConfigurationChangedEventArgs(aspect, oldValue, newValue));
     }
 }
        private void AddModelNodes(VirtualFolderVM parent, IXQueryable element)
        {
            var packageIndexer = this.GameClientRoot.Model.PackageIndexer;

            this.AddModelDirectory(parent,
                                   element,
                                   this.L("game_client_explorer", "undamaged"),
                                   "models/undamaged",
                                   packageIndexer);
            this.AddModelDirectory(parent,
                                   element,
                                   this.L("game_client_explorer", "destroyed"),
                                   "models/destroyed",
                                   packageIndexer);
            this.AddModelDirectory(parent,
                                   element,
                                   this.L("game_client_explorer", "exploded"),
                                   "models/exploded",
                                   packageIndexer);
            this.AddModelDirectory(parent,
                                   element,
                                   this.L("game_client_explorer", "collision"),
                                   "hitTester/collisionModel",
                                   packageIndexer,
                                   false);
            var exclusiveMaskNode = this.CreateExclusiveMaskNode(parent, element, packageIndexer);

            if (exclusiveMaskNode != null)
            {
                parent.AddChild(exclusiveMaskNode);
            }
        }
        public SkillScript(IXQueryable skill, SkillType skillType, string role, Func <double> levelGetter, DuplicatedSkillPolicy duplicatedSkillPolicy, int priority)
            : base(levelGetter)
        {
            this._skill = skill;
            _role       = role;

            var skillKey = this.Skill["@key"];

            _domain = skillKey.Substring(0, 1).ToLower() + skillKey.Substring(1);

            double dummy;

            this._parameters = this.Skill.Where(i => i.Name != "userString" &&
                                                i.Name != "description" &&
                                                i.Name != "icon" &&
                                                double.TryParse(i.Value,
                                                                NumberStyles.Float | NumberStyles.AllowThousands,
                                                                CultureInfo.InvariantCulture,
                                                                out dummy))
                               .ToDictionary(i => i.Name, i => double.Parse(i.Value, CultureInfo.InvariantCulture));

            _duplicatedSkillPolicy = duplicatedSkillPolicy;
            _skillType             = skillType;
            _priority = priority;
        }
        private bool ModelFileEquals(IXQueryable oldElement, IXQueryable newElement, string xpath)
        {
            var oldLocalPath = oldElement[xpath];
            var newLocalPath = newElement[xpath];

            return(this.PackageFileEquals(oldLocalPath, newLocalPath));
        }
        public NationalTechTreeNodeVM(IRepository repository,
                                      IXQueryable tank,
                                      int row,
                                      int column,
                                      IEnumerable <string> unlockTanks,
                                      ImageSource icon)
        {
            _repository      = repository;
            this.Tank        = new TankEntity(tank);
            _unikey          = new TankUnikey(_repository, this.Tank);
            this.Column      = column;
            this.Row         = row;
            this.UnlockTanks = unlockTanks;

            App.BeginInvokeBackground(() => this.Icon = icon);

            this.MenuItems = TankCommandManager.Instance
                             .Commands
                             .OrderBy(c => c.Priority)
                             .Select(c => new MenuItemVM(c.Name, c, _unikey)
            {
                Icon = c.Icon,
            })
                             .ToArray();
        }
Esempio n. 6
0
        private bool SetAccessory(IXQueryable[] accessoryArray, string[] keyArray, XElement elements, int index, IXQueryable value, XElement valueElement, string prefix)
        {
            if (accessoryArray[index].KeyEquals(value))
            {
                return(false);
            }

            var oldAccessory = accessoryArray[index];

            accessoryArray[index] = value;
            this.ScriptHost.SetScript(prefix + (index + 1).ToString(), AccessoryScript.Create(value));
            keyArray[index] = value != null ? value["@key"] : null;

            if (oldAccessory == null && value != null)
            {
                elements.Add(valueElement);
            }
            else if (oldAccessory != null)
            {
                var oldElement = elements.Elements().First(e => e.ExistedAttribute("key").Value == oldAccessory["@key"]);

                if (value == null)
                {
                    oldElement.Remove();
                }
                else
                {
                    oldElement.ReplaceWith(valueElement);
                }
            }

            return(true);
        }
        private static string GetTankName(IXQueryable tank)
        {
#if SHOW_TANK_KEY
            return(string.Format("{0} ({1})", tank["userString"], tank["@fullKey"]));
#else
            return(tank["userString"]);
#endif
        }
Esempio n. 8
0
        public void ForgetSkill(IXQueryable skill)
        {
            CrewInstance.TransferSkill(skill, _learntSkills, _availableSkills);
            this.Configuration.ScriptHost.SetScript(this.GetScriptKey(skill), null);
            this.SetLastSkillScriptLevelGetter(() => this.ActualLastSkillTrainingLevel);

            this.InvalidateSkillEffects();
        }
Esempio n. 9
0
        public TankVM(IRepository repository, IXQueryable tankData)
            : this()
        {
            this.TankUnikey = new TankUnikey(repository, tankData);
            this.Key        = this.TankUnikey.ToString();

            this.Repository = repository;
            this.Model      = new Tank(tankData);
        }
        public XQueryableWrapper(IXQueryable wrapped)
        {
            if (wrapped == null)
            {
                throw new ArgumentNullException("wrapped");
            }

            _wrapped = wrapped;
        }
Esempio n. 11
0
        public static CamouflageScript Create(IXQueryable camouflage)
        {
            if (camouflage == null)
            {
                return(null);
            }

            return(new CamouflageScript(camouflage));
        }
        public LocalGameClientNationalTechTreeVM(LocalGameClient client, string nationKey)
        {
            _client        = client;
            this.NationKey = nationKey;

            _layout = client.TechTreeLayoutDatabase.Query("layout[@nation='{0}']", nationKey);

            this.Name      = _client.Localization.GetLocalizedNationName(NationKey);
            this.SmallIcon = _client.PackageImages.GetNationSmallIcon(NationKey);
        }
Esempio n. 13
0
        private static void AddFileNode(VirtualFolderVM parent, IXQueryable element, string name, string xpath, LocalGameClientPackageIndexer indexer)
        {
            var localPath = element[xpath];

            if (!string.IsNullOrEmpty(localPath))
            {
                var fileNode = new RemotePackageFileVM(parent, indexer.GetPackagePath(localPath), localPath, name);
                parent.AddChild(fileNode);
            }
        }
Esempio n. 14
0
 public static Tank Create(IXQueryable tankData)
 {
     if (tankData is Tank)
     {
         return((Tank)tankData);
     }
     else
     {
         return(new Tank(tankData));
     }
 }
Esempio n. 15
0
        public CachedXQueryable(IXQueryable wrapped)
        {
            if (wrapped == null)
            {
                throw new ArgumentNullException("wrapped");
            }

            _wrapped = wrapped;

            _cache = new Dictionary <string, object>();
        }
Esempio n. 16
0
        public bool TryGetTank(out IXQueryable tank, out IRepository repository)
        {
            repository = Core.Support.GetRepository(this.RepositoryID);
            if (repository == null)
            {
                tank = null;
                return(false);
            }

            tank = this.GetTank(repository);
            return(tank != null);
        }
        public static double QueryDouble(this IXQueryable xqueryable, string xpath, double defaultValue = default(double))
        {
            var value = xqueryable.QueryValue(xpath);

            if (string.IsNullOrEmpty(value))
            {
                return(defaultValue);
            }
            else
            {
                return(double.Parse(value, CultureInfo.InvariantCulture));
            }
        }
        public static int QueryInt(this IXQueryable xqueryable, string xpath, int defaultValue = default(int))
        {
            var value = xqueryable.QueryValue(xpath);

            if (string.IsNullOrEmpty(value))
            {
                return(defaultValue);
            }
            else
            {
                return(int.Parse(value, CultureInfo.InvariantCulture));
            }
        }
        public static bool QueryBool(this IXQueryable xqueryable, string xpath, bool defaultValue = default(bool))
        {
            var value = xqueryable.QueryValue(xpath);

            if (string.IsNullOrEmpty(value))
            {
                return(defaultValue);
            }
            else
            {
                return(bool.Parse(value));
            }
        }
Esempio n. 20
0
 private TechTreeLayoutNode(IXQueryable tank, IEnumerable <string> unlockTanks)
 {
     this.Tank = tank;
     _tankKey  = tank["@key"];
     if (unlockTanks == null)
     {
         _unlockTanks = new string[0];
     }
     else
     {
         _unlockTanks = unlockTanks.ToArray();
     }
 }
Esempio n. 21
0
        protected override double?GetBenchmarkValue(IXQueryable queryable, IRepository repository, string xpath)
        {
            var value = queryable.QueryValue(xpath);

            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            else
            {
                return(bool.Parse(value) ? 1 : 0);
            }
        }
Esempio n. 22
0
        public static AccessoryScript Create(IXQueryable accessory)
        {
            if (accessory == null)
            {
                return(null);
            }

            if (accessory["script/@name"] == "CamouflageNet")
            {
                return(new CamouflageNetScript(accessory));
            }

            return(new AccessoryScript(accessory));
        }
        private static TankInstance GetInstance(IRepository repository, IXQueryable tank, TankUnikey unikey)
        {
            var key = unikey.ToString();

            return(s_instances.GetOrCreate(key, () =>
            {
                var storage = TankInstanceManager.GetRepositoryTankConfigInfoStorage(repository);
                TankInstanceConfigurationInfo configInfo;
                storage.TryGetValue(key, out configInfo);
                var instance = new TankInstance(repository, TankEntity.Create(tank), configInfo);
                storage[key] = instance.ConfigurationInfo;
                return instance;
            }));
        }
        private IEnumerable <ItemName> AnalyseModuleCollectionCollisionChanges(IXQueryable oldTank, IXQueryable newTank, string xpath, string moduleName)
        {
            var oldModules = oldTank.QueryMany(xpath).Distinct(KeyEqualityComparer <IXQueryable> .Instance);
            var newModules = newTank.QueryMany(xpath).Distinct(KeyEqualityComparer <IXQueryable> .Instance);

            foreach (var sharedItem in oldModules.Diff(newModules, KeyEqualityComparer <IXQueryable> .Instance).Shared)
            {
                if (!this.ModelFileEquals(sharedItem.Source, sharedItem.Target, "hitTester/collisionModel"))
                {
                    var name = new ItemName(PatchnoteGeneratorDocumenVM.GetTankName(sharedItem.Source));
                    name.AddModifier(new TypeModifier(moduleName));
                    yield return(name);
                }
            }
        }
Esempio n. 25
0
        protected override string GetValue(IXQueryable queryable, IRepository repository, string xpath)
        {
            var result = base.GetValue(queryable, repository, xpath);

            if (string.IsNullOrEmpty(result))
            {
                Core.Support.LogWarning(this,
                                        string.Format("error getting boolean stat value (key='{0}', xpath='{1}')",
                                                      this.Key,
                                                      xpath));
                return("false");
            }

            return(result);
        }
Esempio n. 26
0
        private void AddModelDirectory(VirtualFolderVM parent,
                                       IXQueryable element,
                                       string directoryName,
                                       string xpath,
                                       LocalGameClientPackageIndexer indexer,
                                       bool addVisualNode = true)
        {
            var localPath = element[xpath];

            if (!string.IsNullOrWhiteSpace(localPath))
            {
                var node = new VirtualFolderVM(parent, directoryName);
                parent.AddChild(node);
                TankNodeVM.AddModelNode(node, localPath, indexer, addVisualNode);
            }
        }
Esempio n. 27
0
        protected override double?GetBenchmarkValue(IXQueryable queryable, IRepository repository, string xpath)
        {
            var value = queryable.QueryValue(xpath);

            if (string.IsNullOrEmpty(value))
            {
                Core.Support.LogWarning(this,
                                        string.Format(
                                            "error getting number stat value (key='{0}', xpath='{1}')",
                                            this.Key,
                                            xpath));
                return(null);
            }

            return(double.Parse(value));
        }
Esempio n. 28
0
        public bool ShouldShowFor(IXQueryable queryable, IRepository repository)
        {
            if (string.IsNullOrEmpty(this.ShowConditionXPath))
            {
                return(true);
            }

            var queryResult = queryable.QueryValue(this.ShowConditionXPath);

            if (string.IsNullOrEmpty(queryResult) || queryResult == "False")
            {
                return(false);
            }

            return(true);
        }
        public static Color?QueryColor(IXQueryable queryable, string xpath, byte?fixedAlpha = null)
        {
            var result = queryable[xpath];

            if (result == null)
            {
                return(null);
            }

            var values = result.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
            var r      = byte.Parse(values[0], CultureInfo.InvariantCulture);
            var g      = byte.Parse(values[1], CultureInfo.InvariantCulture);
            var b      = byte.Parse(values[2], CultureInfo.InvariantCulture);
            var a      = fixedAlpha == null?byte.Parse(values[3], CultureInfo.InvariantCulture) : fixedAlpha.Value;

            return(Color.FromArgb(a, r, g, b));
        }
        public static double[] QueryVector4(IXQueryable queryable, string xpath)
        {
            var result = queryable[xpath];

            if (result == null)
            {
                return(null);
            }

            var values = result.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
            var x      = double.Parse(values[0], CultureInfo.InvariantCulture);
            var y      = double.Parse(values[1], CultureInfo.InvariantCulture);
            var z      = double.Parse(values[2], CultureInfo.InvariantCulture);
            var w      = double.Parse(values[3], CultureInfo.InvariantCulture);

            return(new double[] { x, y, z, w });
        }