Ejemplo n.º 1
0
 public Node(IHuman data, Node left, Node right)
 {
     Data  = data;
     Left  = left;
     Right = right;
     Level = 1;
 }
Ejemplo n.º 2
0
 public Node(IHuman data)
 {
     Data  = data;
     Left  = null;
     Right = null;
     Level = 1;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Купить билет.
        /// </summary>
        /// <param name="who">Кто.</param>
        /// <param name="cityName">Город.</param>
        /// <param name="requiredTransport">Требование типа транспорта.</param>
        /// <returns>Билет.</returns>
        public ITicket Buy(IHuman who, string cityName, string requiredTransport)
        {
            if (who == null)
            {
                throw new ArgumentNullException(nameof(who));
            }
            if (cityName == null)
            {
                throw new ArgumentNullException(nameof(cityName));
            }
            if (requiredTransport == null)
            {
                throw new ArgumentNullException(nameof(requiredTransport));
            }

            var where = _cityMap.Find(cityName);
            if (where == null)
            {
                throw new NullReferenceException($"Пункт назначения '{cityName}' не найден.");
            }

            var route = _cityMap.GetRoute(who.City, where, t => t.GetType().Name == requiredTransport);

            if (route == null)
            {
                throw new NullReferenceException($"Маршрута из {who.City.Name} в {where.Name} на транспорте '{requiredTransport}' не существует.");
            }

            return(new Ticket <ITransport>(who, where, route.Item3));
        }
Ejemplo n.º 4
0
    public static IHuman HumanNearbyPosition(Vector3 position, bool noCast, float maxDist)
    {
        IHuman[] humans = DataCenter.dataCenter.humans;
        IHuman   finded = null;
        float    dist   = maxDist;

        for (int i = 0; i < humans.Length; i++)
        {
            float cur = (humans [i].trans.position - position).magnitude;
            if (!noCast)
            {
                if (cur < dist)
                {
                    finded = humans [i];
                    dist   = cur;
                }
            }
            else
            {
                if (cur < dist && !Physics.Linecast(position + Vector3.up * headHeight,
                                                    humans [i].trans.position + Vector3.up * headHeight))
                {
                    finded = humans [i];
                    dist   = cur;
                }
            }
        }
        return(finded);
    }
Ejemplo n.º 5
0
 static public void Print(IHuman list)
 {
     for (int i = 0; i < list.Length; i++)
     {
         Console.WriteLine(list[i]);
     }
 }
Ejemplo n.º 6
0
        public void TestMethod2()
        {
            IHumanFactory maleFactory   = new MaleFactory();
            IHumanFactory femaleFactory = new FemaleFactory();

            IHuman maleWhiteHuman   = maleFactory.CreateWhiteHuman();
            IHuman femaleWhiteHuman = femaleFactory.CreateWhiteHuman();

            maleWhiteHuman.GetSex();
            maleWhiteHuman.Move();

            femaleWhiteHuman.GetSex();
            femaleWhiteHuman.Move();

            IHuman maleBlackHuman   = maleFactory.CreateBlackHuman();
            IHuman femaleBlackHuman = femaleFactory.CreateBlackHuman();

            maleBlackHuman.GetSex();
            maleBlackHuman.Move();
            femaleBlackHuman.GetSex();
            femaleBlackHuman.Move();
            //Output:
//            White Human, I 'am Men
//White Person is Moving
//White Human, I 'am Women
//White Person is Moving
//Black Human, I 'am Men
//Black Person is Moving
//Black Human, I 'am Women
//Black Person is Moving
        }
Ejemplo n.º 7
0
            public void Show(IHuman H)
            {
                IniFileAttribute FN = (IniFileAttribute)((Attribute[])typeof(Student).GetProperties()[0].GetCustomAttributes())[0];
                IniFileAttribute SN = (IniFileAttribute)((Attribute[])typeof(Student).GetProperties()[1].GetCustomAttributes())[0];
                IniFileAttribute Gr = (IniFileAttribute)((Attribute[])typeof(Student).GetProperties()[2].GetCustomAttributes())[0];

                try
                {
                    FileStream fs = new FileStream("LogFile.log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                    using (Loger writeTo = new Loger(fs, "Log.ini"))
                    {
                        try
                        {
                            H.FName = ReadValueFromFile(FN.FileName);
                            H.SName = ReadValueFromFile(SN.FileName);
                            if (H is Student)
                            {
                                (H as Student).Group = Convert.ToInt32(ReadValueFromFile(Gr.FileName));
                            }
                        }
                        catch (Exception ex)
                        {
                            writeTo.Logs("error", ex.Message);
                        }
                    }
                    Console.WriteLine(H);
                }
                catch
                {
                    throw;
                }
            }
Ejemplo n.º 8
0
 public void SpawnHumans()
 {
     factory = FactoryProducer.GetFactory(FactoryType.Human);
     if (!(env.time.text == "9:00 AM") && (env.isRaining == false))
     {
         m_Beggar = factory.GetHuman(HumanType.Beggar);
         m_Beggar.Speak();
         GameObject beggarInstance = Instantiate(Resources.Load("Beggar", typeof(GameObject))) as GameObject;
         beggarInstance.transform.position = new Vector3((Random.Range(-10f, 10f)), 0, 0);
     }
     if (!(env.time.text == "10:00 PM"))
     {
         m_Farmer = factory.GetHuman(HumanType.Farmer);
         m_Farmer.Speak();
         GameObject farmerInstance = Instantiate(Resources.Load("Farmer", typeof(GameObject))) as GameObject;
         farmerInstance.transform.position = new Vector3((Random.Range(-10f, 10f)), 0, 0);
     }
     if (env.isRaining == false)
     {
         m_Shopowner = factory.GetHuman(HumanType.Shopowner);
         m_Shopowner.Speak();
         GameObject shopownerInstance = Instantiate(Resources.Load("Shopkeeper", typeof(GameObject))) as GameObject;
         shopownerInstance.transform.position = new Vector3((Random.Range(-10f, 10f)), 0, 0);
     }
 }
        public void Get_Null_Human()
        {
            IHuman mockHuman = null;

            mockHumanFactory.CreateHuman(mockHuman);
            var actualHuman = mockHumanFactory.GetInstance();
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Person person  = new Person("Adam", "Smith", null);
            var    fulName = person.FullName;
            string a       = person.FirstName;
            string?b       = person.MiddleName;
            string c       = person.LastName;


            Human human = new Human()
            {
                Name = "Jonn"
            };
            //human.SayHello();


            IHuman cast = (IHuman)human;

            cast.SayHello();

            IHuman human1 = new Human()
            {
                Name = "Weight"
            };

            human1.SayHello();

            ((IHuman) new Human {
                Name = "Milla"
            }).SayHello();

            ((ICopyHuman) new Human {
                Name = "Azad"
            }).SayHello();
        }
Ejemplo n.º 11
0
 public void SendClientHome(IHuman human)
 {
     if (this.clients != null && this.clients.Count > 0)
     {
         this.clients.Remove(human);
     }
 }
Ejemplo n.º 12
0
        public static IHuman[] Get(IHuman[] people, string gender)
        {
            if (!(gender.ToLower().Equals("male") || gender.ToLower().Equals("female")))
            {
                return(null);
            }

            int genderCount = 0;

            foreach (IHuman person in people)
            {
                if (person.Gender.Equals(gender))
                {
                    genderCount++;
                }
            }

            if (genderCount == 0)
            {
                return(new Person[0]);
            }

            IHuman[] result = new IHuman[genderCount];
            int      i      = 0;

            foreach (IHuman person in people)
            {
                if (person.Gender.Equals(gender))
                {
                    result[i++] = person;
                }
            }

            return(result);
        }       //получение всех объектов заданного пола из заданного массива объектов типа IHuman
Ejemplo n.º 13
0
        public KmsHuman(Main trayPtn, KmsRobot robot, DataModel dataModel)
        {
            _TrayPtn = trayPtn;
            _Robot = robot;
            _DataModel = dataModel;

            InitializeComponent();
            BtRes.Image = _ResLeave;

            CbRes.Items.Add(new MCategory { C2010203 = "0", C2010205 = "请选择" });
            CbRes.Items.AddRange(_DataModel.ListCategory().ToArray());
            CbRes.SelectedIndex = 0;
            MiTxt.Checked = true;

            if (_TxtLast == null)
            {
                _TxtLast = new TxtDefault(this, _DataModel);
            }
            ShowControl(_TxtLast.Control);

            Rectangle rect = Screen.PrimaryScreen.WorkingArea;
            _MagicPtn = new MagicPtn(this);
            _MagicPtn.UseDefaultAction();
            _MagicPtn.ExitButtonHandler = PbExit_Click;
            _MagicPtn.Location = new Point(rect.Width - _MagicPtn.Width, rect.Height - _MagicPtn.Height);
            _MagicPtn.Text = "会话";
        }
Ejemplo n.º 14
0
    public void DeleteHuman(IHuman record)
    {
        if (record == null)
        {
            return;
        }
        Human _record_;
        var   deletionList = new System.Collections.Generic.HashSet <IDelRecord>();

        if (!_human_pk.TryGetValue(record.Id, out _record_))
        {
            throw new ArgumentException(String.Format(
                                            "'Human' with id '{0}' does not exist.",
                                            record.Id));
        }
        _record_.PreDeleteOuter(deletionList, false);
        foreach (IDelRecord item in deletionList)
        {
            item.EnsureCanDelete(deletionList);
        }
        foreach (IDelRecord item in deletionList)
        {
            item.DoDelete(this, deletionList);
        }
    }
Ejemplo n.º 15
0
 public override void AddHuman(IHuman human)
 {
     HumanList.Add(human);
     if (human.MyRoom == this)                                                       // If the specified room the human is walking to is equal to the this room change the room to an occupied room.
     {
         hotelNode.BackgroundImage = spriteOccupied;
     }
 }
Ejemplo n.º 16
0
    private static void CheckHuman(IHuman human, double weight, int dna)
    {
        // item 409
        Human human_ = (Human)human;

        Equal(weight, human_._weight);
        Equal(dna, human_._dna);
    }
Ejemplo n.º 17
0
    public virtual void InitEquipment(SkillRunner runner, ItemObject item)
    {
        mSkillRunner = runner;
        mHuman       = mSkillRunner as IHuman;
//		InitNetworkLayer(runner.Netlayer);
        mItemObj    = item;
        mSkillIndex = 0;
        //mMainPlayerEquipment = mSkillRunner == PlayerFactory.mMainPlayer;
    }
Ejemplo n.º 18
0
 private void Start()
 {
     brain = GetComponent <IHuman>();
     if (PickRandomName)
     {
         _myName = AdjectiveHolder.GetRandomName();
     }
     GameObject.FindObjectOfType <MoveManager>().RegisterPlayer(this);
 }
Ejemplo n.º 19
0
        public void Add(IHuman human)
        {
            if (human == null)
            {
                throw new NullReferenceException("Human can't be null");
            }

            data.Add(human);
        }
Ejemplo n.º 20
0
 private void Attack(IHuman who)
 {
     if (canDoSomething)
     {
         who_under_attack = who;
         anims.SetFloat("AttackK", Random.Range(0, 3));
         Invoke("End_Attack", 1.5f);
     }
 }
Ejemplo n.º 21
0
    public void Spawn()
    {
        int   l   = 0;
        float max = maxCount;

        /*if (!ITimecycle.night) {
         *      max = maxCount / 2;
         * }*/
        if (human)
        {
            l = DataCenter.dataCenter.humans.Length;
        }
        else
        {
            l = DataCenter.dataCenter.zombies.Length;
        }
        if ((l < max && limit > 0) || (!IHuman.playerObj && human))
        {
            GameObject sp = (GameObject)Resources.Load("Prefabs/ZombieRag_" + Random.Range(0, 1));
            if (!human)
            {
                sp = Instantiate(sp, transform.position + (Vector3)Vector0.Flat(Random.onUnitSphere), Quaternion.identity, transform);
                IZombie z = sp.GetComponent <IZombie> ();
                z.findMode       = isFinders;
                z.savable.health = 100 + IZombie.dead * 10;
            }
            else
            {
                if (IHuman.playerObj)
                {
                    sp = (GameObject)Resources.Load("Prefabs/HumanRag");
                    sp = Instantiate(sp, transform.position + (Vector3)Vector0.Flat(Random.onUnitSphere), Quaternion.identity, transform);
                    IHuman h = sp.GetComponent <IHuman> ();
                    h.savable.name = "BOT";
                    Destroy(h.camObj);
                }
                else
                {
                    sp = (GameObject)Resources.Load("Prefabs/Human");
                    sp = Instantiate(sp, transform.position + (Vector3)Vector0.Flat(Random.onUnitSphere), Quaternion.identity, transform);
                    IHuman h = sp.GetComponent <IHuman> ();
                    h.savable.name = "player";
                    IHuman.GetPlayer();
                    ITimecycle.UpdateCameras();
                }
            }
        }
        if (limited)
        {
            limit -= 1;
        }
        if (!IsInvoking("Spawn"))
        {
            Invoke("Spawn", interval + Random.Range(0f, interval));
        }
    }
Ejemplo n.º 22
0
    private void OnTriggerEnter(Collider other)
    {
        IHuman h = other.GetComponentInParent <IHuman> ();

        if (h)
        {
            h.savable.patrones_ [type] += count;
            Destroy(gameObject);
        }
    }
Ejemplo n.º 23
0
 public void SpawnHumans()
 {
     factory     = FactoryProducer.GetFactory(FactoryType.Human);
     m_FratBoi   = factory.GetHuman(HumanType.FratBoi);
     m_Farmer    = factory.GetHuman(HumanType.Farmer);
     m_Shopowner = factory.GetHuman(HumanType.Shopowner);
     m_FratBoi.Speak();
     m_Farmer.Speak();
     m_Shopowner.Speak();
 }
Ejemplo n.º 24
0
 public void SpawnHumans()
 {
     factory     = FactoryProducer.GetFactory(FactoryType.Human);
     m_Beggar    = factory.GetHuman(HumanType.Beggar);
     m_Farmer    = factory.GetHuman(HumanType.Farmer);
     m_Shopowner = factory.GetHuman(HumanType.Shopowner);
     //m_Beggar.Speak();
     //m_Farmer.Speak();
     //m_Shopowner.Speak();
 }
Ejemplo n.º 25
0
    public ITool CreateTool(IHuman owner, decimal price, string usage)
    {
        // item 400
        ITool tool = InsertTool(0);

        tool.Usage = usage;
        tool.Price = price;
        SetItemOwner(tool, owner);
        // item 293
        return(tool);
    }
Ejemplo n.º 26
0
    public ISnack CreateSnack(IHuman owner, decimal price, string taste)
    {
        // item 391
        ISnack snack = InsertSnack(0);

        snack.Taste = taste;
        snack.Price = price;
        SetItemOwner(snack, owner);
        // item 286
        return(snack);
    }
Ejemplo n.º 27
0
        public HumanProxy()
        {
            this.obj = new MyHuman();
            Type mt = typeof(ServiceFabricModel.FabricActorMachine);

            id = ActorModel.Runtime.CreateMachine(mt);

            ServiceFabricModel.FabricActorMachine.InitEvent iev = new ServiceFabricModel.
                                                                  FabricActorMachine.InitEvent(obj);
            ActorModel.Runtime.SendEvent(id, iev);
        }
        public void GetOrder(IRestaurantOrder order, IHuman client)
        {
            // I am already serving dinner
            this.isAvailable = false;

            Console.WriteLine(new string('=', GlobalConstants.DelimitersCount));
            Console.WriteLine($"Waiter({this.Name}): - \"Waiting for client order...\"");
            Console.WriteLine($"Client({client.Name}): - \"Ordering foods and beverages...\"");

            this.orders.Add(client, order);
        }
Ejemplo n.º 29
0
 private void SetGender(string gender)
 {
     if (gender == "woman")
     {
         _human = new Woman();
     }
     else
     {
         _human = new Man();
     }
 }
Ejemplo n.º 30
0
 private void Start()
 {
     IHuman[] humans = DataCenter.dataCenter.humans;
     for (int i = 0; i < humans.Length; i++)
     {
         if (humans[i].savable.name == "player")
         {
             player = humans [i];
         }
     }
 }
Ejemplo n.º 31
0
        public void GetOrder(IRestaurantOrder order, IHuman client)
        {
            // I am already serving dinner
            this.isAvailable = false;

            Console.WriteLine(new string('=', GlobalConstants.DelimitersCount));
            Console.WriteLine($"Waiter({this.Name}): - \"Waiting for client order...\"");
            Console.WriteLine($"Client({client.Name}): - \"Ordering foods and beverages...\"");

            this.orders.Add(client, order);
        }
Ejemplo n.º 32
0
 private void SetIHuman()
 {
     for (int i = 0; i < _behaviorTreeEntity.ActionNodeList.Count; ++i)
     {
         NodeAction nodeAction = _behaviorTreeEntity.ActionNodeList[i];
         if (typeof(IHuman).IsAssignableFrom(nodeAction.GetType()))
         {
             IHuman iHuman = nodeAction as IHuman;
             iHuman.SetHuman(this);
         }
     }
 }
Ejemplo n.º 33
0
        public void AcceptClient(IHuman human)
        {
            if (human.Age < 14)
            {
                throw new ArgumentException("Too young to eat");
            }

            if (this.clients != null &&
                this.clients.Count < this.Capacity)
            {
                this.clients.Add(human);
            }
            else
            {
                throw new IndexOutOfRangeException("Nqma mqsto");
            }
        }
Ejemplo n.º 34
0
        public int Eat(ref int a, double b, object o, IHuman h)
        {
            var resultMailbox = runtime.CreateMailbox<object>();
            var hep = new HumanEatParams(a, b, o, h, resultMailbox);
            mailbox.Send(hep);
            hep = (HumanEatParams) resultMailbox.Receive();

            a = hep.a;

            var ex = hep.exception;

            if (ex != null)
            {
                ExceptionDispatchInfo.Capture(ex).Throw();
            }

            return hep.result;
        }
        static void Main(string[] args)
        {
            Student pesho = new Student("Pesho",1234);
            Student mariika = new Student("Mariika",1235);
            mariika.Details = "Keep eyes on her, is very horny !";
            Discipline cSharp = new Discipline("C#",2,pesho,mariika);

            Teacher nakov = new Teacher("Svetlin Nakov",cSharp);
            Teacher vlado = new Teacher("Vlado Karamfilov", cSharp);

            Class firstLevel = new Class(nakov, "Level 2");

            IHuman[] allPeopleInSchool = new IHuman[] {  vlado, pesho, mariika, nakov};

            var sortedPpl = allPeopleInSchool.OrderBy(p => p.GetType() == typeof(Student)).ThenBy(p=>p.Name).ToList();

            //Console.WriteLine(mariika.Name +" Number "+ mariika.UniqueClassNumber +" Details: "+mariika.Details);
            foreach (var ppl in sortedPpl)
            {
                //Sorted By Teachers then Students
                Console.WriteLine(ppl.Name);
            }
            Console.WriteLine();
        }
Ejemplo n.º 36
0
 public void SendClientHome(IHuman human)
 {
     if (this.clients != null && this.clients.Count > 0)
     {
         this.clients.Remove(human);
     }
 }
Ejemplo n.º 37
0
        private void CbRes_SelectedIndexChanged(object sender, EventArgs e)
        {
            // 语言资源
            if (MiTxt.Checked)
            {
                var cat = CbRes.SelectedItem as MCategory;
                if (cat == null || cat.C2010203 == "0")
                {
                    return;
                }
                _TxtLast.Init(cat.C2010203);
                return;
            }

            // 屏幕截图
            if (!MiImg.Checked)
            {
                return;
            }

            var item = CbRes.SelectedItem as Items;
            if (item == null)
            {
                return;
            }

            IHuman<Image> capture;
            switch (item.K)
            {
                case "screen":
                    if (_ImgScreen == null)
                    {
                        _ImgScreen = new ImgScreen(this);
                    }
                    capture = _ImgScreen;
                    break;
                case "window":
                    if (_ImgWindow == null)
                    {
                        _ImgWindow = new ImgWindow(this);
                    }
                    capture = _ImgWindow;
                    break;
                case "region":
                    if (_ImgRegion == null)
                    {
                        _ImgRegion = new ImgRegion(this);
                    }
                    capture = _ImgRegion;
                    break;
                case "control":
                    if (_ImgControl == null)
                    {
                        _ImgControl = new ImgControl(this);
                    }
                    capture = _ImgControl;
                    break;
                default:
                    if (_ImgDefault == null)
                    {
                        _ImgDefault = new ImgDefault(this);
                    }
                    capture = _ImgDefault;
                    break;
            }

            _ImgLast = capture;
            ShowControl(_ImgLast.Control);
        }
Ejemplo n.º 38
0
        private void MiTxt_Click(object sender, EventArgs e)
        {
            if (MiTxt.Checked)
            {
                return;
            }

            MiImg.Checked = false;
            MiTxt.Checked = true;

            CbRes.Items.Clear();
            CbRes.Items.Add(new MCategory { C2010205 = "请选择", C2010203 = "0" });
            CbRes.Items.AddRange(_DataModel.ListCategory().ToArray());
            CbRes.SelectedIndex = 0;
            CbRes.Focus();

            if (_TxtLast == null)
            {
                _TxtLast = new TxtDefault(this, _DataModel);
            }
            ShowControl(_TxtLast.Control);
        }
Ejemplo n.º 39
0
        public void RequestPayment(IHuman client)
        {
            var clientOrder = this.orders[client];
            var clientPayment = client.Pay(clientOrder.TotalOrderPrice);

            Console.WriteLine(new string('=', GlobalConstants.DelimitersCount));
            Console.WriteLine($"Payment made from: {client.Name}");
            Console.WriteLine($"Required payment amount: ${clientOrder.TotalOrderPrice}");
            Console.WriteLine($"Client payment amount: ${clientPayment}");

            if (clientPayment > clientOrder.TotalOrderPrice)
            {
                this.bakshishes += (clientPayment - clientOrder.TotalOrderPrice);
                this.restaurantProfits += clientOrder.TotalOrderPrice;
            }

            this.isAvailable = true;
        }
Ejemplo n.º 40
0
        public void ServeOrder(IHuman client)
        {
            var clientOrder = this.orders[client];

            Console.WriteLine(new string('=', GlobalConstants.DelimitersCount));
            Console.WriteLine($"Waiter({this.Name}): - \"Serving order to client ({client.Name})...\"");
            Console.WriteLine("Order details:");
            Console.WriteLine(clientOrder);

            client.Eat(clientOrder.Foods);
            client.Drink(clientOrder.Beverages);
        }
Ejemplo n.º 41
0
 public int Eat(ref int a, double b, object o, IHuman h)
 {
     Console.WriteLine($"I ate {a}, {b}, {o}, {h}");
     a = 2;
     return 1;
 }
Ejemplo n.º 42
0
        public int Colour(IHuman fig, int i = 0)
        {
            fig.Laugh();

            throw new System.NotImplementedException();
        }