示例#1
0
    // Use this for initialization
    void Setup()
    {
        if (!init)
        {
            PlayerPrefs.SetString(PP_KILL_STRING, "");

            foreach (int i in killStrings)
            {
                killStringsList.Add(i);
            }

            print("killStringsList:" + killStringsList.Count);

            string text = PlayerPrefs.GetString(PP_KILL_STRING, "");

            string[] splitKill = text.Split(',');

            print("text: " + text);

            for (int i = 0; i < splitKill.Length; i++)
            {
                int num = 0;

                System.Int32.TryParse(splitKill[i], out num);                 //KILL STRING MIGHT ALWAYS INCLUDE 0, BECAUSE OF TryParse

                if (!killStringsList.Contains(num))
                {
                    killStringsList.Add(num);
                }
                else
                {
                    print("Killer");
                }
            }

            for (int i = 0; i < killStringsList.Count; i++)
            {
                int num = killStringsList[i];

                while (killStringsList.Contains(num))
                {
                    killStringsList.Remove(num);
                }

                killStringsList.Add(num);
            }

            print("killStringsList count: " + killStringsList.Count);

            init = true;

            Cursor.visible = !Application.isEditor;

            SetMaterial();
            pool = new List <Vector3>();

            for (int i = 0; i < 10000; i++)
            {
                pool.Add(new Vector3());
            }

            result = new List <float>();

            TextAsset asset = Resources.Load <TextAsset>(jsonLineFile);

            JObject j1 = JObject.Parse(asset.text);

            cfs = Camera.main.GetComponent <CameraFrustrumScript>();

            Vector3 projPos = new Vector3(
                (float)j1[LumarcaGenerator.PROP_PROJ_POS]["x"],
                (float)j1[LumarcaGenerator.PROP_PROJ_POS]["y"],
                (float)j1[LumarcaGenerator.PROP_PROJ_POS]["z"]);

            cfs.SetupCamera(
                (float)j1[LumarcaGenerator.PROP_PHYSICAL_WIDTH],
                projPos,
                (float)j1[LumarcaGenerator.PROP_THROW_RATIO],
                (bool)j1[LumarcaGenerator.PROP_CEILING_MOUNT]);

            front = cfs.GetFrontPlane();

            back    = new Vector3[4];
            back[0] = LumarcaGenerator.GetFarClippingPlane(front[0]);
            back[1] = LumarcaGenerator.GetFarClippingPlane(front[1]);
            back[2] = LumarcaGenerator.GetFarClippingPlane(front[2]);
            back[3] = LumarcaGenerator.GetFarClippingPlane(front[3]);

            frontHeight = front[2].y - front[0].y;
            backHeight  = back[2].y - back[0].y;

            JArray ja = j1["positions"] as JArray;

            for (int i = 0; i < ja.Count; i++)
            {
                Vector3 vec = UtilScript.JsonToVector3(ja[i]);

                if (flipX)
                {
                    vec.x = -vec.x;
                }

                float lerpPer = (vec.z - front[0].z) / (back[0].z - front[0].z);

                float lineHeight = Mathf.Lerp(frontHeight, backHeight, lerpPer);

                if (cfs.ceilingMounted)
                {
                    vec.y = (front[2].y + (front[2].y - lineHeight)) / 2f;
                }
                else
                {
                    vec.y = (front[0].y + (front[0].y + lineHeight)) / 2f;
                }

                posList.Add(vec);
            }

            pos = posList.ToArray();

            Debug.Log("Num Lines: " + pos.Length);

            foreach (LumarcaAnimation la in lumarcaAnimations)
            {
                la.LoadFromJSON();
            }

            GetComponent <LumarcaAnimation>();

            if (recordName)
            {
                recordAnimation = GetComponent <LumarcaAnimation>();
                if (recordAnimation == null)
                {
                    recordAnimation = gameObject.AddComponent <LumarcaAnimation>();
                }
            }

            VectorManager.useDraw3D = true;

            //		0.6424695

            //		VectorLine.SetRay3D (Color.green, transform.position, transform.forward * 5.0f);

            //		VectorLine line = VectorLine.SetLine(Color.green,  new Vector3[]{Vector3.left, Vector3.down});
            //		line.SetColor(Color.yellow);
            //		line.Draw3D();

            //		VectorLine.SetLine(Color.red, new Vector3[]{Vector3.left, Vector3.down});
            //
            //		vectorLinePool = new ObjectPool<VectorLine>(new ObjectGenerator<VectorLine>());
            //
            //		VectorLine myLine = vectorLinePool.GetObject();
            //
            //		myLine.SetColor(Color.blue);
            //		myLine.points3[0] = new Vector3(0,0,0);
            //		myLine.points3[1] = new Vector3(0,1,0);
            //
            //		List<int> myWidths = new List<int>(){1}; // C#
            //		myLine.SetWidths (myWidths);
        }
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        Cursor.visible = false;

        SetMaterial();
        pool = new List <Vector3>();

        for (int i = 0; i < 10000; i++)
        {
            pool.Add(new Vector3());
        }

        result = new List <float>();

        TextAsset asset = Resources.Load(jsonLineFile) as TextAsset;

        JObject j1 = JObject.Parse(asset.text);
        JArray  ja = j1["positions"] as JArray;

        for (int i = 0; i < ja.Count; i++)
        {
            Vector3 vec = UtilScript.JsonToVector3(ja[i]);

            posList.Add(vec);
        }

        pos = posList.ToArray();

        Debug.Log("Num Lines: " + pos.Length);

        cfs = Camera.main.GetComponent <CameraFrustrumScript>();

//		jObject["lumarcaSize"] = cfs.physicalWidth;
//		jObject["ProjPos"] = UtilScript.Vector3ToJson(cfs.transform.position);
//		jObject["ThrowRatio"] = cfs.throwRatio;
//		jObject["PhysicalWidth"] = cfs.physicalWidth;
//		jObject["CeilingMount"] = cfs.ceilingMounted;
//		JArray jPositions = new JArray();
//		jObject["positions"] = jPositions;

        Vector3 projPos = new Vector3(
            (float)j1[LumarcaGenerator.PROP_PROJ_POS]["x"],
            (float)j1[LumarcaGenerator.PROP_PROJ_POS]["y"],
            (float)j1[LumarcaGenerator.PROP_PROJ_POS]["z"]);

        cfs.SetupCamera(
            (float)j1[LumarcaGenerator.PROP_PHYSICAL_WIDTH],
            projPos,
            (float)j1[LumarcaGenerator.PROP_THROW_RATIO],
            (bool)j1[LumarcaGenerator.PROP_CEILING_MOUNT]);
        front = cfs.GetFrontPlane();
        back  = new Vector3[4];

        for (int i = 0; i < front.Length; i++)
        {
            back[i]   = UtilScript.CloneVec3(front[i]);
            back[i].z = front[0].z + Camera.main.farClipPlane - Camera.main.nearClipPlane;
        }

        foreach (LumarcaAnimation la in lumarcaAnimations)
        {
            la.LoadFromJSON();
        }

        GetComponent <LumarcaAnimation>();

        if (recordName)
        {
            recordAnimation = gameObject.AddComponent <LumarcaAnimation>();
        }
    }