Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        //tag
        if (col.gameObject.tag == "Lazer")
        {
            anim.SetTrigger("died");

            GetComponent <Rigidbody2D>().isKinematic = true;
            GetComponent <Collider2D>().enabled      = false;

            endmenu.SetActive(true);
            ingamedisplay.SetActive(false);
            buttonup.SetActive(false);
            buttondown.SetActive(false);

            GetComponent <AudioSource>().PlayOneShot(died, 3.0F);

            int totalcans = 5;

            UnityAnalytics.CustomEvent("gameOver", new Dictionary <string, object>
            {
                { "totalcan", totalcans },
            });

            Everyplay.StopRecording();
            //Everyplay.SetMetadata("score", score);
            //Everyplay.PlayLastRecording();
        }
    }
 void OnApplicationPause(bool isPaused)
 {
     Debug.Log(isPaused ? "App Pause" : "App Resume");
     UnityAnalytics.CustomEvent("Events", new Dictionary <string, object> {
         { "Action", isPaused ? "App Pause" : "App Resume" }
     });
 }
 public static void PickTeamEvent(string team)
 {
     UnityAnalytics.CustomEvent("PickTeam", new Dictionary <string, object>
     {
         { "team", team },
     });
 }
 void OnApplicationQuit()
 {
     Debug.Log("App Close");
     UnityAnalytics.CustomEvent("Events", new Dictionary <string, object> {
         { "Action", "AppClose" }
     });
 }
 public static void ReadAboutEvent(float time)
 {
     UnityAnalytics.CustomEvent("ReadAbout", new Dictionary <string, object>
     {
         { "time", time },
     });
 }
Exemplo n.º 6
0
 public void RegistrarInicio()
 {
     UnityAnalytics.CustomEvent("gameStart", new Dictionary <string, object>
     {
         //{ "potions", totalPotions },
         //{ "coins", totalCoins },
     });
 }
 public static void EndedScene()
 {
     EndScene();
     UnityAnalytics.CustomEvent("Scene End", new Dictionary <string, object> {
         { "points", points },
         //{ "distance", distance }
     });
     scene = false;
 }
 // Use this for initialization
 void Start()
 {
     UnityAnalytics.StartSDK(appId);
     UnityAnalytics.CustomEvent("Events", new Dictionary <string, object> {
         { "Action", "App Start" }
     });
     UnityAnalytics.SetUserBirthYear(1984);
     UnityAnalytics.SetUserGender(SexEnum.M);
     UnityAnalytics.SetUserId("PAHeartBeat");
 }
Exemplo n.º 9
0
        public void SendEvent(string name, IDictionary <string, object> data, AnalyticsServices services)
        {
            if (services == AnalyticsServices.ParseDotCom || services == AnalyticsServices.Both)
            {
                var specificData = data.ToDictionary(o => o.Key, o => o.Value.ToString());

                ParseAnalytics.TrackEventAsync(name, specificData);
            }
            if (services == AnalyticsServices.UnityAnalytics || services == AnalyticsServices.Both)
            {
                UnityAnalytics.CustomEvent(name, data);
            }
        }
Exemplo n.º 10
0
    public void RegistrarFin()
    {
        float secsJuego = Time.time;

        //int vidaGirl = GameObject.Find ("Girl").GetComponent<ControlPersonaje> ().energy;
        //int vidaGoblin = GameObject.Find ("goblin archer").GetComponent<ControlEnemigo> ().energy;
        aSource.Stop();
        UnityAnalytics.CustomEvent("gameOver", new Dictionary <string, object>
        {
            { "time", secsJuego },
            { "numReliquias", numReliquias },
            { "numEnemigosDerrotados", numEnemigosDerrotados },
            { "version", version }
        });
    }
Exemplo n.º 11
0
    private void trackUACustomEvent(string eventType, params object[] paramValues)
    {
        // Track a custom event using Unity Analytics
        //https://analytics.cloud.unity3d.com/docs
        // Max 10 params per custom event

        var parametersDict = new Dictionary <string, object>();

        for (var i = 0; i < paramValues.Length; i += 2)
        {
            parametersDict.Add(paramValues[i] as string, paramValues[i + 1]);
        }

        UnityAnalytics.CustomEvent(eventType, parametersDict);
    }
Exemplo n.º 12
0
    private IEnumerator CheckVersion()
    {
        WWW w = new WWW("http://retalyx.fr/rsgg/latestversion.txt");

        yield return(w);

        if (w.error != null)
        {
            Debug.Log("Error .. " + w.error);
        }
        else
        {
            Debug.Log("Found ... ==>" + w.text + "<==");
            string   val = w.text;
            string[] v   = val.Split('|');
            lv         = v[0];
            lvdownload = v[1];

            if (lv != null && lvdownload != null)
            {
                if (float.Parse(lv) > float.Parse(version))
                {
                    UnityAnalytics.CustomEvent("update", new Dictionary <string, object>
                    {
                        { "needUpdate", true },
                        { "currentVersion", version }
                    });
                }
                else
                {
                    UnityAnalytics.CustomEvent("update", new Dictionary <string, object>
                    {
                        { "needUpdate", false },
                        { "currentVersion", version }
                    });
                }
            }
        }
    }
    public static void GameOverEvent(Dictionary <string, int> units, float time)
    {
        string pMedic   = "PlayerMedic";
        string pRPG     = "PlayerRPG";
        string pSoldier = "PlayerSoldier";
        string pTank    = "PlayerTank";

        string aMedic   = "AIMedic";
        string aRPG     = "AIRPG";
        string aSoldier = "AISoldier";
        string aTank    = "AITank";

        if (units.Count == 0)
        {
            CrossSceneMenuInfo.use.resetDict();
            units = CrossSceneMenuInfo.use.unitsSpawned;
        }


        UnityAnalytics.CustomEvent("GameOver", new Dictionary <string, object>
        {
            { pSoldier, units[pSoldier] },
            { pMedic, units[pMedic] },
            { pRPG, units[pRPG] },
            { pTank, units[pTank] },

            { aSoldier, units[aSoldier] },
            { aMedic, units[aMedic] },
            { aRPG, units[aRPG] },
            { aTank, units[aTank] },

            { "time", time }
        });

        Debug.Log("SentGameOverEvent");
    }
 public static void ClickedSocialTwitterEvent()
 {
     UnityAnalytics.CustomEvent("ClickTwitter", null);
 }
Exemplo n.º 15
0
    private void refreshGUIGalaxy()
    {
        //Left Panel
        GUILayout.BeginArea(new Rect(10, 10, 200, 1000));

        GUILayout.Label("Galaxy Generator by Retalyx V" + version);
        if (GUILayout.Button("Donate"))
        {
            donate();
        }

        GUILayout.Label("Galaxy Name:");
        galaxyname = GUILayout.TextField(galaxyname, 32);

        GUILayout.BeginHorizontal("box");
        GUILayout.Label("Seed:");
        generationseed = int.Parse(GUILayout.TextField(generationseed + "", 7));
        GUILayout.EndHorizontal();
        generationseed    = (int)Mathf.Round(GUILayout.HorizontalSlider(generationseed, 0.0F, 1000000.0F));
        autogenHyperlines = GUILayout.Toggle(autogenHyperlines, "Auto Generate Hyperlanes");
        GUILayout.Label("Minimal System Distance: " + minDist);
        minDist      = (int)Mathf.Round(GUILayout.HorizontalSlider(minDist, 0.0F, 50.0F));
        loadfromfile = GUILayout.Toggle(loadfromfile, "Import from file");
        if (!loadfromfile)
        {
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Galaxy Size:");
            galaxysize = float.Parse(GUILayout.TextField(galaxysize + "", 4));
            GUILayout.EndHorizontal();
            galaxysize = (int)Mathf.Round(GUILayout.HorizontalSlider(galaxysize, 0.0F, 1000.0F));
            if (galaxysize > 1000)
            {
                GUI.color = Color.red;
                GUILayout.Label("MAX INGAME SUPPORTED SIZE IS 1000");
                GUI.color = Color.white;
            }
            GUILayout.Label("Real System Count: " + galaxysystemcount);
            GUILayout.Label("Nebula Count: " + galaxynebulacount);

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("System Count:");
            starstogen = float.Parse(GUILayout.TextField(starstogen + "", 5));
            GUILayout.EndHorizontal();
            starstogen = (int)Mathf.Round(GUILayout.HorizontalSlider(starstogen, 0.0F, 50000.0F));

            usePerlin = GUILayout.Toggle(usePerlin, "Perlin Noise");

            if (usePerlin)
            {
                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Noise Scale:");
                nscale = float.Parse(GUILayout.TextField(nscale + "", 7));
                GUILayout.EndHorizontal();
                nscale = GUILayout.HorizontalSlider(nscale, 0.0F, 1000.0F);

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Noise Persistence:");
                npers = float.Parse(GUILayout.TextField(npers + "", 4));
                GUILayout.EndHorizontal();
                npers = GUILayout.HorizontalSlider(npers, 0.0F, 2.0F);

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Noise Frequency:");
                nfreq = float.Parse(GUILayout.TextField(nfreq + "", 4));
                GUILayout.EndHorizontal();
                nfreq = GUILayout.HorizontalSlider(nfreq, 0.0F, 5.0F);
            }

            if (GUILayout.Button("Generate"))
            {
                generate();
            }
        }
        else
        {
            GUILayout.Label("Galaxy Size: " + Mathf.Max(pnggalaxyX, pnggalaxyY));
            GUILayout.Label("System Count: " + galaxysystemcount);
            GUILayout.Label("Nebula Count: " + galaxynebulacount);
            if (Mathf.Max(pnggalaxyX, pnggalaxyY) > 1000)
            {
                GUI.color = Color.red;
                GUILayout.Label("MAX INGAME SUPPORTED SIZE IS 1000");
                GUI.color = Color.white;
            }

            usePerlin = GUILayout.Toggle(usePerlin, "Perlin Noise");

            if (usePerlin)
            {
                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Noise Scale:");
                nscale = float.Parse(GUILayout.TextField(nscale + "", 7));
                GUILayout.EndHorizontal();
                nscale = GUILayout.HorizontalSlider(nscale, 0.0F, 1000.0F);

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Noise Persistence:");
                npers = float.Parse(GUILayout.TextField(npers + "", 4));
                GUILayout.EndHorizontal();
                npers = GUILayout.HorizontalSlider(npers, 0.0F, 2.0F);

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Noise Frequency:");
                nfreq = float.Parse(GUILayout.TextField(nfreq + "", 4));
                GUILayout.EndHorizontal();
                nfreq = GUILayout.HorizontalSlider(nfreq, 0.0F, 5.0F);
            }

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Scale:");
            pngmultiplier = float.Parse(GUILayout.TextField(pngmultiplier + "", 5));
            GUILayout.EndHorizontal();
            pngmultiplier = (int)Mathf.Round(GUILayout.HorizontalSlider(pngmultiplier, 0.0F, 25.0F));

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Randomizer:");
            pngrandomizer = float.Parse(GUILayout.TextField(pngrandomizer + "", 5));
            GUILayout.EndHorizontal();
            pngrandomizer = (int)Mathf.Round(GUILayout.HorizontalSlider(pngrandomizer, 0.0F, 25.0F));

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Reducer:");
            pngreducer = float.Parse(GUILayout.TextField(pngreducer + "", 4));
            GUILayout.EndHorizontal();
            pngreducer = GUILayout.HorizontalSlider(pngreducer, 0.0F, 1.0F);

            if (GUILayout.Button("Generate From PNG"))
            {
                generatefrompng();
            }
        }
        if (spawns >= 2)
        {
            GUI.color = Color.green;
            if (GUILayout.Button("Save Mod"))
            {
                save();
            }
            GUI.color = Color.white;
        }
        else
        {
            GUI.color = Color.red;
            if (GUILayout.Button("Save Mod"))
            {
                Log("You need at least 2 spawns\nto save your galaxy");
            }
            GUI.color = Color.white;
        }
        if (lv != null && lvdownload != null)
        {
            if (float.Parse(lv) > float.Parse(version))
            {
                GUILayout.Label("New Version available!");
                if (GUILayout.Button("Download V" + lv))
                {
                    Application.OpenURL(lvdownload);

                    UnityAnalytics.CustomEvent("downloadUpdate", new Dictionary <string, object>
                    {
                        { "clickedUpdateButton", true },
                        { "latestVersion", lv }
                    });
                }
            }
        }
        // GUILayout.Label("Warning: Experimental!");
        if (GUILayout.Button("Save/Load Project"))
        {
            editorMode = -1;
            projectManager.refreshProjectList();
        }

        if (message != null && message != "")
        {
            if (GUILayout.Button("Clear Logs"))
            {
                ClearLog();
            }
        }
        GUILayout.BeginScrollView(Vector2.zero, GUILayout.Width(200), GUILayout.Height(500));
        GUILayout.Box(message);
        GUILayout.EndScrollView();
        GUILayout.EndArea();

        //Right Panel
        string modeText = "No Mode";

        GUILayout.BeginArea(new Rect(Screen.width - 210, 10, 200, 1000));
        switch (currentMode)
        {
        case 1:
            modeText = "Spawn";
            break;

        case 2:
            modeText = "Move";
            break;

        case 3:
            modeText = "Create System";
            break;

        case 4:
            modeText = "Delete System";
            break;

        case 5:
            modeText = "Create Nebula";
            break;

        case 6:
            modeText = "Delete Nebula";
            break;

        case 7:
            modeText = "Hyperlane Tool";
            break;

        default:
            modeText = "No Mode";
            break;
        }
        GUILayout.Label("Current Mode: " + modeText);

        if (GUILayout.Button("Spawn"))
        {
            if (currentMode == 1)
            {
                currentMode = 0;
            }
            else
            {
                currentMode = 1;
            }
        }
        if (currentMode == 1)
        {
            if (GUILayout.Button("Generate " + genspawn + " Spawn"))
            {
                GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("star_system");
                int          maxSpawn    = 0;
                for (var i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i])
                    {
                        if (!gameObjects[i].GetComponent <system>().isSpawn)
                        {
                            maxSpawn++;
                        }
                    }
                }
                if (genspawn > maxSpawn)
                {
                    genspawn = maxSpawn;
                }
                for (var i = 0; i < genspawn; i++)
                {
                    int rn = UnityEngine.Random.Range(0, gameObjects.Length);
                    if (gameObjects[rn].GetComponent <system>().isSpawn)
                    {
                        i--;
                    }
                    else
                    {
                        gameObjects[rn].GetComponent <system>().setSpawn(true);
                        // spawns++;
                    }
                }
                Log("Generated " + genspawn + " new spawns");
            }
            genspawn = int.Parse(GUILayout.TextField(genspawn + "", 3));
        }
        if (GUILayout.Button("Move"))
        {
            if (currentMode == 2)
            {
                currentMode = 0;
            }
            else
            {
                currentMode = 2;
            }
        }

        GUILayout.BeginHorizontal("box");
        if (GUILayout.Button("Create System"))
        {
            if (currentMode == 3)
            {
                currentMode = 0;
            }
            else
            {
                currentMode = 3;
            }
        }
        if (GUILayout.Button("Delete System"))
        {
            if (currentMode == 4)
            {
                currentMode = 0;
            }
            else
            {
                currentMode = 4;
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal("box");
        if (GUILayout.Button("Create Nebula"))
        {
            if (currentMode == 5)
            {
                currentMode = 0;
            }
            else
            {
                currentMode = 5;
            }
        }
        if (GUILayout.Button("Delete Nebula"))
        {
            if (currentMode == 6)
            {
                currentMode = 0;
            }
            else
            {
                currentMode = 6;
            }
        }
        GUILayout.EndHorizontal();
        if (GUILayout.Button("Hyperlane"))
        {
            if (currentMode == 7)
            {
                currentMode           = 0;
                prevSelectedHyperlane = null;
            }
            else
            {
                currentMode = 7;
            }
        }
        if (currentMode == 7)
        {
            // hlpreventmode = GUILayout.Toggle(hlpreventmode, "Prevent mode");
            if (GUILayout.Button("Radius Generate Hyperlane"))
            {
                StartCoroutine(generateHyperlanes());
            }
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Generation Radius:");
            genhlradius = int.Parse(GUILayout.TextField(genhlradius + "", 6));
            GUILayout.EndHorizontal();
            genhlradius = (int)Mathf.Round(GUILayout.HorizontalSlider(genhlradius, 0.0F, 100.0F));

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Max per System:");
            genhlmaxlines = int.Parse(GUILayout.TextField(genhlmaxlines + "", 2));
            GUILayout.EndHorizontal();
            genhlmaxlines = (int)Mathf.Round(GUILayout.HorizontalSlider(genhlmaxlines, 0.0F, 10.0F));

            if (GUILayout.Button("Clear Hyperlanes"))
            {
                GameObject[] la = GameObject.FindGameObjectsWithTag("hyperlane");
                for (var w = 0; w < la.Length; w++)
                {
                    if (la[w])
                    {
                        la[w].GetComponent <hyperlane>().kill();
                    }
                }
            }
        }
        if (selectedSystem)
        {
            GUILayout.Label("Selected System Infos");
            if (selectedSystem.systemName != "RandomName" && selectedSystem.systemName != "random" && selectedSystem.systemName != "" && selectedSystem.systemName != null)
            {
                GUILayout.Label("Name: " + selectedSystem.systemName);
            }
            GUILayout.Label("Position");
            GUILayout.Label("X: " + selectedSystem.transform.position.x);
            GUILayout.Label("Y: " + selectedSystem.transform.position.z);
            GUILayout.Label("ID: " + selectedSystem.systemid);
            GUILayout.Label("Hyperlanes: " + selectedSystem.connectedLines);
            if (!selectedSystem.prevent)
            {
                if (GUILayout.Button("Prevent Hyperlanes to any"))
                {
                    selectedSystem.prevent = true;
                    GameObject[] gameObjectsHL = GameObject.FindGameObjectsWithTag("hyperlane");
                    for (var i = 0; i < gameObjectsHL.Length; i++)
                    {
                        if (gameObjectsHL[i])
                        {
                            if (gameObjectsHL[i].GetComponent <hyperlane>().link0 == selectedSystem || gameObjectsHL[i].GetComponent <hyperlane>().link1 == selectedSystem)
                            {
                                gameObjectsHL[i].GetComponent <hyperlane>().kill();
                            }
                        }
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Allow Hyperlanes to any"))
                {
                    selectedSystem.prevent = false;
                }
            }
            if (GUILayout.Button("Delete connected hyperlanes"))
            {
                GameObject[] gameObjectsHL = GameObject.FindGameObjectsWithTag("hyperlane");
                for (var i = 0; i < gameObjectsHL.Length; i++)
                {
                    if (gameObjectsHL[i])
                    {
                        if (gameObjectsHL[i].GetComponent <hyperlane>().link0 == selectedSystem || gameObjectsHL[i].GetComponent <hyperlane>().link1 == selectedSystem)
                        {
                            gameObjectsHL[i].GetComponent <hyperlane>().kill();
                        }
                    }
                }
            }
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Initializer:");
            selectedSystem.initializer = GUILayout.TextField(selectedSystem.initializer);
            GUILayout.EndHorizontal();
            if (GUILayout.Button("Edit in System Editor"))
            {
                editorMode = 1;
                GalaxyEditor.SetActive(false);
                bool fnd = false;
                foreach (GameObject se in systemEditors)
                {
                    if (se.GetComponent <systemeditor>().thisSystem == selectedSystem)
                    {
                        se.SetActive(true);
                        fnd = true;
                        break;
                    }
                }
                if (!fnd)
                {
                    GameObject se = (GameObject)Instantiate(systemeditor_prefab, new Vector3(0, 0, 0), Quaternion.identity);
                    se.GetComponent <systemeditor>().SetForSys(selectedSystem);
                    systemEditors.Add(se);
                }
            }
            if (selectedSystem.isSpawn)
            {
                if (GUILayout.Button("Disable Spawn"))
                {
                    selectedSystem.setSpawn(false);
                    // spawns--;
                }
            }
            else if (!selectedSystem.isSpawn)
            {
                if (GUILayout.Button("Enable Spawn"))
                {
                    selectedSystem.setSpawn(true);
                    // spawns++;
                }
            }
        }
        if (selectedNebula)
        {
            GUILayout.Label("Selected Nebula Infos");
            GUILayout.Label("Position");
            GUILayout.Label("X: " + selectedNebula.transform.position.x);
            GUILayout.Label("Y: " + selectedNebula.transform.position.z);
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Name:");
            selectedNebula.nebulaName = GUILayout.TextField(selectedNebula.nebulaName);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Radius:");
            selectedNebula.nebulaRadius = int.Parse(GUILayout.TextField(selectedNebula.nebulaRadius + "", 3));
            GUILayout.EndHorizontal();
        }
        GUILayout.EndArea();
    }
Exemplo n.º 16
0
    IEnumerator generateHyperlanes()
    {
        isGenerating = true;
        float        progressPercent = 0f;
        float        timeLeft        = 0f;
        List <float> times           = new List <float>();
        var          temp            = Time.realtimeSinceStartup;

        GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("star_system");
        int          cnt         = 0;
        int          lcnt        = 0;

        foreach (GameObject sy in gameObjects)
        {
            var tempL = Time.realtimeSinceStartup;
            if (sy)
            {
                float[] distances = new float[gameObjects.Length];
                int[]   indexes   = new int[gameObjects.Length];
                int     arrayind  = 0;
                int     j         = 0;
                foreach (GameObject go in gameObjects)
                {
                    float dist = Vector3.Distance(sy.transform.position, go.transform.position);
                    if (dist <= genhlradius && dist > 0)
                    {
                        distances[arrayind] = dist;
                        indexes[arrayind]   = j;
                        arrayind++;
                    }
                    j++;
                }
                foreach (float distance in distances)
                {
                    if (distance <= 0)
                    {
                        distances[Array.IndexOf(distances, distance)] = genhlradius + 1;
                    }
                }
                Array.Sort(distances, indexes);
                Array.Resize(ref distances, genhlmaxlines + 1);
                Array.Resize(ref indexes, genhlmaxlines + 1);
                for (int i = 0; i < distances.Length; i++)
                {
                    float  mindDist = Mathf.Min(distances);
                    int    ind      = indexes[Array.IndexOf(distances, mindDist)];
                    system sys0     = sy.GetComponent <system>();
                    system sys1     = gameObjects[ind].GetComponent <system>();
                    distances[Array.IndexOf(distances, mindDist)] = genhlradius + 1;
                    bool         ignorelane = false;
                    GameObject[] hlt        = GameObject.FindGameObjectsWithTag("hyperlane");
                    foreach (GameObject ht in hlt)
                    {
                        if (ht.name == "hl_" + sys0.systemid + "_to_" + sys1.systemid || ht.name == "hl_" + sys1.systemid + "_to_" + sys0.systemid)
                        {
                            ignorelane = true;
                            // Debug.Log("Ignoring:" + ht.name);
                            break;
                        }
                    }

                    if (!ignorelane)
                    {
                        float checkdist = Vector3.Distance(sy.transform.position, gameObjects[ind].transform.position);
                        if (checkdist <= genhlradius && sy != gameObjects[ind] && sys0.connectedLines < genhlmaxlines && sys1.connectedLines < genhlmaxlines && checkdist > 0 && !sys0.prevent && !sys1.prevent)
                        {
                            GameObject line = (GameObject)Instantiate(hyperlane_prefab, new Vector3(0, 0, 0), Quaternion.identity);
                            line.transform.SetParent(GalaxyEditor.transform, true);
                            hyperlane hl = line.GetComponent <hyperlane>();
                            hl.link0 = sys0;
                            hl.link1 = sys1;
                            hl.transform.position = sys0.transform.position;
                            hl.SetName();
                            sys0.connectedLines++;
                            sys1.connectedLines++;
                            cnt++;
                        }
                    }
                }
            }
            lcnt++;
            //Stats
            if (lcnt % 10 == 0)
            {
                float thislTime = float.Parse((Time.realtimeSinceStartup - tempL).ToString("f3"));
                times.Add(thislTime);
                progressPercent = (float)lcnt / (float)gameObjects.Length * 100;
                timeLeft        = ((float)gameObjects.Length - (float)lcnt) * times.Average();
                TimeSpan t              = TimeSpan.FromSeconds(timeLeft);
                TimeSpan tt             = TimeSpan.FromSeconds(thislTime);
                string   timeLeftString = string.Format("{0:D2}h:{1:D2}m:{2:D2}s",
                                                        t.Hours,
                                                        t.Minutes,
                                                        t.Seconds);
                string thislTimeString = string.Format("{0:D2}m:{1:D2}s:{2:D3}ms",
                                                       tt.Minutes,
                                                       tt.Seconds,
                                                       tt.Milliseconds);
                generationStatusString = "Generating: " + lcnt + "/" + gameObjects.Length + "\nHyperlanes: " + cnt + "\nLast gen duration: " + thislTimeString + "\n\nProgress: " + progressPercent.ToString("f2") + "%" + "\nEstimated Time Left: " + timeLeftString;
                yield return(new WaitForSeconds(0.001f));
            }
        }
        string tText = (Time.realtimeSinceStartup - temp).ToString("f2");

        Log("Generated " + cnt + " hyperlanes in\n" + tText + "s");
        UnityAnalytics.CustomEvent("genHyperlane", new Dictionary <string, object>
        {
            { "radius", genhlradius },
            { "maxLines", genhlmaxlines },
            { "finisgHyperlane", cnt },
            { "finishDuration", tText }
        });
        isGenerating = false;
    }
Exemplo n.º 17
0
    void save()
    {
        GameObject[] gameObjects   = GameObject.FindGameObjectsWithTag("star_system");
        GameObject[] gameObjectsN  = GameObject.FindGameObjectsWithTag("nebula");
        GameObject[] gameObjectsHL = GameObject.FindGameObjectsWithTag("hyperlane");
        int          savespawns    = 0;

        for (var i = 0; i < gameObjects.Length; i++)
        {
            if (gameObjects[i])
            {
                if (gameObjects[i].GetComponent <system>().isSpawn)
                {
                    savespawns++;
                }
            }
        }
        string file = galaxyname.Replace(" ", "_");

        if (!Directory.Exists("GeneratedMods"))
        {
            Directory.CreateDirectory("GeneratedMods");
        }
        if (Directory.Exists("GeneratedMods\\" + file))
        {
            Directory.Delete("GeneratedMods\\" + file, true);
        }
        if (!Directory.Exists("GeneratedMods\\" + file))
        {
            Directory.CreateDirectory("GeneratedMods\\" + file);
            Directory.CreateDirectory("GeneratedMods\\" + file + "\\common");
            Directory.CreateDirectory("GeneratedMods\\" + file + "\\common\\on_actions");
            Directory.CreateDirectory("GeneratedMods\\" + file + "\\common\\solar_system_initializers");
            Directory.CreateDirectory("GeneratedMods\\" + file + "\\events");
            Directory.CreateDirectory("GeneratedMods\\" + file + "\\map");
            Directory.CreateDirectory("GeneratedMods\\" + file + "\\map\\setup_scenarios");

            TextAsset filetoadd = (TextAsset)Resources.Load("common/on_actions/reta_events", typeof(TextAsset));
            File.WriteAllText("GeneratedMods\\" + file + "\\common\\on_actions\\reta_events.txt", filetoadd.text);
            filetoadd = (TextAsset)Resources.Load("common/solar_system_initializers/retalyx_initializers", typeof(TextAsset));
            File.WriteAllText("GeneratedMods\\" + file + "\\common\\solar_system_initializers\\retalyx_initializers.txt", filetoadd.text);
            filetoadd = (TextAsset)Resources.Load("common/solar_system_initializers/retalyx_initializers_lists", typeof(TextAsset));
            File.WriteAllText("GeneratedMods\\" + file + "\\common\\solar_system_initializers\\retalyx_initializers_lists.txt", filetoadd.text);
            filetoadd = (TextAsset)Resources.Load("events/reta_start", typeof(TextAsset));
            File.WriteAllText("GeneratedMods\\" + file + "\\events\\reta_start.txt", filetoadd.text);
        }
        string       fileName = "GeneratedMods\\" + file + "\\map\\setup_scenarios\\retalyx_" + file + ".txt";
        StreamWriter sr       = File.CreateText(fileName);

        sr.WriteLine("#Made with Retalyx Static Galaxy Generator v" + version);
        sr.WriteLine("static_galaxy_scenario = {");
        sr.WriteLine("    name = \"" + galaxyname + "\"");
        sr.WriteLine("    priority = 0");
        sr.WriteLine("    default = no");
        sr.WriteLine("    colonizable_planet_odds = 1.0");
        sr.WriteLine("    num_empires = { min = 1 max = " + (savespawns - 1) + " }");
        sr.WriteLine("    num_empire_default = " + (savespawns - 1));
        sr.WriteLine("    advanced_empire_default = 0");
        sr.WriteLine("    core_radius = 0");
        int customSys = 0;

        if (autogenHyperlines)
        {
            sr.WriteLine("    random_hyperlanes = yes");
        }
        else
        {
            sr.WriteLine("    random_hyperlanes = no");
        }

        for (var i = 0; i < gameObjects.Length; i++)
        {
            if (gameObjects[i])
            {
                sr.WriteLine("");
                sr.WriteLine("    system = {");
                if (gameObjects[i].GetComponent <system>().systemName != null && gameObjects[i].GetComponent <system>().systemName != "" && gameObjects[i].GetComponent <system>().systemName != "RandomName" && gameObjects[i].GetComponent <system>().systemName != "random")
                {
                    sr.WriteLine("        name = \"" + gameObjects[i].GetComponent <system>().systemName + "\"");
                }
                sr.WriteLine("        id = \"" + gameObjects[i].GetComponent <system>().systemid + "\"");
                sr.WriteLine("        position = {");
                sr.WriteLine("            x = " + gameObjects[i].transform.position.x + "");
                sr.WriteLine("            y = " + gameObjects[i].transform.position.z + "");
                sr.WriteLine("        }");
                if (gameObjects[i].GetComponent <system>().isSpawn)
                {
                    if (gameObjects[i].GetComponent <system>().initializer != null && gameObjects[i].GetComponent <system>().initializer != "")
                    {
                        sr.WriteLine("        initializer = " + gameObjects[i].GetComponent <system>().initializer);
                        customSys++;
                    }
                    else
                    {
                        sr.WriteLine("        initializer = retalyx_random_spawn");
                    }
                    sr.WriteLine("        spawn_weight = { base = 1 }");
                }
                else if (gameObjects[i].GetComponent <system>().initializer != null && gameObjects[i].GetComponent <system>().initializer != "")
                {
                    sr.WriteLine("        initializer = " + gameObjects[i].GetComponent <system>().initializer);
                    customSys++;
                }
                sr.WriteLine("    }");
                if (gameObjects[i].GetComponent <system>().prevent)
                {
                    sr.WriteLine("    prevent_hyperlane = { from = \"" + gameObjects[i].GetComponent <system>().systemid + "\" to = \"any\" }");
                }
            }
        }

        for (var i = 0; i < gameObjectsN.Length; i++)
        {
            if (gameObjectsN[i])
            {
                sr.WriteLine("");
                sr.WriteLine("    nebula = {");
                sr.WriteLine("        name = \"" + gameObjectsN[i].GetComponent <nebula>().nebulaName + "\"");
                sr.WriteLine("        position = {");
                sr.WriteLine("            x = " + gameObjectsN[i].transform.position.x + "");
                sr.WriteLine("            y = " + gameObjectsN[i].transform.position.z + "");
                sr.WriteLine("        }");
                sr.WriteLine("        radius = " + gameObjectsN[i].GetComponent <nebula>().nebulaRadius + "");
                sr.WriteLine("    }");
            }
        }
        sr.WriteLine("");

        for (var i = 0; i < gameObjectsHL.Length; i++)
        {
            if (gameObjectsHL[i])
            {
                if (gameObjectsHL[i].GetComponent <hyperlane>().prevent)
                {
                    sr.WriteLine("    prevent_hyperlane = { from = \"" + gameObjectsHL[i].GetComponent <hyperlane>().link0.systemid + "\" to = \"" + gameObjectsHL[i].GetComponent <hyperlane>().link1.systemid + "\" }");
                }
                else
                {
                    sr.WriteLine("    add_hyperlane = { from = \"" + gameObjectsHL[i].GetComponent <hyperlane>().link0.systemid + "\" to = \"" + gameObjectsHL[i].GetComponent <hyperlane>().link1.systemid + "\" }");
                }
            }
        }
        sr.WriteLine("}");
        sr.Close();
        UnityAnalytics.CustomEvent("savedGalaxy", new Dictionary <string, object>
        {
            { "systems", gameObjects.Length },
            { "nebulas", gameObjectsN.Length },
            { "hyperlanes", gameObjectsHL.Length },
            { "customSystems", customSys }
        });

        for (var i = 0; i < systemEditors.Count; i++)
        {
            systemEditors[i].GetComponent <systemeditor>().save();
        }

        fileName = "GeneratedMods\\" + file + ".mod";
        sr       = File.CreateText(fileName);
        sr.WriteLine("name=\"" + galaxyname + "\"");
        sr.WriteLine("path=\"mod/" + file + "\"");
        sr.WriteLine("tags={");
        sr.WriteLine("	\"Galaxy Generation\"");
        sr.WriteLine("}");
        sr.WriteLine("supported_version=\"" + supportedGameVersion + "\"");
        sr.Close();


        Log("Saved galaxy in\nGeneratedMods\\" + file);
    }
 public static void StartGameEvent()
 {
     UnityAnalytics.CustomEvent("StartGame", null);
 }
 public static void ClickedSocialFacebookEvent()
 {
     UnityAnalytics.CustomEvent("ClickFacebook", null);
 }
 public static void OpenOptionsEvent()
 {
     UnityAnalytics.CustomEvent("OpenOptions", null);
 }