Exemple #1
0
    public AnvilAgent(string agentName, string agentSerial, LatLng location, string faction)
    {
        this.agentName   = agentName;
        this.agentSerial = agentSerial;
        locationLatLng   = ConversionTool.LatLongFromUnityVector3D(transform.position);

        locString = locationLatLng.ToString();
    }
Exemple #2
0
    //Gear - links to equipments by Arrays and List of owned or accessible objects
    //Goals -links to drives and traits classes
    //working memory - unit level blackboard: navTarget, navSequence, schedule, goals, sensorTarget, sensorList
    //Senses - links to perception and awareness

    public AnvilAgent(string agentName, string agentSerial, LatLng location, string faction)
    {
        mAgentName   = agentName;
        mAgentSerial = agentSerial;
        mLocation    = ConversionTool.LatLongFromUnityVector3D(transform.position);
        mFaction     = faction;
        locString    = mLocation.ToString();
    }
Exemple #3
0
    void Update()
    {
        transformString = myTransform.position.x.ToString() + "," + myTransform.position.y.ToString();
        locationLatLng  = ConversionTool.LatLongFromUnityVector3D(myTransform.position);
        locString       = locationLatLng.ToString();


        if (Input.GetKey(KeyCode.Y))
        {
            moving = true;
        }

        if (moving)
        {
            //moveScript.moveToWaypoint (agentWayPoints [0]);
        }

        //activeWaypointName = mNavTarget.mWayPointName;
    }
Exemple #4
0
 public LatLng getLatLong()
 {
     return(locationLatLng = ConversionTool.LatLongFromUnityVector3D(transform.position));
 }
Exemple #5
0
 public Vector3 ToUnityVector3()
 {
     return(ConversionTool.LatLongToUnityVector3D(latLong));
 }
        public void InitializeDatabase(SchoolExpressDbContext context)
        {
            string[] entityNames =
            {
                "Campus",
                "ClassRoom",
                "Course",
                "Degree",
                "Career",
                "CareerDetail",
                "Module",
                "Period",
                "Person",
                "Speaker",
                "Student",
                "CareerSchedule",
                "CareerScheduleDetail",
                "Enrollment",
                "EnrollmentDetail"
            };

            IList <Type> entityTypes = AppDomain.CurrentDomain.GetAssemblies()
                                       .SelectMany(s => s.GetTypes())
                                       .Where(p => typeof(IEntity).IsAssignableFrom(p)).ToList();
            string dataSourcesPath = ConfigurationManager.AppSettings["DataSources"];

            if (string.IsNullOrEmpty(dataSourcesPath))
            {
                dataSourcesPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataSources", SchoolExpressDbContext.ProviderName, "Csv");
            }

            foreach (string entityName in entityNames)
            {
                string sourceFile = Path.Combine(dataSourcesPath, entityName + ".csv");
                Type   entityType = entityTypes.FirstOrDefault(t => t.Name == entityName);
                if (File.Exists(sourceFile) && entityType != null)
                {
                    bool tableHasIdentity = false;

                    if (SchoolExpressDbContext.ProviderName == "System.Data.SqlClient")
                    {
                        tableHasIdentity = context.Database.SqlQuery <int>("SELECT OBJECTPROPERTY(OBJECT_ID('" + entityName + "'), 'TableHasIdentity')").Single() == 1;
                        if (tableHasIdentity)
                        {
                            context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT " + entityName + " ON;");
                        }
                    }

                    using (StreamReader file = new StreamReader(sourceFile))
                    {
                        string   line;
                        int      counter    = 0;
                        string[] properties = { };
                        while ((line = file.ReadLine()) != null)
                        {
                            if (counter == 0)
                            {
                                properties = line.Split('|');
                            }
                            else
                            {
                                object   entity = Activator.CreateInstance(entityType);
                                string[] values = line.Split('|');
                                for (int i = 0; i < values.Length; i++)
                                {
                                    PropertyInfo propertyInfo = entityType.GetProperty(properties[i]);
                                    if (propertyInfo != null)
                                    {
                                        object value;
                                        string strValue = values[i].Trim('"').Trim();
                                        if (propertyInfo.PropertyType == typeof(bool))
                                        {
                                            value = ConversionTool.ConvertBoolean(strValue);
                                        }
                                        else if (propertyInfo.PropertyType == typeof(bool?))
                                        {
                                            value = ConversionTool.ConvertNullableBoolean(strValue);
                                        }
                                        else if (propertyInfo.PropertyType == typeof(TimeSpan))
                                        {
                                            value = ConversionTool.ConvertTimeSpan(strValue);
                                        }
                                        else if (propertyInfo.PropertyType == typeof(TimeSpan?))
                                        {
                                            value = ConversionTool.ConvertNullableTimeSpan(strValue);
                                        }
                                        else if (propertyInfo.PropertyType == typeof(DateTime))
                                        {
                                            value = ConversionTool.ConvertDateTime(strValue);
                                        }
                                        else if (propertyInfo.PropertyType == typeof(DateTime?))
                                        {
                                            value = ConversionTool.ConvertNullbleDateTime(strValue);
                                        }
                                        else
                                        {
                                            value = Convert.ChangeType(strValue, propertyInfo.PropertyType);
                                        }

                                        propertyInfo.SetValue(entity, value, null);
                                    }
                                }

                                context.Set(entityType).Add(entity);
                            }

                            counter++;
                        }
                    }

                    context.SaveChanges();

                    if (SchoolExpressDbContext.ProviderName == "System.Data.SqlClient" && tableHasIdentity)
                    {
                        context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT " + entityName + " OFF;");
                    }

                    if (SchoolExpressDbContext.ProviderName == "Npgsql")
                    {
                        IList <dynamic> results = context.DynamicListFromSql("SELECT table_schema, table_name, column_name FROM information_schema.columns WHERE column_default LIKE 'nextval%' AND table_name = '" + entityName + "';", new Dictionary <string, object>()).ToList();
                        foreach (var result in results)
                        {
                            context.Database.SqlQuery <int>("SELECT setval(pg_get_serial_sequence('\"" + result.table_schema + "\".\"" + result.table_name + "\"', '" + result.column_name + "'), CAST((SELECT MAX(\"" + result.column_name + "\") FROM \"" + result.table_schema + "\".\"" + result.table_name + "\") AS INTEGER));");
                        }
                    }
                }
            }
        }
Exemple #7
0
 void Update()
 {
     transformString = myTransform.position.x.ToString() + "," + myTransform.position.y.ToString();
     mLocation       = ConversionTool.LatLongFromUnityVector3D(myTransform.position);
     locString       = mLocation.ToString();
 }