/*
     * Stops Enemies and the Sun From executing(Basically Pausing them) if you send a false boolean
     * Resumes Enemies and Sun if you send a true boolean
     */
    private void PauseOrResumeEnemiesAndSun(bool value)
    {
        //The current Way of getting enemies is terrible so I'm doing it this way
        Enemy[]   enemiesArray = FindObjectsOfType <Enemy>();
        SunScript sunScript    = FindObjectOfType <SunScript>();

        //For each Enemy
        for (int i = 0; i < enemiesArray.Length; i++)
        {
            //Pause it or resume it
            enemiesArray[i].enabled = value;
            enemiesArray[i].ThisAnimator.enabled = value;

            //Pause all enemies sounds
            AudioSource[] audioSources = enemiesArray[i].GetAudioSources();

            if (audioSources.Length > 0)
            {
                for (int j = 0; j < audioSources.Length; j++)
                {
                    if (value)
                    {
                        audioSources[j].UnPause();
                    }
                    else
                    {
                        audioSources[j].Pause();
                    }
                }
            }
        }

        //For the Sun
        sunScript.enabled = value;
    }
Esempio n. 2
0
 public void SetupSimulation(EarthScript earth, SunScript sun)
 {
     this.earth      = earth;
     this.sun        = sun;
     gameObject.name = speciesName;
     foreach (var organ in GetComponents <BasicSpeciesOrganScript>())
     {
         organ.SetBasicSpeciesScript(this);
     }
     SetupSpecificSimulation();
     jobController = GetComponent <BasicJobController>();
 }
Esempio n. 3
0
    void Awake()
    {
        // Register the singleton
        if (Instance != null)
        {
            Debug.LogError("Multiple instances of BeatsEngine!");
        }
        Instance = this;

        audioSource       = GetComponent <AudioSource>();
        sunScript         = sun.GetComponent <SunScript>();
        terrainGeneration = GetComponent <TerrainGeneration>();
    }
Esempio n. 4
0
    public void OnFinishedLoadingAllScene()
    {
        earth = GameObject.Find("Earth").GetComponent <EarthScript>();
        sun   = GameObject.Find("Sun").GetComponent <SunScript>();

        SpeciesManager.Instance.GetSpeciesMotor().enabled = true;
        SpeciesManager.Instance.GetSpeciesMotor().SetupSimulation(earth, sun);
        earth.SetUpEarth(earthSize, simulationSpeed);
        sun.SetupSun(earth);
        SpeciesManager.Instance.GetSpeciesMotor().StartSimulation();
        User.Instance.StartSimulation();
        simulationInitialised = true;
        earth.StartSimulation();
    }
Esempio n. 5
0
 public void SetupSimulation(EarthScript earth, SunScript sun)
 {
     this.earth  = earth;
     canvasUI    = GameObject.Find("Canvas");
     graphWindow = canvasUI.transform.GetChild(0).GetComponent <GraphWindow>();
     graphWindow.gameObject.SetActive(false);
     for (int i = 0; i < transform.childCount; i++)
     {
         GameObject newCountPrefab = Instantiate(populaitonCountPrefab, GetPopulationCountParent());
         newCountPrefab.GetComponent <SpeciesPopulaitonCount>().SetSpecies(transform.GetChild(i).GetComponent <BasicSpeciesScript>(), i);
     }
     foreach (var speciesHolder in GetAllSpeciesHolders())
     {
         speciesHolder.Destroy();
     }
     for (int i = 0; i < transform.childCount; i++)
     {
         allSpecies.Add(transform.GetChild(i).GetComponent <BasicSpeciesScript>());
         transform.GetChild(i).GetComponent <BasicSpeciesScript>().speciesIndex = i;
     }
     for (int i = 0; i < GetAllSpecies().Count; i++)
     {
         if (GetAllSpecies()[i].GetComponent <AnimalSpecies>() != null)
         {
             animalSpecies.Add(GetAllSpecies()[i].GetComponent <AnimalSpecies>());
             GetAllSpecies()[i].specificSpeciesIndex = animalSpecies.Count - 1;
         }
     }
     for (int i = 0; i < GetAllSpecies().Count; i++)
     {
         if (GetAllSpecies()[i].GetComponent <PlantSpecies>() != null)
         {
             plantSpecies.Add(GetAllSpecies()[i].GetComponent <PlantSpecies>());
             GetAllSpecies()[i].specificSpeciesIndex = plantSpecies.Count - 1;
         }
     }
     foreach (var species in GetAllSpecies())
     {
         species.SetupSimulation(earth, sun);
     }
 }
Esempio n. 6
0
 void PlaceSun()
 {
     this.sun  = Instantiate(sunPrefab, sunSpawnPoint, Quaternion.identity);
     sunScript = this.sun.transform.GetComponent <SunScript>();
 }
Esempio n. 7
0
 private void Awake()
 {
     instance = this;
 }