Exemplo n.º 1
0
    static AnalyticsObject LoadBinary(string path)
    {
        AnalyticsObject ao = null;

        if (File.Exists(path))
        {
            FileStream      file   = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
            BinaryFormatter binary = new BinaryFormatter();
            ao = binary.Deserialize(file) as AnalyticsObject;
            file.Close();
        }
        return(ao);
    }
Exemplo n.º 2
0
    static AnalyticsObject LoadBinary(int id)
    {
        AnalyticsObject ao = null;

        if (File.Exists(Application.persistentDataPath + "/" + fileName + id + ".data"))
        {
            FileStream      file   = new FileStream(Application.persistentDataPath + "/" + fileName + id + ".data", FileMode.Open, FileAccess.Read, FileShare.Read);
            BinaryFormatter binary = new BinaryFormatter();
            ao = binary.Deserialize(file) as AnalyticsObject;
            file.Close();
        }
        return(ao);
    }
Exemplo n.º 3
0
        private static AnalyticsObject GetRectangle()
        {
            AnalyticsObject aObject;
            TPolygon        tPolygon;
            TColor          tColor;

            aObject              = new AnalyticsObject();
            aObject.Name         = "SuspectArea";
            aObject.AlarmTrigger = true;
            aObject.Value        = "A suspect item";
            aObject.Confidence   = 0.9;
            aObject.Description  = "Object description";
            tPolygon             = new TPolygon();
            aObject.Polygon      = tPolygon;

            tColor         = new TColor();
            tColor.A       = 255;
            tColor.R       = 255;
            tColor.G       = 255;
            tColor.B       = 0;
            tPolygon.Color = tColor;

            PointList pointList = new PointList();
            TPoint    tPoint;

            tPoint   = new TPoint();
            tPoint.X = 0.3D;
            tPoint.Y = 0.3D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.6D;
            tPoint.Y = 0.3D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.6D;
            tPoint.Y = 0.6D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.3D;
            tPoint.Y = 0.6D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.3D;
            tPoint.Y = 0.3D;
            pointList.Add(tPoint);

            tPolygon.PointList = pointList;

            return(aObject);
        }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        m_AO = AnalyticsObject.LoadData(DataType.JSON, 0);
        if (m_AO == null)
        {
            m_AO           = new AnalyticsObject(m_iGridSizeX, m_iGridSizeZ);
            m_AO.levelName = SceneManager.GetActiveScene().name;
        }


        m_Player = FindObjectOfType <PlayerContoller>().transform;
        //m_AO = AnalyticsObject.LoadData(DataType.JSON, m_AO.gameId);
        print(Application.persistentDataPath);
    }
Exemplo n.º 5
0
    static AnalyticsObject LoadJson(string path)
    {
        AnalyticsObject ao = null;

        if (File.Exists(path))
        {
            StreamReader file     = new StreamReader(path);
            string       dataFile = file.ReadToEnd();
            file.Close();
            JSONNode jsonObject = JSONNode.Parse(dataFile);
            int      X          = int.Parse(jsonObject["SizeX"].Value);
            int      Z          = int.Parse(jsonObject["SizeZ"].Value);
            ao = new AnalyticsObject(X, Z);


            ao.levelName = jsonObject["levelName"].Value;

            ao.gameId    = int.Parse(jsonObject["gameId"].Value);
            ao.minValues = new Data();
            ao.minValues.FromJson(jsonObject["minValues"]);
            ao.maxValues = new Data();
            ao.maxValues.FromJson(jsonObject["maxValues"]);
            ao.dataMap = new Data[X][];
            for (int i = 0; i < X; i++)
            {
                ao.dataMap[i] = new Data[Z];
                for (int j = 0; j < Z; j++)
                {
                    ao.dataMap[i][j] = new Data();
                    ao.dataMap[i][j].FromJson(jsonObject["dataMap"][i][j]);
                }
            }
        }

        return(ao);
    }