Example #1
0
        // get the atom with the highest Sim() value to me in a structure
        public static clsGroundAtom findMostSimilarInStructure(clsGroundAtom me, clsPolygon structure)
        {
            // find most similar only in this agent's public space
            List <clsGroundAtom> comparisonAtoms = me.m_GameObject.getQuadTreeByStructure(structure).SearchEntities(me.curr_X, me.curr_Y, me.proxemics.publicSpace, isPrecise: true);

            return(findMostSimilarFromGroup(me, comparisonAtoms));
        }
Example #2
0
        // get a polygon by guid
        public static clsPolygon getPolygonByGuid(String guid)
        {
            string     sql     = "select * from Polygons where polygon_guid='" + guid + "'";
            clsPolygon polygon = GetPolygonBySql(sql);

            return(polygon);
        }
Example #3
0
        // get all polygon escape points for a specific polygon
        public static List <clsPolygonOpeningEscapePoint> getPolygonEscapePoints(clsPolygon polygon)
        {
            String sql = "select * from polygon_openings_escape_points where polygon_guid='" + polygon.PolygonGuid + "'";
            List <clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePointsBySql(sql);

            return(escapePoints);
        }
Example #4
0
        // get all polygon openings from database for a specific polygon
        public static List <clsPolygonOpening> getPolygonOpeningsByPolygon(clsPolygon polygon)
        {
            string sql = "select * from polygon_openings where polygon_guid='" + polygon.PolygonGuid + "'";
            List <clsPolygonOpening> openings = GetPolygonOpeningsBySql(sql);

            return(openings);
        }
Example #5
0
        public static clsPolygon GetPolygonByName(string Name)
        {
            string     sql     = "select * from Polygons where polygon_name='" + Name + "'";
            clsPolygon polygon = GetPolygonBySql(sql);

            return(polygon);
        }
Example #6
0
 public GO_AWAY_FROM_BUILDING_STATE(clsActivityMovement ActivityMovement, TerrainService.Vector targetPosition, clsPolygon Structure, int exitEdgeNumber)
     : base(ActivityMovement)
 {
     refActivityMovement = ActivityMovement;
     this.targetPosition = targetPosition;
     this.Structure      = Structure;
     this.exitEdgeNumber = exitEdgeNumber;
 }
Example #7
0
        private static clsPolygon GetPolygonBySql(string sql)
        {
            try
            {
                clsPolygon polygon = new clsPolygon();

                using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
                using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection))
                {
                    DataSet dsPol = new DataSet();
                    DataTable dtPol = new DataTable();
                    dsPol.Reset();
                    da.Fill(dsPol);
                    dtPol = dsPol.Tables[0];

                    if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0)
                    {
                        return null;
                    }

                    foreach (DataRow rowPol in dtPol.Rows)
                    {
                        polygon.PolygonName = rowPol["polygon_name"].ToString();
                        polygon.PolygonGuid = rowPol["polygon_guid"].ToString();                  


                    }
                }

                polygon.Points = getPolygonPoints(polygon.PolygonGuid);
				//YD:
				// get the polygon's openings
                polygon.PolygonOpenings = getPolygonOpeningsByPolygon(polygon);
				
				// get the escape points for each opening
                List<clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePoints(polygon);
                polygon.EscapePoints = new Dictionary<int, clsPolygonOpeningEscapePoint>();
                foreach (clsPolygonOpeningEscapePoint escapePoint in escapePoints)
                {
                    polygon.EscapePoints.Add(escapePoint.polygonEdgeNum, escapePoint);
                }
				// ---

                return polygon;
            }
            catch (Exception ex)
            {

            }
            return null;
        }
Example #8
0
        private static clsPolygon GetPolygonBySql(string sql)
        {
            try
            {
                clsPolygon polygon = new clsPolygon();

                using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
                    using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection))
                    {
                        DataSet   dsPol = new DataSet();
                        DataTable dtPol = new DataTable();
                        dsPol.Reset();
                        da.Fill(dsPol);
                        dtPol = dsPol.Tables[0];

                        if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0)
                        {
                            return(null);
                        }

                        foreach (DataRow rowPol in dtPol.Rows)
                        {
                            polygon.PolygonName = rowPol["polygon_name"].ToString();
                            polygon.PolygonGuid = rowPol["polygon_guid"].ToString();
                        }
                    }

                polygon.Points = getPolygonPoints(polygon.PolygonGuid);
                //YD:
                // get the polygon's openings
                polygon.PolygonOpenings = getPolygonOpeningsByPolygon(polygon);

                // get the escape points for each opening
                List <clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePoints(polygon);
                polygon.EscapePoints = new Dictionary <int, clsPolygonOpeningEscapePoint>();
                foreach (clsPolygonOpeningEscapePoint escapePoint in escapePoints)
                {
                    polygon.EscapePoints.Add(escapePoint.polygonEdgeNum, escapePoint);
                }
                // ---

                return(polygon);
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
Example #9
0
        private int getClosestExitPoint(clsGroundAtom refGroundAtom, clsPolygon Structure)
        {
            DPoint[] coordinates = refGroundAtom.m_GameObject.getRegularMovementCoordinates();
            DPoint   minPoint    = null;
            int      minIndex    = 0;

            for (int i = 0; i < coordinates.Count(); i++)
            {
                DPoint coordinate = coordinates[i];
                if (minPoint == null || TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, coordinate.x, coordinate.y) <
                    TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, minPoint.x, minPoint.y))
                {
                    minPoint = coordinate;
                    minIndex = i;
                }
            }

            return(minIndex);
        }
Example #10
0
		// get all polygon openings from database for a specific polygon
        public static List<clsPolygonOpening> getPolygonOpeningsByPolygon(clsPolygon polygon) {
            string sql = "select * from polygon_openings where polygon_guid='" + polygon.PolygonGuid + "'";
            List<clsPolygonOpening> openings = GetPolygonOpeningsBySql(sql);
            return openings;
        }
Example #11
0
 public SOCIAL_COMPARISON_IN_STRUCTURE_STATE(clsPolygon _Structure, clsGroundAtom mostSimilar)
     : base(_Structure)
 {
     this.mostSimilar = mostSimilar;
 }
Example #12
0
 public EXIT_STRUCTURE_STATE(clsPolygon _Structure) : base(_Structure)
 {
 }
Example #13
0
 public STAY_IN_STRUCTURE_STATE(clsPolygon _Structure)
     : base(_Structure)
 {
 }
Example #14
0
 public REGULAR_MOVEMENT_IN_STRUCTURE_STATE(clsPolygon _Structure, PolygonWaypoint nextWaypoint)
     : base(_Structure)
 {
     this.nextWaypoint = nextWaypoint;
 }
Example #15
0
 public MOVEMENT_IN_STRUCTURE_STATE(clsPolygon _Structure)
 {
     Structure = _Structure;
 }
Example #16
0
 public AtomAndStructureEventArgs(clsGroundAtom groundAtom, clsPolygon Structure)
 {
     this.groundAtom = groundAtom;
     this.Structure  = Structure;
 }
Example #17
0
        private int getClosestExitPoint(clsGroundAtom refGroundAtom, clsPolygon Structure)
        {
            DPoint[] coordinates = refGroundAtom.m_GameObject.getRegularMovementCoordinates();
            DPoint minPoint = null;
            int minIndex = 0;

            for (int i = 0; i < coordinates.Count(); i++)
            {
                DPoint coordinate = coordinates[i];
                if (minPoint == null || TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, coordinate.x, coordinate.y) <
                                      TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, minPoint.x, minPoint.y))
                {
                    minPoint = coordinate;
                    minIndex = i;
                }
            }

            return minIndex;
        }
Example #18
0
 public GO_AWAY_FROM_BUILDING_STATE(clsActivityMovement ActivityMovement, TerrainService.Vector targetPosition, clsPolygon Structure, int exitEdgeNumber)
     : base(ActivityMovement)
 {
     refActivityMovement = ActivityMovement;
     this.targetPosition = targetPosition;
     this.Structure = Structure;
     this.exitEdgeNumber = exitEdgeNumber;
 }
Example #19
0
 // get the atom with the highest Sim() value to me in a structure
 public static clsGroundAtom findMostSimilarInStructure(clsGroundAtom me, clsPolygon structure)
 {
     List<clsGroundAtom> comparisonAtoms = me.m_GameObject.getQuadTreeByStructure(structure).SearchEntities(me.curr_X, me.curr_Y, COMPARISON_RADIUS, isPrecise: true);
     return findMostSimilarFromGroup(me, comparisonAtoms);
 }
Example #20
0
 public STAY_IN_STRUCTURE_STATE(clsPolygon _Structure)
     : base(_Structure)
 {
 }
Example #21
0
 public REGULAR_MOVEMENT_IN_STRUCTURE_STATE(clsPolygon _Structure, PolygonWaypoint nextWaypoint)
     : base(_Structure)
 {
     this.nextWaypoint = nextWaypoint;
 }
Example #22
0
 public MOVEMENT_IN_STRUCTURE_STATE(clsPolygon _Structure)
 {
     Structure = _Structure;
     
 }
Example #23
0
		// get all polygon escape points for a specific polygon
        public static List<clsPolygonOpeningEscapePoint> getPolygonEscapePoints(clsPolygon polygon)
        {
            String sql = "select * from polygon_openings_escape_points where polygon_guid='" + polygon.PolygonGuid + "'";
            List<clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePointsBySql(sql);
            return escapePoints;
        }
Example #24
0
 public EXIT_STRUCTURE_STATE(clsPolygon _Structure) : base(_Structure)
 {
 }
Example #25
0
 public AtomAndStructureEventArgs(clsGroundAtom groundAtom, clsPolygon Structure)
 {
     this.groundAtom = groundAtom;
     this.Structure = Structure;
 }