示例#1
0
    public List <Unit> GetUnitsEnemyIsAttacking(Building building)
    {
        List <Unit> targets = new List <Unit>();

        AttackBuildingOrder ABO;

        foreach (AttackOrder AO in this.player.enemyAttackOrders)
        {
            if (AO.GetType() == typeof(AttackBuildingOrder))
            {
                ABO = (AttackBuildingOrder)AO;
                if (ABO.target == building)
                {
                    if (ABO.units.Count > 0)
                    {
                        return(ABO.units);
                    }
                    else
                    {
                        ABO.isActive = false;
                    }
                }
            }
        }

        return(targets);
    }
示例#2
0
        public void AO_test()
        {
            RGOBase.ClearAll();
            AO aout1 = new AO(1, "10100", IOCategory.Real, "test description");

            aout1.Value = 5.0;
            Assert.IsTrue(aout1.RawValue == 5.0);

            aout1.Convert = p => p * 2.0;

            aout1.Value = 5.0;
            Assert.IsTrue(aout1.RawValue == 10.0);

            aout1.OverRide           = true;
            aout1.OverrideValue      = 20.0;
            aout1.UseConvertFunction = false;
            aout1.Value = 5.0;
            Assert.IsTrue(aout1.RawValue == 20.0);

            aout1.UseConvertFunction = true;
            aout1.Value = 5.0;
            Assert.IsTrue(aout1.RawValue == 40.0);

            Assert.ThrowsException <NotImplementedException>(() => aout1.RawValue = 1.0);
        }
示例#3
0
    public static T load_asset <T>(string name_) where T : Object
    {
        int abi  = 0;
        AO  ao   = null;
        var name = name_.ToLower();

        DBGPRINT("ABM::load_asset:" + name);
        if (name_to_ao.TryGetValue(name, out ao))
        {
            //TODO: load_asset<Sprite> and load_asset<Texture2D> may has same name
            DBGPRINT("load_asset name:" + name + " hit");
            ++ao.refn;
            return((T)ao.asset);
        }
        if (abi_of_asset.TryGetValue(name, out abi) == false)
        {
            return(null);
        }
        var abo = load_abo(abi);

        if (abo == null)
        {
            return(null);
        }
        var asset = abo.ab.LoadAsset <T>(name);

        if (asset != null)
        {
            ao               = new AO(abi, name);
            ao.asset         = asset;
            name_to_ao[name] = ao;
            object_to_ao[asset.GetInstanceID()] = ao;
        }
        return(asset);
    }
示例#4
0
        public void CreateRGO(int nr)
        {
            int id = 10000;

            for (int i = 0; i < nr; i++)
            {
                var sv1 = new SV <double>(0, id++.ToString(), "The quick brown fox jumped over the lazy dog");
            }

            for (int i = 0; i < nr; i++)
            {
                var stp1 = new STP <double>(0, id++.ToString(), "This is an unused description");
            }

            for (int i = 0; i < nr; i++)
            {
                var ai = new AI(5, id++.ToString(), IOCategory.Real, "Test description that has no meaning");
                var ao = new AO(5, id++.ToString(), IOCategory.Real, "Test description that has no opinion");
                var di = new DI(5, id++.ToString(), IOCategory.Real, "Test description that has no purpose");
                var d0 = new DO(5, id++.ToString(), IOCategory.Real, "Test description that has no direction");
            }

            for (int i = 0; i < nr; i++)
            {
                var EQP1 = new EQP <double>(6, id++.ToString(), "VacuumSystem", "PumpTime", 5.5, 0, 10.3, Units.s, "This is a default description");
                var EQP2 = new EQP <int>(6, id++.ToString(), "Chuckdrive", "Travel", 5, 0, 10, Units.s, "This is a default description");
                var EQP3 = new EQP <bool>(6, id++.ToString(), "Source", "Rotationspeed", true, false, true, Units.s, "This is a default description");
            }
        }
示例#5
0
    string GetNumber(RobotSystem robotSystem)
    {
        var io = robotSystem.IO;

        return(io.UseControllerNumbering
         ? AO.ToString()
         : io.AO[AO]);
    }
示例#6
0
        string IDatabaseManagerService.getStrAO(string id)
        {
            AO tag = getByIdAO(id);

            if (tag == null)
            {
                return(null);
            }
            return(tag.ToString());
        }
示例#7
0
        public Y(string fullName, string description, int deviceNumber,
                 string objectName, int objectNumber, string articleName) : base(
                fullName, description, deviceNumber, objectName, objectNumber)
        {
            dSubType    = DeviceSubType.NONE;
            dType       = DeviceType.Y;
            ArticleName = articleName;

            AO.Add(new IOChannel("AO", -1, -1, -1, ""));
        }
示例#8
0
 //••••••••••••••••••••••••••••••••••••••••••••••••••••••••
 private bool IsAO(string _sAO)
 {
     for (AO ao = AO._FIRST; ao <= AO._LAST; ao++)
     {
         if (the(ao) == _sAO)
         {
             return(true);
         }
     }
     return(false);
 }
示例#9
0
    public static void ref_asset(int instance_id)
    {
        AO ao = null;

        if (object_to_ao.TryGetValue(instance_id, out ao))
        {
            ++ao.refn;
            DBGPRINT("ref_asset instance id:" + instance_id + " ref count:" + ao.refn);
        }
        System.Diagnostics.Debug.Assert(ao != null);
        return;
    }
示例#10
0
        public void deleteAO(string id)
        {
            lock (db.AOs)
            {
                AO tag = getByIdAO(id);
                db.AOs.Remove(tag);

                db.SaveChanges();
                DataManipulator.saveData();
                onChangeNotification.Invoke("Operation succesful.");
            }
        }
示例#11
0
 //••••••••••••••••••••••••••••••••••••••••••••••••••••••••
 /// <summary>check if expression is one of arithmetic operations
 /// predefined in m_sAO array</summary>
 /// <param name="_sAO">string to engage</param>
 /// <returns>true if `_sAO` is almost an operator or indeed
 /// the operator, false otherwise</returns>
 private bool IsMaybeAO(string _sAO)
 {
     for (AO ao = AO._FIRST; ao <= AO._LAST; ao++)
     {
         if (the(ao).StartsWith(_sAO) &&
             (_sAO.Length <= the(ao).Length))
         {
             return(true);
         }
     }
     return(false);
 }
示例#12
0
 public void changeValueAO(string id, double value)
 {
     lock (db.AOs)
     {
         AO tag = getByIdAO(id);
         foreach (AO t in db.AOs)
         {
             if (t.Address == tag.Address)
             {
                 t.InitValue = value;
             }
         }
         db.SaveChanges();
         DataManipulator.saveData();
         onChangeNotification.Invoke("Value changed.");
     }
 }
示例#13
0
    public List <Unit> GetUnitsEnemyIsAttacking(Unit unit)
    {
        AttackUnitOrder AUO;

        foreach (AttackOrder AO in this.player.enemyAttackOrders)
        {
            if (AO.GetType() == typeof(AttackUnitOrder))
            {
                AUO = (AttackUnitOrder)AO;
                if (AUO.targets.Contains(unit))
                {
                    return(AUO.units);
                }
            }
        }

        return(null);
    }
示例#14
0
    public static void unref_asset(int instance_id)
    {
        AO ao = null;

        if (object_to_ao.TryGetValue(instance_id, out ao) == false)
        {
            return;
        }
        --ao.refn;

        DBGPRINT("ABM::load_asset:" + ao.name);
        DBGPRINT("unref_asset instance id:" + instance_id + " ref count:" + ao.refn);
        if (ao.refn <= 0)
        {
            unload_abo(ao.abi);
            name_to_ao.Remove(ao.name);
            object_to_ao.Remove(instance_id);
        }
        return;
    }
示例#15
0
        public void addUpdateAO(string operation, string id, string description, string address, double initvalue, double lowlimit, double highlimit)
        {
            lock (db.AOs)
            {
                if (operation == "add")
                {
                    AO novi = new AO(id, description, address, initvalue, lowlimit, highlimit);
                    db.AOs.Add(novi);
                    db.SaveChanges();
                    DataManipulator.saveData();
                    return;
                }

                AO tag = getByIdAO(id);
                tag.Description = description;
                tag.Address     = address;
                tag.InitValue   = initvalue;
                tag.LowLimit    = lowlimit;
                tag.HighLimit   = highlimit;
                db.SaveChanges();
                DataManipulator.saveData();
                onChangeNotification.Invoke("Operation succesful.");
            }
        }
 /// <summary>
 /// Виконання арифметичних операцій
 /// </summary>
 /// <param name="delAO">делегат з арифметичною операцією</param>
 private void Result(AO delAO)
 {
     MainWindow.tbR.Text = delAO().ToString();
 }
示例#17
0
        static void Main()
        {
            // Enable Unicode
            Console.OutputEncoding = Encoding.Unicode;

            // набір допутимих опреацій
            string arrayOper = "+-/*";

            // Алгоритм Дейкстри
            for (; ;)
            {
                // чистка консолі
                Console.Clear();

                #region Перше число
                // введеня даних
                Console.Write("Введіть число: a = ");

                // зчитування числа
                bool next = double.TryParse(Console.ReadLine()
                                            .Replace(".", ","), out double a);

                // перевірка чи не було ввежено неправильно
                if (!next)
                {
                    Console.WriteLine("\n\tПомилка введення даних.\n" +
                                      "\tСпробувати ще раз?");
                    if (Console.ReadKey().Key == ConsoleKey.Enter)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }

                #endregion

                #region Арифметична операція
                // введеня даних
                Console.Write("Введіть арифметичну опрецію: ");

                // зчитування операції
                string oper = Console.ReadLine();

                // аналіз чи введений 1 символ і чи введена АО є в наборі
                if (!(oper.Length == 1 &&
                      arrayOper.Contains(oper)))
                {
                    Console.WriteLine("\n\tПомилка введення даних.\n" +
                                      "\tСпробувати ще раз?");
                    if (Console.ReadKey().Key == ConsoleKey.Enter)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                #endregion

                #region Друге число
                // введеня даних
                Console.Write("Введіть число: b = ");

                // зчитування числа
                next = double.TryParse(Console.ReadLine()
                                       .Replace(".", ","), out double b);

                // перевірка чи не було ввежено неправильно
                if (!next)
                {
                    Console.WriteLine("\n\tПомилка введення даних.\n" +
                                      "\tСпробувати ще раз?");
                    if (Console.ReadKey().Key == ConsoleKey.Enter)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                #endregion

                // створення делегата який виконуватиме АО
                AO del = default;

                // аналіз вибраної операції
                switch (oper)
                {
                case "+":       // лямда-вираз
                    del = (x, y) => x + y;
                    break;

                case "-":       // лямда-вираз
                    del = (x, y) => x - y;
                    break;

                case "*":       // лямда-вираз
                    del = (x, y) => x * y;
                    break;

                case "/":       // анонімний метод
                    del = delegate(double x, double y)
                    {
                        if (a == 0 && b == 0)
                        {
                            return(double.NaN);
                        }
                        else if (a > 0 && b == 0)
                        {
                            return(double.PositiveInfinity);
                        }
                        else if (a < 0 && b == 0)
                        {
                            return(double.NegativeInfinity);
                        }
                        else
                        {
                            return(a / b);
                        }
                    };
                    break;
                }

                // вивід результату
                Console.WriteLine($"\n\tРезультат: {a} {oper} {b} = {del(a, b):N2}");

                #region Повтор
                Console.WriteLine("\n\tСпробувати ще раз?");
                if (Console.ReadKey().Key == ConsoleKey.Enter)
                {
                    continue;
                }
                else
                {
                    break;
                }
                #endregion
            }
        }
示例#18
0
 //••••••••••••••••••••••••••••••••••••••••••••••••••••••••
 /// <summary>accessor of array of operations</summary>
 /// <param name="_AO">enumerator of operation</param>
 /// <returns>string equivalent to enumerator</returns>
 private string the(AO _ao)
 {
     return(m_sAO[(int)_ao]);
 }
示例#19
0
        //Takes all of the information in the record and put it into a string with the format that it needs to have to be saved in a file
        public string ToFile()
        {
            string ReturnString = "";

            foreach (ContractionIVDrip item in _contractionIVDRIPList)
            {
                ReturnString = ReturnString + item.ToString();
            }
            foreach (VaginalExploration item in _vaginalExplorationList)
            {
                ReturnString = ReturnString + item.ToString();
            }
            foreach (Micturition item in _micturitionList)
            {
                ReturnString = ReturnString + item.ToString();
            }
            foreach (FetusObservation item in FetusObservationList)
            {
                ReturnString = ReturnString + item.ToString();
            }
            foreach (BirthInformation item in BirthInformationList)
            {
                ReturnString = ReturnString + item.ToString();
            }
            ReturnString = (ReturnString + "_variables|" + ThisRecordID.ToString() + "|" + TimeOfBirth.ToString() + "|" + CircumferenceHead.ToString() + "|" + CircumferenceStomach.ToString() + "|" + BloodSugar.ToString() + "|" + GA + "|" + NavelpHVenous.ToString() + "|" + NavelpHArterial.ToString() + "|" + NavelBaseExcessArterial.ToString() + "|" + NavelBaseExcessVenous.ToString() + "|" + FetusPosition.ToString() + "|" + PlacentaWeight.ToString() + "|" + KVitamin.ToString() + "|" + ApgarOneMinute.ToString() + "|" + ApgarFiveMinutes.ToString() + "|" + ApgarTenMinutes.ToString() + "|" + AO.ToString() + "|" + HO.ToString() + "|" + Weight.ToString() + "|" + Length.ToString() + "|" + NumberOfChildren + "|" + FurtherNotice + "|" + Sucking.ToString() + "|" + Nose.ToString() + "|" + Pharynx.ToString() + "|" + Ventricle.ToString() + "|" + Diagnosis + "|" + Note + "|" + NewNote + "|" + ApgarOneMinuteNote + "|" + ApgarFiveMinuteNote + "|" + ApgarTenMinuteNote + "|" + BreastFeedingNote + "|" + BirthComplications.ToString() + "|" + IsActive.ToString() + "|" + ChildCPR);
            foreach (string item in Diseases)
            {
                ReturnString = ReturnString + "|" + item;
            }
            return(ReturnString);
        }
示例#20
0
    protected void RemoveAnotherOrder(List <Unit> units)
    {
        Player player = GameController.players[units[0].idPlayer];
        Unit   unit   = units[0];

        FindAndAttackOrder FAO;
        MovementOrder      MO;
        DefenseOrder       DO;
        AttackOrder        AO;
        BuildOrder         BO;

        foreach (Order order in GameController.players[unit.idPlayer].orders)
        {
            if (order != this)
            {
                if (!unit.isBusy && order.GetType() == typeof(MovementOrder))
                {
                    MO = (MovementOrder)order;

                    if (MO.units.Contains(unit))
                    {
                        if (MO.units.Count != units.Count)
                        {
                            foreach (Unit unitItem in units)
                            {
                                MO.units.Remove(unitItem);
                            }

                            if (MO.units.Count > 0)
                            {
                                player.standbyOrders.Add(MO.Clone());
                            }
                        }

                        MO.isActive = false;

                        break;
                    }
                }
                else
                {
                    if (order.GetType().BaseType == typeof(AttackOrder))
                    {
                        AO = (AttackOrder)order;

                        if (AO.units.Contains(unit))
                        {
                            if (AO.units.Count != units.Count)
                            {
                                foreach (Unit unitItem in units)
                                {
                                    AO.units.Remove(unitItem);
                                }

                                if (AO.units.Count > 0)
                                {
                                    player.standbyOrders.Add(AO.Clone());
                                }
                            }

                            //Debug.Log("Remove AO");
                            GameController.players[(this.idPlayer == 0 ? 1 : 0)].enemyAttackOrders.Remove(AO);
                            AO.isActive = false;

                            break;
                        }
                    }
                    else if (order.GetType() == typeof(BuildOrder) && unit.GetType().BaseType == typeof(Worker))
                    {
                        BO = (BuildOrder)order;

                        if (BO.workers.Contains((Worker)unit))
                        {
                            if (BO.workers.Count != units.Count)
                            {
                                foreach (Worker unitItem in units)
                                {
                                    BO.workers.Remove(unitItem);
                                }

                                if (BO.workers.Count > 0)
                                {
                                    player.standbyOrders.Add(BO.Clone());
                                }
                            }

                            BO.isActive = false;

                            break;
                        }
                    }
                    else if (order.GetType() == typeof(DefenseOrder))
                    {
                        DO = (DefenseOrder)order;

                        if (this.GetType() == typeof(DefenseOrder))
                        {
                            DefenseOrder DefenseOrderOld = (DefenseOrder)this;

                            if (DO.units.Contains(unit))
                            {
                                if (DO.units.Count == units.Count && DO.building != DefenseOrderOld.building)
                                {
                                    foreach (Unit unitItem in units)
                                    {
                                        DO.units.Remove(unitItem);
                                    }

                                    if (DO.units.Count > 0)
                                    {
                                        player.standbyOrders.Add(DO.Clone());
                                    }

                                    DO.isActive = false;
                                }

                                break;
                            }
                        }

                        if (DO.units.Contains(unit))
                        {
                            if (DO.units.Count != units.Count)
                            {
                                foreach (Unit unitItem in units)
                                {
                                    DO.units.Remove(unitItem);
                                }

                                if (DO.units.Count > 0)
                                {
                                    player.standbyOrders.Add(DO.Clone());
                                }
                            }

                            DO.isActive = false;

                            break;
                        }
                    }
                    else if (order.GetType() == typeof(FindAndAttackOrder))
                    {
                        FAO = (FindAndAttackOrder)order;

                        if (FAO.units.Contains(unit))
                        {
                            if (FAO.units.Count != units.Count)
                            {
                                foreach (Worker unitItem in units)
                                {
                                    FAO.units.Remove(unitItem);
                                }

                                if (FAO.units.Count > 0)
                                {
                                    player.standbyOrders.Add(FAO.Clone());
                                }
                            }

                            FAO.isActive = false;
                            break;
                        }
                    }
                }
            }
        }
    }