Esempio n. 1
0
    public void setEvolutions(List <object> evol, UniverseTime t)
    {
        time       = t;
        evolutions = evol;
        //print ("evol: " + evolutions);
        displacements = new Dictionary <string, Texture2D> ();
        for (int i = 0; i < evolutions.Count; ++i)
        {
            Dictionary <string, object> current = (Dictionary <string, object>)(evolutions [i]);
            if (current.ContainsKey("displacement"))
            {
                //print("cur disp: " + "System/1/" + current["displacement"]);
                //print ((Texture2D)Resources.Load ( "System/1/" +  current["displacement"]));
                GameObject   manager = GameObject.Find("Manager");
                SystemLoader sys     = manager.GetComponent <SystemLoader>();

                var path = "file://" + Application.dataPath + "/Resources/" + sys.resourceFolder + current["displacement"] + ".png";
                print("path for displacement : " + path);
                var www = new WWW(path);
                while (!www.isDone)
                {
                    ;
                }
                displacements.Add((string)current["displacement"], www.texture);
            }
        }
        //Texture2D t2 = (Texture2D)Resources.Load ("Assets/Resources/System/1/Maps/soleilDisplacement2.png");
        //displacement.Add ( t2);
    }
Esempio n. 2
0
        public static TSystemType AddSystem <TSystemType>(this SystemLoader t) where TSystemType : Component, ISystemService
        {
            var parent = uFrameKernel.Instance.transform;
            var go     = new GameObject(typeof(TSystemType).Name);

            go.transform.parent = parent;
            return(go.AddComponent <TSystemType>());
        }
Esempio n. 3
0
 public static SystemLoader getInstance()
 {
     if (!_instance)
     {
         GameObject manager = GameObject.Find("Manager");
         _instance = manager.AddComponent <SystemLoader>();
     }
     return(_instance);
 }
Esempio n. 4
0
    void initPlanetList()
    {
        if (astre.items.Count != 0)
        {
            return;
        }
        GameObject   manager = GameObject.Find("Manager");
        SystemLoader sys     = manager.GetComponent <SystemLoader>();

        foreach (GameObject p in sys.planets)
        {
            astre.items.Add(p.name);
        }
    }
Esempio n. 5
0
        public static TSystemType AddSystem <TSystemType>(this SystemLoader t) where TSystemType : Component, ISystemService
        {
            var parent   = uFrameKernel.Instance.transform;
            var existing = parent.GetComponentInChildren <TSystemType>();

            if (existing != null)
            {
                return(existing);
            }
            var go = new GameObject(typeof(TSystemType).Name);

            go.transform.parent = parent;
            return(go.AddComponent <TSystemType>());
        }
Esempio n. 6
0
	void OpenFile (string pathToFile) {
		var fileIndex = pathToFile.LastIndexOf (pathChar);
		message = "You selected file: " + pathToFile.Substring (fileIndex+1, pathToFile.Length-fileIndex-1);
		controler.SetActive(true);
		controler.animation.Play();
	
		GameObject g = GameObject.Find ("Manager");
        sysLoader = SystemLoader.getInstance();
		sysLoader.rootFolder = pathToFile.Substring (0, fileIndex + 1);
		var index = sysLoader.rootFolder.LastIndexOf ("Resources") + 10;
		string folder = sysLoader.rootFolder.Substring(index, sysLoader.rootFolder.Length - index);
		folder = folder.Replace ('\\', '/');
		sysLoader.resourceFolder = folder;
		sysLoader.initialize ();
	}
Esempio n. 7
0
    void OnSelectionAstre(string val)
    {
        print("ONSELECTIONASTRE");
        GameObject   manager = GameObject.Find("Manager");
        SystemLoader sys     = manager.GetComponent <SystemLoader>();

        foreach (GameObject p in sys.planets)
        {
            print(p);
            if (val == p.name)
            {
                //setCamFree();
                setCamLookAt(p);
            }
        }
    }
Esempio n. 8
0
    void OnClick()
    {
        GameObject   manager = GameObject.Find("Manager");
        SystemLoader sys     = manager.GetComponent <SystemLoader>();

        foreach (GameObject p in sys.planets)
        {
            if (astre.selection == p.name)
            {
                planet = p.name;
                time   = w.elapsed;
                res.Add(time);
                PlanetUpdater updater = p.GetComponent <PlanetUpdater>();
                extraction(planet, time, updater.evolutions);
            }
        }
    }
Esempio n. 9
0
    // Update is called once per frame
    void Update()
    {
        timer();
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (menuInGame.GetComponent <UIPanel>().alpha == 0)
            {
                menuInGame.GetComponent <UIPanel>().alpha = 1;
                menuInGame.SetActive(true);
            }
            else
            {
                menuInGame.GetComponent <UIPanel>().alpha = 0;
            }
        }
        if (Input.GetButton("Fire1"))
        {
            extractOK.SetActive(false);

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            //// TODO: singletooon !
            GameObject   manager = GameObject.Find("Manager");
            SystemLoader sys     = manager.GetComponent <SystemLoader>();
            if (!sys || !sys.hasLoaded)
            {
                print("planet not leaded yet");
                return;
            }

            UniverseTime w = manager.GetComponent <UniverseTime>();

            if (controler.activeInHierarchy)
            {
                initPlanetList();
                foreach (GameObject p in sys.planets)
                {
                    Collider planetCollider = p.collider;
                    if (planetCollider != null && planetCollider.Raycast(ray, out hit, 1000.0f))
                    {
                        {
                            //Debug.DrawLine (ray.origin, hit.point);
                            //print ("hit! ");
                            Vector2 textureCoord = hit.textureCoord;
                            pu = p.GetComponent <PlanetUpdater>();
                            foreach (var t in pu.materials)
                            {
                                if (selectedMat == null || pu.materials[selectedMat] == null)
                                {
                                    selectedMat = t.Key;
                                }
                            }
                            textureCoord.x *= pu.materials[selectedMat].width;
                            textureCoord.y *= pu.materials[selectedMat].height;
                            //print(hit.textureCoord);
                            x = (int)textureCoord.x;
                            y = (int)textureCoord.y;
                            //print("pixel rock : " + pu.materials["rock"].GetPixel(x, y));
                            //print("pixel water : " + pu.materials["water"].GetPixel(x, y));
                            if (controler.activeInHierarchy)
                            {
                                ShowInformations(x, y, pu);

                                // parent the camera to the object looked at
                                //setCamFree();
                                setCamLookAt(p);

                                // update the local indicator
                                priv_indicator.SetActive(true);

                                priv_indicator.transform.parent        = pu.gameObject.transform;
                                priv_indicator.transform.localPosition = Vector3.zero;
                                priv_indicator.transform.localRotation = Quaternion.Euler(Vector3.zero);
                                priv_indicator.transform.localScale    = new Vector3(1, 1, 1);
                                // average of each scales (x and y and z)


                                priv_indicator.GetComponentInChildren <ParticleSystem>().startSpeed = initial_particle_speed * priv_indicator.transform.parent.localScale.x;
                                //print(hit.normal);
                                Quaternion quatHit = Quaternion.FromToRotation(Vector3.up, hit.point - pu.transform.position);

                                //print("quatHit: " + quatHit);

                                priv_indicator.transform.rotation = quatHit;
                                //print("rotation: " + priv_indicator.transform.rotation);

                                return;
                            }
                        }
                    }
                }
            }
        }
    }