Пример #1
0
        public override bool Equals(object obj)
        {
            SendPoint tempObj = (SendPoint)obj;

            return((_point.Equals(tempObj.Point)) && (_id.Equals(tempObj.ID)));
        }
Пример #2
0
        public EnvironmentMessage Clone()
        {
            Object obj = null;

            if (_entity == null)
            {
                _entity = new SendPoint(0, new Point());
            }
            else if (_entity is Point)
            {
                Point temp = (Point)_entity;
                obj = new Point(temp.X, temp.Y);
            }
            else if (_entity is SendPoint)
            {
                SendPoint temp = (SendPoint)_entity;
                obj = new SendPoint(temp.ID, new Point(temp.Point.X, temp.Point.Y));
            }
            else if (_entity is AgentConfig)
            {
                AgentConfig temp        = (AgentConfig)_entity;
                Purpose     tempPurpose = new Purpose(temp.Purpose.Importance, temp.Purpose.Worship,
                                                      new Point(((Point)(temp.Purpose.Entity)).X, ((Point)(temp.Purpose.Entity)).Y));
                SortedList <TypeMessege, int> tempSortedList = new SortedList <TypeMessege, int>();
                List <List <Point> >          listConfig     = new List <List <Point> >();
                if (temp.ListConfig != null)
                {
                    List <Point> tempConfig;
                    foreach (List <Point> config in temp.ListConfig)
                    {
                        tempConfig = new List <Point>();
                        foreach (Point point in tempConfig)
                        {
                            tempConfig.Add(point);
                        }
                        listConfig.Add(tempConfig);
                    }
                }
                if (temp.ResponceTime != null)
                {
                    foreach (var i in temp.ResponceTime)
                    {
                        tempSortedList.Add(i.Key, i.Value);
                    }
                }
                Point tempPoint = new Point(temp.StartPoint.X, temp.StartPoint.Y);
                obj = new AgentConfig(temp.Name, temp.Color, temp.SenseOfPurpose,
                                      tempPurpose, temp.Worship, temp.Temper,
                                      temp.LifeCircle, temp.Attempt, tempSortedList,
                                      tempPoint, temp.Length, listConfig);
            }
            else if (_entity is EnvironmentConfig)
            {
                EnvironmentConfig             temp           = (EnvironmentConfig)_entity;
                Point                         tempPoint      = new Point(temp.OffsetXY.X, temp.OffsetXY.Y);
                SortedList <TypeMessege, int> tempSortedList = new SortedList <TypeMessege, int>();
                if (tempSortedList != null)
                {
                    foreach (var i in temp.Response)
                    {
                        tempSortedList.Add(i.Key, i.Value);
                    }
                }
                obj = new EnvironmentConfig(temp.Height, temp.Width, tempPoint, tempSortedList);
            }
            return(new EnvironmentMessage(_id, _idOwner, _typeMessege, _action, obj));
        }