Example #1
0
 public AoATurretViewModel(AoATurret turret)
 {
     _turret = turret;
         foreach (AoAWeapon weapon in _turret.Weapons)
             _weapons.Add(new AoAWeaponViewModel(weapon));
 }
Example #2
0
        public new bool LoadData(NdfObject dataobject, TradManager dictionary, TradManager techdic, EdataManager iconPackage)
        {
            NdfCollection collection;

            // UNITS
            if (dataobject.TryGetValueFromQuery<NdfCollection>(PRODUCABLE_UNITS_PATH, out collection))
            {

                List<CollectionItemValueHolder> unitss = collection.InnerList.FindAll(x => x.Value is NdfObjectReference);

                List<NdfObjectReference> units = new List<NdfObjectReference>();
                foreach (CollectionItemValueHolder uni in unitss)
                {
                    units.Add(uni.Value as NdfObjectReference);
                }

                AoAGameObject obj;
                foreach (NdfObjectReference unit in units)
                {
                    obj = new AoAGameObject();
                    if (obj.LoadData(unit.Instance, dictionary, techdic, iconPackage))
                        if (obj.Type != ObjectType.Building)
                        {
                            AoAUnit aunit = new AoAUnit(obj);
                            if (aunit.LoadData(unit.Instance, dictionary, techdic, iconPackage)) // !!!!!
                                _BuildableUnits.Add(aunit);
                        }
                }
            }

            //Stealth
            NdfSingle ndfFloat32;
            IsStealthy = false;
            if (dataobject.TryGetValueFromQuery<NdfSingle>(STEALTH_PATH, out ndfFloat32))
                IsStealthy = ndfFloat32.Value >= 50f;

            if (dataobject.TryGetValueFromQuery<NdfSingle>(DAMMAGE_PATH, out ndfFloat32))
                Health = ndfFloat32.Value;

            // Armor
            NdfUInt32 ndfuint32;
            Armor = 0;
            if (dataobject.TryGetValueFromQuery<NdfUInt32>(ARMOR_PATH, out ndfuint32))
                Armor = (int)ndfuint32.Value;

            // vIEW RANGE
            if (dataobject.TryGetValueFromQuery<NdfSingle>(VIEW_RANGE_PATH, out ndfFloat32))
            {
                ViewRange = ndfFloat32.Value;
            }
            else { ViewRange = 0; }

            //Turrets
            NdfCollection ndfCollection;
            if (dataobject.TryGetValueFromQuery<NdfCollection>(TURRET_LIST_PATH, out ndfCollection))
            {
                List<CollectionItemValueHolder> turrs = ndfCollection.InnerList.FindAll(x => x.Value is NdfObjectReference);

                List<NdfObjectReference> turrets = new List<NdfObjectReference>();
                foreach (CollectionItemValueHolder turr in turrs)
                {
                    turrets.Add(turr.Value as NdfObjectReference);
                }

                AoATurret turret;
                int turretNum = 1;
                foreach (NdfObjectReference turr in turrets)
                {
                    turret = new AoATurret("T" + turretNum++);
                    if (turret.LoadData(turr.Instance, dictionary, techdic, iconPackage))
                        Turrets.Add(turret);
                }

            }

            //RESEARCHES
            if (dataobject.TryGetValueFromQuery<NdfCollection>(AVAILABLE_RESEARCHES_PATH, out collection))
            {

                List<CollectionItemValueHolder> ress = collection.InnerList.FindAll(x => x.Value is NdfObjectReference);

                List<NdfObjectReference> researches = new List<NdfObjectReference>();
                foreach (CollectionItemValueHolder uni in ress)
                {
                    researches.Add(uni.Value as NdfObjectReference);
                }

                AoAResearch aResearch;
                foreach (NdfObjectReference research in researches)
                {
                    aResearch = new AoAResearch();
                    if (aResearch.LoadData(research.Instance, dictionary, techdic, iconPackage)) // tech.dic !
                    {
                        Researches.Add(aResearch);
                    }
                }
            }

            return true;
        }
Example #3
0
        public new bool LoadData(NdfObject dataobject, TradManager dictionary, TradManager dictionary2, EdataManager iconPackage)
        {
            NdfUInt32 ndfuint32;
            NdfSingle ndfFloat32;
            NdfInt32 ndfInt32;
            NdfObject ndfObject;
            NdfCollection ndfCollection;

            // HP
            if (!dataobject.TryGetValueFromQuery<NdfSingle>(DAMMAGE_PATH, out ndfFloat32))
                return false;
            Health = ndfFloat32.Value;

            // Armor
            Armor = 0;
            if (dataobject.TryGetValueFromQuery<NdfUInt32>(ARMOR_PATH, out ndfuint32))
                Armor = (int)ndfuint32.Value;

            //POW
            if (dataobject.TryGetValueFromQuery<NdfUInt32>(POW_PATH, out ndfuint32))
                nbrPOW = (int)ndfuint32.Value;

            //AutoReveal
            if (!dataobject.TryGetValueFromQuery<NdfInt32>(AUTOREVEAL_PATH, out ndfInt32))
                return false;
            AutoReveal = ndfInt32.Value == 2;

            //Transporter
            if (dataobject.TryGetValueFromQuery<NdfInt32>(TRANSPORT_PATH, out ndfInt32))
            {
                TransportSlot = ndfInt32.Value;
            }
            else { TransportSlot = 0; }

            //Stealth
            if (!dataobject.TryGetValueFromQuery<NdfSingle>(STEALTH_PATH, out ndfFloat32))
                return false;
            IsStealthy = ndfFloat32.Value >= 50f;

            // vIEW RANGE
            if (dataobject.TryGetValueFromQuery<NdfSingle>(VIEW_RANGE_PATH, out ndfFloat32))
            {
                ViewRange = ndfFloat32.Value;
            }
            else { ViewRange = 0; }

            // Slot Taken
            if(dataobject.TryGetValueFromQuery<NdfInt32>(TRANSPORTABLE_PATH, out ndfInt32))
            {
                SlotTaken = ndfInt32.Value;
            } else { SlotTaken = 0; }

            //Turrets
            if(dataobject.TryGetValueFromQuery<NdfCollection>(TURRET_LIST_PATH, out ndfCollection))
            {
                List<CollectionItemValueHolder> turrs = ndfCollection.InnerList.FindAll(x => x.Value is NdfObjectReference);

                List<NdfObjectReference> turrets = new List<NdfObjectReference>();
                foreach (CollectionItemValueHolder turr in turrs)
                {
                    turrets.Add(turr.Value as NdfObjectReference);
                }

                AoATurret turret;
                int turrentNum = 1;
                foreach(NdfObjectReference turr in turrets)
                {
                    turret = new AoATurret("T" + turrentNum++);
                    if(turret.LoadData(turr.Instance, dictionary, dictionary2, iconPackage))
                        Turrets.Add(turret);
                }

            }// a tester

            //Vehicle
             // Speed
            if(!dataobject.TryGetValueFromQuery<NdfSingle>(SPEED_PATH, out ndfFloat32))
                return false;
            Speed = ndfFloat32.Value;
            OnRoadSpeed = Speed;

            if (dataobject.TryGetValueFromQuery<NdfSingle>(ROAD_BONUS, out ndfFloat32))
                OnRoadSpeed *= ndfFloat32.Value ;

            // Upgrades
            if (dataobject.TryGetValueFromQuery<NdfCollection>(AVAILABLE_RESEARCHES_PATH, out ndfCollection))
            {
                List<CollectionItemValueHolder> ress = ndfCollection.InnerList.FindAll(x => x.Value is NdfObjectReference);

                List<NdfObjectReference> researches = new List<NdfObjectReference>();
                foreach (CollectionItemValueHolder uni in ress)
                {
                    researches.Add(uni.Value as NdfObjectReference);
                }

                AoAResearch aResearch;
                foreach (NdfObjectReference research in researches)
                {
                    aResearch = new AoAResearch();
                    if (aResearch.LoadData(research.Instance, dictionary, dictionary2, iconPackage)) // tech.dic !
                    {
                        Upgrades.Add(aResearch);
                    }
                }
            }

            // UnitChildren
            NdfObjectReference ndfref;
            if (dataobject.TryGetValueFromQuery<NdfObjectReference>(CHILD_PATH, out ndfref))
            {
                AoAGameObject obj = new AoAGameObject();
                obj.LoadData(ndfref.Instance, dictionary, dictionary2, iconPackage);
                AoAUnit unit = new AoAUnit(obj);
                unit.LoadData(ndfref.Instance, dictionary, dictionary2, iconPackage);
                Children.Add(unit);
            }
            else
            {
                // Regarder dans technoregistrar ?
            }

            return true;
        }