Exemple #1
0
        protected void Start()
        {
            //
            //
            m_placementAngleMinDeg -= (int)transform.rotation.eulerAngles.y;
            m_placementAngleMinDeg  = m_placementAngleMinDeg % 360;
            m_placementAngleMaxDeg -= (int)transform.rotation.eulerAngles.y;
            m_placementAngleMaxDeg  = m_placementAngleMaxDeg % 360;

            if (m_placementAngleMaxDeg < m_placementAngleMinDeg)
            {
                int tmp = m_placementAngleMaxDeg;
                m_placementAngleMaxDeg = m_placementAngleMinDeg;
                m_placementAngleMinDeg = tmp;
            }

            //
            //
            m_placementAngleMin = m_placementAngleMinDeg * Mathf.Deg2Rad;
            m_placementAngleMax = m_placementAngleMaxDeg * Mathf.Deg2Rad;

            //
            //
            FindStep();

            //
            //
            m_pointCount = Mathf.CeilToInt((m_placementAngleMax - m_placementAngleMin) / m_placementStep);

            if (m_pointCount != 0)
            {
                aLocations = new SLocation[m_pointCount];
                float fCurrentAngle = m_placementAngleMin;
                for (int pointNum = 0; pointNum < m_pointCount; ++pointNum)
                {
                    aLocations[pointNum] = new SLocation
                    {
                        vLocation = ComputePoint(fCurrentAngle),
                        unit      = null,
                        bReserved = false,
                    };

                    //GameObject prim2 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    //prim2.transform.position = aLocations[pointNum].vLocation;

                    fCurrentAngle += m_placementStep;

                    if ((Mathf.Deg2Rad * 360.0f) - m_placementStep < fCurrentAngle)
                    {
                        m_pointCount = pointNum;
                        break;
                    }
                }
            }

            SetHp(m_hp);
            m_objectUI.SetProgressBarDisplayed(false);
        }
Exemple #2
0
        static void Main()
        {
            #region Definations
            IBase     _SBase     = new SBase();
            ICommand  _SCommand  = new SCommand(_SBase);
            ILocation _SLocation = new SLocation(_SCommand);
            IRover    _SRover    = new SRover(_SCommand, _SBase, _SLocation);
            IPlateau  _SPlateau  = new SPlateau();
            #endregion

            #region Test Input One
            Plateau plateau = _SPlateau.createPlateau(5, 5);
            Dictionary <Rover, bool> firstRover = _SRover.setRoverLocation(plateau, 1, 2, enumMainDirections.N);

            if (firstRover.FirstOrDefault().Value)
            {
                Dictionary <Rover, bool> firstRoverResponse = _SRover.updateRoverLocation(plateau, firstRover.FirstOrDefault().Key, "LMLMLMLMM");
                _SLocation.roverResultLocation(firstRoverResponse);
            }
            else
            {
                _SCommand.printInvalidLocationOrDirection();
            }
            #endregion

            #region Test Input Two
            Dictionary <Rover, bool> secondRover = _SRover.setRoverLocation(plateau, 3, 3, enumMainDirections.E);
            if (firstRover.FirstOrDefault().Value)
            {
                Dictionary <Rover, bool> secondRoverResponse = _SRover.updateRoverLocation(plateau, secondRover.FirstOrDefault().Key, "MMRMMRMRRM");
                _SLocation.roverResultLocation(secondRoverResponse);
            }
            else
            {
                _SCommand.printInvalidLocationOrDirection();
            }
            #endregion

            Console.ReadLine();
        }
        private void SetElement(XElement Element, Action<int> Progress)
        {
            try
            {
                this.SchoolYear = Element.AttributeText("SchoolYear");
                this.Semester = Element.AttributeText("Semester");

                ClassResult = new SIntegrationResult<SClass>();
                ClassResult.Data = new List<SClass>();

                XElement elmClasses = Element.Element("Classes");

                if (elmClasses != null)
                {
                    foreach (XElement SubElement in elmClasses.Elements("Class"))
                    {
                        SClass Class = new SClass();
                        Class.Load(SubElement);
                        ClassResult.Data.Add(Class);
                    }
                }

                ClassBusysResult = new SIntegrationResult<SClassBusy>();
                ClassBusysResult.Data = new List<SClassBusy>();

                XElement elmClassBuys = Element.Element("ClassBusys");

                if (elmClassBuys != null)
                {
                    foreach (XElement SubElement in elmClassBuys.Elements("ClassBusy"))
                    {
                        SClassBusy ClassBusy = new SClassBusy();
                        ClassBusy.Load(SubElement);
                        ClassBusysResult.Data.Add(ClassBusy);
                    }
                }

                Progress.Invoke(10);

                TeacherResult = new SIntegrationResult<STeacher>();
                TeacherResult.Data = new List<STeacher>();

                XElement elmTeachers = Element.Element("Teachers");

                if (elmTeachers != null)
                {
                    foreach (XElement SubElement in elmTeachers.Elements("Teacher"))
                    {
                        STeacher Teacher = new STeacher();
                        Teacher.Load(SubElement);
                        TeacherResult.Data.Add(Teacher);
                    }
                }

                FullTeacherResult = new SIntegrationResult<STeacher>();
                FullTeacherResult.Data = new List<STeacher>();

                XElement elmFullTeacher = Element.Element("FullTeachers");

                if (elmFullTeacher != null)
                {
                    foreach (XElement SubElement in elmFullTeacher.Elements("Teacher"))
                    {
                        STeacher Teacher = new STeacher();
                        Teacher.Load(SubElement);
                        FullTeacherResult.Data.Add(Teacher);
                    }
                }

                Progress.Invoke(20);

                TeacherBusysResult = new SIntegrationResult<STeacherBusy>();
                TeacherBusysResult.Data = new List<STeacherBusy>();

                XElement elmTeacherBusy = Element.Element("TeacherBusys");

                if (elmTeacherBusy != null)
                {
                    foreach (XElement SubElement in  elmTeacherBusy.Elements("TeacherBusy"))
                    {
                        STeacherBusy TeacherBusy = new STeacherBusy();
                        TeacherBusy.Load(SubElement);
                        TeacherBusysResult.Data.Add(TeacherBusy);
                    }
                }

                Progress.Invoke(30);

                CourseSectionResult = new SIntegrationResult<SCourseSection>();
                CourseSectionResult.Data = new List<SCourseSection>();

                XElement elmCourseSections = Element.Element("CourseSections");

                if (elmCourseSections != null)
                {
                    foreach (XElement SubElement in elmCourseSections.Elements("CourseSection"))
                    {
                        SCourseSection CourseSection = new SCourseSection();
                        CourseSection.Load(SubElement);
                        CourseSectionResult.Data.Add(CourseSection);
                    }
                }

                Progress.Invoke(40);

                ClassroomResult = new SIntegrationResult<SClassroom>();
                ClassroomResult.Data = new List<SClassroom>();

                XElement elmClassrooms = Element.Element("Classrooms");

                if (elmClassrooms!=null)
                {
                    foreach (XElement SubElement in elmClassrooms.Elements("Classroom"))
                    {
                        SClassroom Classroom = new SClassroom();

                        Classroom.Load(SubElement);

                        ClassroomResult.Data.Add(Classroom);
                    }
                }

                Progress.Invoke(50);

                ClassroomBusysResult = new SIntegrationResult<SClassroomBusy>();
                ClassroomBusysResult.Data = new List<SClassroomBusy>();

                XElement elmClassroomBusys = Element.Element("ClassroomBusys");

                if (elmClassroomBusys != null)
                {
                    foreach (XElement SubElement in elmClassroomBusys.Elements("ClassroomBusy"))
                    {
                        SClassroomBusy ClassroomBusy = new SClassroomBusy();
                        ClassroomBusy.Load(SubElement);
                        ClassroomBusysResult.Data.Add(ClassroomBusy);
                    }
                }

                Progress.Invoke(60);

                LocationResult = new SIntegrationResult<SLocation>();
                LocationResult.Data = new List<SLocation>();

                XElement elmLocations = Element.Element("Locations");

                if (elmLocations != null)
                {
                    foreach (XElement SubElement in elmLocations.Elements("Location"))
                    {
                        SLocation Location = new SLocation();

                        Location.Load(SubElement);

                        LocationResult.Data.Add(Location);
                    }
                }

                Progress.Invoke(70);

                TimeTableResult = new SIntegrationResult<STimeTable>();
                TimeTableResult.Data = new List<STimeTable>();

                XElement elmTimeTables = Element.Element("TimeTables");

                if (elmTimeTables != null)
                {
                    foreach (XElement SubElement in elmTimeTables.Elements("TimeTable"))
                    {
                        STimeTable TimeTable = new STimeTable();

                        TimeTable.Load(SubElement);

                        TimeTableResult.Data.Add(TimeTable);
                    }
                }

                Progress.Invoke(80);

                TimeTableSecsResult = new SIntegrationResult<STimeTableSec>();
                TimeTableSecsResult.Data = new List<STimeTableSec>();

                XElement elmTimeTableSecs = Element.Element("TimeTableSecs");

                if (elmTimeTableSecs != null)
                {
                    foreach (XElement SubElement in elmTimeTableSecs.Elements("TimeTableSec"))
                    {
                        STimeTableSec TimeTableSec = new STimeTableSec();

                        TimeTableSec.Load(SubElement);

                        TimeTableSecsResult.Data.Add(TimeTableSec);
                    }
                }

                Progress.Invoke(90);

                Subjects = CourseSectionResult.Data.Select(x => x.Subject).Distinct().ToList();

                Progress.Invoke(100);

                IsSuccess = true;
            }
            catch (Exception e)
            {
                IsSuccess = false;

                throw e;
            }
        }