Esempio n. 1
0
    public static void CalculateAbilityDefender(Guid DefenderID, WorldAbility Ability)
    {
        RootUnit unit    = GameWorldReferenceClass.GetUnitByID(DefenderID).GetComponent <RootUnit>();
        Type     statsTF = unit.totalStats.GetType();

        if (Ability.harmful)
        {
            float  total  = Ability.calculatedDamage;
            string form   = Ability.wFormRune.formRuneType.ToString();
            string school = Ability.wSchoolRune.schoolRuneType.ToString();

            total += (float)statsTF.GetField(string.Format("{0}_DamageTaken_Flat", form)).GetValue(unit.totalStats) + (float)statsTF.GetField(string.Format("{0}_DamageTaken_Flat", school)).GetValue(unit.totalStats);
            total *= 1 + (float)statsTF.GetField(string.Format("{0}_DamageTaken_AddPercent", form)).GetValue(unit.totalStats) + (float)statsTF.GetField(string.Format("{0}_DamageTaken_AddPercent", school)).GetValue(unit.totalStats) + unit.totalStats.GlobalDamage_DamageTaken_AddPercent;
            total *= (float)statsTF.GetField(string.Format("{0}_DamageTaken_MultiplyPercent", form)).GetValue(unit.totalStats) * (float)statsTF.GetField(string.Format("{0}_DamageTaken_MultiplyPercent", school)).GetValue(unit.totalStats) * unit.totalStats.GlobalDamage_DamageTaken_MultiplyPercent;

            float resolvedDamage = Mathf.Round(total * 100) / 100;
            unit.unitHealth -= resolvedDamage;
            unit.ResolveHit(resolvedDamage, false);
        }

        if (Ability.helpful)
        {
            //DamageHitInfo hitInfo = new DamageHitInfo();
            float resolvedHealing = Mathf.Round(Ability.calculatedHealing * 100) / 100;
            unit.unitHealth += resolvedHealing;
            unit.ResolveHeal(resolvedHealing);
        }
    }
Esempio n. 2
0
    public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
    {
        Vector3 dir = Camera.main.transform.forward;

        target.GetComponent <RootUnit>().Shove(15, dir);
        target.moveAbilityTimer = 0;
    }
Esempio n. 3
0
    public static void CalculateAbilityAttacker(WorldAbility Ability)
    {
        RootUnit unit     = GameWorldReferenceClass.GetUnitByID(Ability.abilityOwner).GetComponent <RootUnit>();
        Type     statsTF  = unit.totalStats.GetType();
        RootUnit attacker = GameWorldReferenceClass.GetUnitByID(Ability.abilityOwner);

        if (Ability.harmful)
        {
            float  total  = Ability.wSchoolRune.Damage();
            string form   = Ability.wFormRune.formRuneType.ToString();
            string school = Ability.wSchoolRune.schoolRuneType.ToString();

            total += (float)statsTF.GetField(string.Format("{0}_Damage_Flat", form)).GetValue(unit.totalStats) + (float)statsTF.GetField(string.Format("{0}_Damage_Flat", school)).GetValue(unit.totalStats);
            total *= 1 + (float)statsTF.GetField(string.Format("{0}_Damage_AddPercent", form)).GetValue(unit.totalStats) + (float)statsTF.GetField(string.Format("{0}_Damage_AddPercent", school)).GetValue(unit.totalStats) + unit.totalStats.GlobalDamage_Damage_AddPercent;
            total *= (float)statsTF.GetField(string.Format("{0}_Damage_MultiplyPercent", form)).GetValue(unit.totalStats) * (float)statsTF.GetField(string.Format("{0}_Damage_MultiplyPercent", school)).GetValue(unit.totalStats) * unit.totalStats.GlobalDamage_Damage_MultiplyPercent;
            Ability.calculatedDamage = total;
        }

        if (Ability.helpful)
        {
            float total = Ability.wSchoolRune.Damage();

            //total += (float)statsTF.GetField(string.Format("{0}_Damage_Flat", Ability.formRune.form.ToString())).GetValue(unit.totalStats) + (float)statsTF.GetField(string.Format("{0}_Damage_Flat", Ability.schoolRunes[0].school.ToString())).GetValue(unit.totalStats);
            //total *= 1 + (float)statsTF.GetField(string.Format("{0}_Damage_AddPercent", Ability.formRune.form.ToString())).GetValue(unit.totalStats) + (float)statsTF.GetField(string.Format("{0}_Damage_AddPercent", Ability.schoolRunes[0].school.ToString())).GetValue(unit.totalStats);
            //total *= (float)statsTF.GetField(string.Format("{0}_Damage_MultiplyPercent", Ability.formRune.form.ToString())).GetValue(unit.totalStats) * (float)statsTF.GetField(string.Format("{0}_Damage_MultiplyPercent", Ability.schoolRunes[0].school.ToString())).GetValue(unit.totalStats);
            Ability.calculatedHealing = total;
        }
    }
Esempio n. 4
0
    public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
    {
        Vector3 dir = new Vector3(0, 1, 0);

        target.Shove(15, dir);
        target.moveAbilityTimer = 0;
    }
Esempio n. 5
0
    public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
    {
        Vector2 flattenedDir = new Vector2(-Camera.main.transform.forward.x, -Camera.main.transform.forward.z).normalized;
        Vector3 dir          = new Vector3(flattenedDir.x, 0, flattenedDir.y);

        target.Shove(15, dir);
        target.moveAbilityTimer = 0;
    }
Esempio n. 6
0
        public MyEditController()
        {
            RootUnit = new RootUnit("Root", null);
            Units.Add(RootUnit);

            Parameters.Add(new ByPassParameter(RootUnit.Info.Id, 1));
            Parameters.Add(new GainParameter(RootUnit.Info.Id, 2));
        }
Esempio n. 7
0
    public static Vector3 LineOfSightCheckRootUnit(Vector3 viewerEyes, RootUnit subject)
    {
        RaycastHit lineOfSightTop;
        RaycastHit lineOfSightCenter;
        RaycastHit lineOfSightBottom;
        RaycastHit lineOfSightFront;
        RaycastHit lineOfSightBack;
        RaycastHit lineOfSightLeft;
        RaycastHit lineOfSightRight;

        var mesh = subject.GetComponent <CapsuleCollider>();

        Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, 0), Color.red);
        Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, 0), Color.green);
        Debug.DrawLine(viewerEyes, subject.transform.position, Color.blue);
        Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, mesh.radius), Color.black);
        Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, -mesh.radius), Color.white);
        Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(-mesh.radius, mesh.height, 0), Color.gray);
        Debug.DrawLine(viewerEyes, subject.transform.position + new Vector3(mesh.radius, mesh.height, 0), Color.cyan);

        Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, 0) - viewerEyes, out lineOfSightCenter, 50);
        if (lineOfSightCenter.collider.GetComponent <RootUnit>())
        {
            return(lineOfSightCenter.point);
        }
        Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, 0) - viewerEyes, out lineOfSightTop, 50);
        if (lineOfSightTop.collider.GetComponent <RootUnit>())
        {
            return(lineOfSightTop.point);
        }
        Physics.Raycast(viewerEyes, subject.transform.position - viewerEyes, out lineOfSightBottom, 50);
        if (lineOfSightBottom.collider.GetComponent <RootUnit>())
        {
            return(lineOfSightBottom.point);
        }
        Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height / 2, mesh.radius) - viewerEyes, out lineOfSightFront, 50);
        if (lineOfSightFront.collider.GetComponent <RootUnit>())
        {
            return(lineOfSightFront.point);
        }
        Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(0, mesh.height, -mesh.radius) - viewerEyes, out lineOfSightBack, 50);
        if (lineOfSightBack.collider.GetComponent <RootUnit>())
        {
            return(lineOfSightBack.point);
        }
        Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(-mesh.radius, mesh.height, 0) - viewerEyes, out lineOfSightLeft, 50);
        if (lineOfSightLeft.collider.GetComponent <RootUnit>())
        {
            return(lineOfSightLeft.point);
        }
        Physics.Raycast(viewerEyes, subject.transform.position + new Vector3(mesh.radius, mesh.height, 0) - viewerEyes, out lineOfSightRight, 50);
        if (lineOfSightRight.collider.GetComponent <RootUnit>())
        {
            return(lineOfSightRight.point);
        }

        return(new Vector3());
    }
        /// <summary>
        ///     Adds a hierarchy level.
        /// </summary>
        public void AddHierarchyLevel()
        {
            IUnitDecorator newHierarchyLevel = RootUnit.AddNewHigherUnit();

            SelectedUnit = newHierarchyLevel;
            ActivateItem(Items.FirstOrDefault());

            OnModelChanged();
        }
Esempio n. 9
0
        public HomeController(RootUnit root)
        {
            _root = root;

            //if (_root != null) return;

            //_root = (RootUnit)(ConfigurationManager.GetSection("RootUnit"));
            //_root.UpdateParents();
        }
        /// <summary>
        ///     Adds a new <see cref="HigherUnit" /> to the root unit's list of subordinates.
        /// </summary>
        public void AddNewHigherUnit()
        {
            HigherUnitDecorator higherUnit = this._decoratorService.Decorate(new HigherUnit());

            higherUnit.PropertyChanged += OnHigherUnitDecoratorPropertyChanged;

            RootUnit.AddSubordinate(higherUnit);
            SelectedUnit = higherUnit;
        }
        /// <summary>
        ///     Adds a new <see cref="Unit" /> to the root unit's list of subordinates.
        /// </summary>
        public void AddNewUnit()
        {
            UnitDecorator unit = this._decoratorService.Decorate(new Unit());

            unit.PropertyChanged += OnUnitDecoratorPropertyChanged;

            RootUnit.AddSubordinate(unit);
            SelectedUnit = unit;
        }
        /// <summary>
        ///     Adds a unit.
        /// </summary>
        public void AddUnit()
        {
            IUnitDecorator newUnit = RootUnit.AddNewUnit();

            SelectedUnit = newUnit;
            ActivateItem(Items.FirstOrDefault());

            OnModelChanged();
        }
Esempio n. 13
0
    public static void CalculateEnemyAbilityDefender(Guid DefenderID, float damage)
    {
        RootUnit defender = GameWorldReferenceClass.GetUnitByID(DefenderID);

        float resolvedDamage = Mathf.Round(damage * 100) / 100;

        defender.unitHealth -= resolvedDamage;
        defender.ResolveHit(resolvedDamage, false);
    }
Esempio n. 14
0
    public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
    {
        Status status = new Status();

        status.sourceUnit  = owner.unitID;
        status.rate        = Heal();
        status.maxDuration = Duration();

        target.AddStatus(status);
    }
Esempio n. 15
0
    public void Trigger(Collider collider)
    {
        RootUnit target = collider.GetComponent <RootUnit>();

        if (target != null && target.unitID != wA.abilityOwner && target.isAlive && !wA.previousTargets.Contains(target))
        {
            ApplyHit(target);
            wA.previousTargets.Add(target);
        }
    }
Esempio n. 16
0
    public void Trigger(Collider collider)
    {
        RootUnit target = collider.GetComponent <RootUnit>();

        if (target != null && target.unitID != wA.abilityOwner && target.isAlive && !wA.previousTargets.Contains(target))
        {
            ApplyHit(target);
            wA.previousTargets.Add(target);
            if (wA.abilityToTrigger != null)
            {
                CreateTriggerAbility(transform.position, null);
            }
        }
    }
Esempio n. 17
0
    public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
    {
        Status status = new Status();

        status.modifierGroups.Add(new ModifierGroup()
        {
            Stat = ModifierGroup.eStat.GlobalDamage, Aspect = ModifierGroup.eAspect.DamageTaken, Method = ModifierGroup.eMethod.AddPercent, Value = .01f * EffectStrength()
        });
        status.sourceUnit  = owner.unitID;
        status.rate        = 0;
        status.maxDuration = Duration();

        target.AddStatus(status);
    }
Esempio n. 18
0
    public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
    {
        Status status = new Status();

        status.modifierGroups.Add(new ModifierGroup()
        {
            Stat = stat, Aspect = aspect, Method = method, Value = EffectStrength()
        });
        status.sourceUnit  = owner.unitID;
        status.rate        = 0;
        status.maxDuration = Duration();

        target.AddStatus(status);
    }
Esempio n. 19
0
 public bool Use(RootUnit user, InventoryItem inventoryItem)
 {
     if (inventoryItem.currentCharges > 0)
     {
         user.unitHealth += inventoryItem.healAmount;
         Mathf.Clamp(user.unitHealth, 0, user.unitMaxHealth);
         user.ResolveHeal(inventoryItem.healAmount);
         inventoryItem.currentCharges--;
         if (inventoryItem.currentCharges <= 0)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 20
0
    public override void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
    {
        Collider[] collisionSphere;

        collisionSphere = Physics.OverlapSphere(owner.primarySpellCastLocation.position, 2, 1 << 11);

        foreach (var item in collisionSphere)
        {
            var ability = item.GetComponent <EnemyWorldAbility>();
            if (ability != null && ability.enemyAbilityStats.behavior == EnemyAbilityStats.Behavior.Projectile)
            {
                ability.reflected = true;
                item.transform.LookAt(GameWorldReferenceClass.GetUnitByID(ability.enemyAbilityStats.owner).transform.position);
            }
        }
    }
Esempio n. 21
0
        //public HomeController(RootUnit root)
        public HomeController()
        {
            var user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <SmartHomeUserManager>().FindByName(System.Web.HttpContext.Current.User.Identity.Name);

            if (user != null && user.Profiles.Any())
            {
                _root = user.Profiles.Where(p => p.Name == user.DefaultProfileName).FirstOrDefault();
                _root.UpdateParents();
            }

            //_root = root;

            //if (_root != null) return;

            //_root = (RootUnit)(ConfigurationManager.GetSection("RootUnit"));
            //_root.UpdateParents();
        }
    public static void CreateWorldAbility(RootUnit target, RootUnit owner, WorldAbility worldAbility, int numberOfCopies)
    {
        List <RootUnit> targets = GetInAreaRootUnit(10, worldAbility.transform.position, worldAbility.previousTargets);

        for (int i = 0; i < numberOfCopies && i < targets.Count; i++)
        {
            GameObject abilityResult = Instantiate(Resources.Load(String.Format("Prefabs/Abilities/Forms/{0}", worldAbility.wFormRune.formRuneType))) as GameObject;
            GameObject particles     = Instantiate(Resources.Load(String.Format("Prefabs/Abilities/Forms/{0}_Graphic/{1}_{0}_Graphic", worldAbility.wFormRune.formRuneType, worldAbility.wSchoolRune.schoolRuneType))) as GameObject;
            particles.transform.SetParent(abilityResult.transform);
            WorldAbility newWorldAbility = abilityResult.GetComponent <WorldAbility>();
            newWorldAbility.Construct(worldAbility, owner.unitID);
            newWorldAbility.targetPreference = targets[i].transform;
            newWorldAbility.previousTargets.Add(worldAbility.previousTargets.LastOrDefault());
            newWorldAbility.isTriggered      = true;
            abilityResult.transform.position = worldAbility.transform.position;
        }
    }
Esempio n. 23
0
        public CommandController(RootUnit root)
        {
            _root = root;

            if (_mqtt == null)
            {
                lock(_sync)
                {
                    if (_mqtt == null)
                    {
                        _mqtt = new MqttClient(ConfigurationManager.AppSettings["mqtt:host"], Convert.ToInt32(ConfigurationManager.AppSettings["mqtt:port"]), false,null,null,MqttSslProtocols.None);
                        _mqtt.ConnectionClosed += MqttReconnect;
                        MqttReconnect(null, null);
                        //_mqtt.Connect("my_unique_identifier", ConfigurationManager.AppSettings["mqtt:user"], ConfigurationManager.AppSettings["mqtt:password"]);
                    }
                }
            }
        }
Esempio n. 24
0
    public void ApplyHit(RootUnit target)
    {
        if ((target.unitID == wA.abilityOwner && wA.harmful && wA.selfHarm) || target.unitID != wA.abilityOwner)
        {
            DamageManager.CalculateAbilityDefender(target.unitID, wA);
        }

        if (wA.wEffectRunes != null)
        {
            foreach (var rune in wA.wEffectRunes)
            {
                if (rune.triggerTag == Rune.TriggerTag.OnHit)
                {
                    rune.Effect(target, GameWorldReferenceClass.GetUnitByID(wA.abilityOwner), wA);
                }
            }
        }
    }
Esempio n. 25
0
        public CommandController()
        {
            var user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <SmartHomeUserManager>().FindByName(System.Web.HttpContext.Current.User.Identity.Name);

            if (user != null && user.Profiles.Any())
            {
                _root = user.Profiles.Where(p => p.Name == user.DefaultProfileName).FirstOrDefault();
                _root.UpdateParents();
            }

            if (_mqtt == null)
            {
                lock (_sync)
                {
                    if (_mqtt == null)
                    {
                        _mqtt = new MqttClient(ConfigurationManager.AppSettings["mqtt:host"], Convert.ToInt32(ConfigurationManager.AppSettings["mqtt:port"]), false, null, null, MqttSslProtocols.None);
                        _mqtt.ConnectionClosed += MqttReconnect;
                        MqttReconnect(null, null);
                        //_mqtt.Connect("my_unique_identifier", ConfigurationManager.AppSettings["mqtt:user"], ConfigurationManager.AppSettings["mqtt:password"]);
                    }
                }
            }
        }
Esempio n. 26
0
    public bool TossItem(InventoryItem itemToRemove, int index)
    {
        if (RemoveItem(index))
        {
            RootUnit unitToDrop = GameWorldReferenceClass.GetUnitByID(owner);
            Vector3  pos        = unitToDrop.transform.position;

            if (ResourceManager.AllWorldItems.Count > 0)
            {
                WorldItem itemBeingCreated = ResourceManager.RestoreItem();
                itemBeingCreated.inventoryItem      = itemToRemove;
                itemBeingCreated.transform.position = new Vector3(UnityEngine.Random.Range(-.25f, .25f) + pos.x, .25f + pos.y, UnityEngine.Random.Range(-.25f, .25f) + pos.z);
                itemBeingCreated.transform.LookAt(unitToDrop.transform);
                itemBeingCreated.transform.Rotate(0, 180, 0);
                itemBeingCreated.GetComponent <Rigidbody>().velocity = itemBeingCreated.transform.forward * UnityEngine.Random.Range(4f, 7f);
                itemBeingCreated.transform.rotation = UnityEngine.Random.rotation;
                itemBeingCreated.transform.SetParent(GameObject.Find("Items").transform);
                itemBeingCreated.gameObject.SetActive(true);
                return(true);
            }
            else
            {
                GameObject freshWorldItem   = GameObject.Instantiate(Resources.Load("BlankItem")) as GameObject;
                WorldItem  itemBeingCreated = freshWorldItem.GetComponent <WorldItem>();
                itemBeingCreated.inventoryItem      = itemToRemove;
                itemBeingCreated.transform.position = new Vector3(UnityEngine.Random.Range(-.25f, .25f) + unitToDrop.transform.position.x, .25f + unitToDrop.transform.position.y, UnityEngine.Random.Range(-.25f, .25f) + unitToDrop.transform.position.z);
                itemBeingCreated.transform.LookAt(unitToDrop.transform);
                itemBeingCreated.transform.Rotate(0, 180, 0);
                itemBeingCreated.GetComponent <Rigidbody>().velocity = itemBeingCreated.transform.forward * UnityEngine.Random.Range(4f, 7f);
                itemBeingCreated.transform.rotation = UnityEngine.Random.rotation;
                freshWorldItem.transform.SetParent(GameObject.Find("Items").transform);
                return(true);
            }
        }
        return(false);
    }
Esempio n. 27
0
 public void FindTarget()
 {
     currentTarget = GameWorldReferenceClass.GetInAreaPlayer(20, transform.position);
 }
Esempio n. 28
0
 public virtual void Effect(RootUnit target, RootUnit owner, WorldAbility worldAbility)
 {
 }
Esempio n. 29
0
 public static void CalculateStatusDamage(RootUnit unit, float totalStatusTick)
 {
     unit.unitHealth += totalStatusTick;
     //unit.ResolveHit(totalStatusTick, true);
 }
Esempio n. 30
0
 public virtual bool Use(RootUnit user)
 {
     return(false);
 }
Esempio n. 31
0
 public override bool Use(RootUnit user)
 {
     return(inventoryItem.usableItem.Use(user, inventoryItem));
 }
Esempio n. 32
0
        private void CreateRootUnit()
        {
            _root = new RootUnit()
            {
                Id = "root",
                Name = "fazenda",
                DisplayName = "Фазенда",
                Sensors = new List<SensorBase>()
                {
                    new TemperatureSensor() { Id = "airtemp", Name = "temperature", DisplayName = "температура воздуха", HardId = "TM0001" },
                    new PressureSensor() { Id = "pressure", Name = "pressure", DisplayName = "атмосферное давление", HardId = "PR0001" },
                },
                Units = new List<CompositeObjectBase>()
                {
                    new House() {
                        Id = "house",
                        Name = "house",
                        DisplayName = "дом",
                        Sensors = new List<SensorBase>() {
                            new TemperatureSensor() { Id = "firstfloor", Name = "firstfloor", DisplayName = "температура на 1 этаже", HardId = "TM0002" },
                            new TemperatureSensor() { Id = "secondfloor", Name = "secondfloor", DisplayName = "температура на 2 этаже", HardId = "TM0003" },
                        },
                    },
                    new Greenhouse()
                    {
                        Id = "parnik1",
                        Name = "parnik1",
                        DisplayName = "теплица 1",
                        Sensors = new List<SensorBase>()
                        {
                            new TemperatureSensor() { Id = "temperature", Name = "temperature", DisplayName = "температура воздуха", HardId = "TM0004" }
                        },
                        Units = new List<CompositeObjectBase>()
                        {
                            new Barrel()
                            {
                                Id = "barrel1",
                                Name = "barrel1",
                                DisplayName = "бочка 1",
                                Commands = new List<Command>()
                                {
                                    new Command() { Id = "open", Name = "open", DisplayName = "открыть" },
                                    new Command() { Id = "close", Name = "close", DisplayName = "закрыть" }
                                },
                                Sensors = new List<SensorBase>()
                                {
                                    new LevelSensor() { Id = "level", Name = "level", DisplayName = "уровень", HardId = "LV0001" }
                                }
                            },

                            new Barrel()
                            {
                                Id = "barrel2",
                                Name = "barrel2",
                                DisplayName = "бочка 2",
                                Commands = new List<Command>()
                                {
                                    new Command() { Id = "open", Name = "open", DisplayName = "открыть" },
                                    new Command() { Id = "close", Name = "close", DisplayName = "закрыть" }
                                },
                                Sensors = new List<SensorBase>()
                                {
                                    new LevelSensor() { Id = "level", Name = "level", DisplayName = "уровень", HardId = "LV0002" }
                                }
                            }

                        }
                    }
                }

            };

            XmlSerializer xs = new XmlSerializer(_root.GetType());

            StringWriter sw = new StringWriter();

            xs.Serialize(sw, _root);

            var s = sw.ToString();

            var sr = new StringReader(s);

            var f = (RootUnit)xs.Deserialize(sr);

            var ss = "ok";
        }
Esempio n. 33
0
        private void CreateRootUnit()
        {
            _root = new RootUnit()
            {
                Id          = "root",
                Name        = "fazenda",
                DisplayName = "Фазенда",
                Sensors     = new List <SensorBase>()
                {
                    new TemperatureSensor()
                    {
                        Id = "airtemp", Name = "temperature", DisplayName = "температура воздуха", HardId = "TM0001"
                    },
                    new PressureSensor()
                    {
                        Id = "pressure", Name = "pressure", DisplayName = "атмосферное давление", HardId = "PR0001"
                    },
                },
                Units = new List <CompositeObjectBase>()
                {
                    new House()
                    {
                        Id          = "house",
                        Name        = "house",
                        DisplayName = "дом",
                        Sensors     = new List <SensorBase>()
                        {
                            new TemperatureSensor()
                            {
                                Id = "firstfloor", Name = "firstfloor", DisplayName = "температура на 1 этаже", HardId = "TM0002"
                            },
                            new TemperatureSensor()
                            {
                                Id = "secondfloor", Name = "secondfloor", DisplayName = "температура на 2 этаже", HardId = "TM0003"
                            },
                        },
                    },
                    new Greenhouse()
                    {
                        Id          = "parnik1",
                        Name        = "parnik1",
                        DisplayName = "теплица 1",
                        Sensors     = new List <SensorBase>()
                        {
                            new TemperatureSensor()
                            {
                                Id = "temperature", Name = "temperature", DisplayName = "температура воздуха", HardId = "TM0004"
                            }
                        },
                        Units = new List <CompositeObjectBase>()
                        {
                            new Barrel()
                            {
                                Id          = "barrel1",
                                Name        = "barrel1",
                                DisplayName = "бочка 1",
                                Commands    = new List <Command>()
                                {
                                    new Command()
                                    {
                                        Id = "open", Name = "open", DisplayName = "открыть"
                                    },
                                    new Command()
                                    {
                                        Id = "close", Name = "close", DisplayName = "закрыть"
                                    }
                                },
                                Sensors = new List <SensorBase>()
                                {
                                    new LevelSensor()
                                    {
                                        Id = "level", Name = "level", DisplayName = "уровень", HardId = "LV0001"
                                    }
                                }
                            },

                            new Barrel()
                            {
                                Id          = "barrel2",
                                Name        = "barrel2",
                                DisplayName = "бочка 2",
                                Commands    = new List <Command>()
                                {
                                    new Command()
                                    {
                                        Id = "open", Name = "open", DisplayName = "открыть"
                                    },
                                    new Command()
                                    {
                                        Id = "close", Name = "close", DisplayName = "закрыть"
                                    }
                                },
                                Sensors = new List <SensorBase>()
                                {
                                    new LevelSensor()
                                    {
                                        Id = "level", Name = "level", DisplayName = "уровень", HardId = "LV0002"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            XmlSerializer xs = new XmlSerializer(_root.GetType());

            StringWriter sw = new StringWriter();

            xs.Serialize(sw, _root);

            var s = sw.ToString();

            var sr = new StringReader(s);

            var f = (RootUnit)xs.Deserialize(sr);

            var ss = "ok";
        }