Ejemplo n.º 1
0
 public void RemoveWeatherEffect(WeatherEffect effect)
 {
     if (weatherEffects.Remove(effect))
     {
         WorldTileChanged();
     }
 }
Ejemplo n.º 2
0
 IEnumerator fadeEffect(WeatherEffect effect, bool fadingIn)
 {
     while (effect.emitter.maxEmission < effect.maxParticles)
     {
         effect.emitter.maxEmission += fadeRate;
         yield return null;
     }
 }
Ejemplo n.º 3
0
 public void SetValue(WeatherEffect weatherEffect)
 {
     if (_dropdown == null)
     {
         _dropdown = GetComponent <Dropdown>();
     }
     _dropdown.value = _effects.FindIndex(w => w.objectName == weatherEffect.objectName);
 }
Ejemplo n.º 4
0
        MapType(string name, List <TextNode> nodes)
        {
            Name = name;

            var fields = TypeLoader.GetFields(this);

            foreach (var node in nodes)
            {
                switch (node.Key)
                {
                case nameof(TerrainGenerationBase):
                    TerrainGenerationBase = new TerrainGeneratorInfo(node.Convert <int>(), node.Children);

                    break;

                case nameof(NoiseMaps):
                    NoiseMaps = new NoiseMapInfo[node.Children.Count];

                    for (int i = 0; i < NoiseMaps.Length; i++)
                    {
                        var child = node.Children[i];
                        NoiseMaps[i] = new NoiseMapInfo(child.Convert <int>(), child.Children);
                    }

                    break;

                case nameof(PatrolPlacers):
                    PatrolPlacers = new PatrolPlacerInfo[node.Children.Count];

                    for (int i = 0; i < PatrolPlacers.Length; i++)
                    {
                        PatrolPlacers[i] = new PatrolPlacerInfo(node.Children[i].Children);
                    }

                    break;

                case nameof(WeatherEffects):
                    WeatherEffects = new WeatherEffect[node.Children.Count];

                    for (int i = 0; i < WeatherEffects.Length; i++)
                    {
                        WeatherEffects[i] = new WeatherEffect(node.Children[i].Children);
                    }

                    break;

                default:
                    TypeLoader.SetValue(this, fields, node);

                    break;
                }
            }

            if (TerrainGenerationBase == null)
            {
                throw new MissingNodeException(name, "BaseTerrainGeneration");
            }
        }
Ejemplo n.º 5
0
 public void AddWeatherEffect(WeatherEffect effect)
 {
     if (weatherEffects.Contains(effect))
     {
         return;
     }
     weatherEffects.Add(effect);
     WorldTileChanged();
 }
Ejemplo n.º 6
0
        public void InitData(WeatherAmbientData targetData, WeatherTimeData timeData, WeatherEffect weatherEffect, Light light)
        {
            m_currentAmbientData = m_ambientData;
            m_targetAmbientData  = targetData;

            m_currentTimeData = m_timeData;
            m_targetTimeData  = timeData;
            m_weatherEffect   = weatherEffect;
            m_light           = light;

            m_light.shadows = targetData.ShadowType;
        }
Ejemplo n.º 7
0
    internal void Initialize(string mapname)
    {
        draw = (prefs = WeatherEffect.GetPrefs(mapname)) != null;

        if (draw)
        {
            cloudsParent = new GameObject("_clouds");
            cloudsParent.transform.parent = MapRenderer.mapParent.transform;

            Camera.main.backgroundColor = prefs.skyColor;

            LoadCloudTextures();

            SetupClouds();
        }
    }
Ejemplo n.º 8
0
    private void Start()
    {
        cloudMat = cloudRenderer.material;
        cloudRenderer.material = cloudMat;

        skyMat = skyRenderer.material;
        skyRenderer.material = skyMat;

        RenderSettings.fogMode = FogMode.Linear;
        //   RenderSettings.fogMode = FogMode.ExponentialSquared;

        RenderSettings.fogColor = defaultSettings.fogColor;
        skyMat.SetColor("_Color", RenderSettings.fogColor);
        cloudMat.SetColor("_Color", defaultSettings.cloudColor);
        mainCamera.farClipPlane = defaultSettings.farClipPlaneDistance;
        if (defaultSettings.fogStartDistance >= defaultSettings.fogDistance)
        {
            defaultSettings.fogStartDistance = defaultSettings.fogDistance - 1f;
        }
        RenderSettings.fogStartDistance = defaultSettings.fogStartDistance;
        RenderSettings.fogEndDistance   = defaultSettings.fogDistance;

        //    RenderSettings.fogDensity = defaultSettings.fogDensity;

        curWeatherEffect = WeatherEffect.none;
        curRotation      = defaultSettings.rotationSpeed;

        triggerCount = 0;

        rainPS = rainEffect.GetComponentInChildren <ParticleSystem>();
        rainEM = rainPS.emission;
        rainMM = rainPS.main;

        snowPS = snowEffect.GetComponentInChildren <ParticleSystem>();
        snowEM = snowPS.emission;
        snowMM = snowPS.main;

        windPS = windEffect.GetComponentInChildren <ParticleSystem>();
        windEM = windPS.emission;
        windMM = windPS.main;

        sandstormPS = sandstormEffect.GetComponentInChildren <ParticleSystem>();
        sandstormEM = sandstormPS.emission;
        sandstormMM = sandstormPS.main;

        chara = PlayerManager.GetMainPlayer().gameObject;
    }
Ejemplo n.º 9
0
    private void OnMapComplete(string mapname)
    {
        //everything needed was loaded, no need to keep the current cache
        //FileCache.Report();
        FileCache.ClearAll();

        //add sounds to playlist (and cache)
        foreach (var sound in world.sounds)
        {
            sounds.Add(sound, null);
        }
        Debug.Log(sounds.Count() + " sounds loaded");


        if (WeatherEffect.HasMap(mapname))
        {
            //create sky
            sky = new Sky();
            //initialize clouds
            sky.Initialize(mapname);
        }
        else
        {
            //no weather effects, set sky color to blueish
            //Camera.main.backgroundColor = new Color(0.4f, 0.6f, 0.8f, 1.0f);
        }

        //add lights
        GameObject lightsParent = new GameObject("_lights");

        lightsParent.transform.parent = mapParent.transform;

        foreach (var light in world.lights)
        {
            var lightObj = new GameObject(light.name);
            lightObj.transform.SetParent(lightsParent.transform);
            Light lightComponent = lightObj.AddComponent <Light>();
#if UNITY_EDITOR
            lightComponent.lightmapBakeType = LightmapBakeType.Baked;
#endif

            lightComponent.color = new Color(light.color[0], light.color[1], light.color[2]);
            lightComponent.range = light.range;
            Vector3 position = new Vector3(light.pos[0] + width, -light.pos[1], light.pos[2] + height);
            lightObj.transform.position = position;
        }
    }
Ejemplo n.º 10
0
        private void Start()
        {
            _selectionDisplayControl = GameObject.FindWithTag(Tags.MainCamera).GetComponent <SelectionDisplayControl>();
            _selectionModeControl    = GameObject.FindWithTag(Tags.PowerButtonPanel).GetComponent <SelectionModeControl>();
            _sessionManager          = GameObject.FindWithTag(Tags.SessionManager).GetComponent <SessionManager>();

            _weatherEffectDropdown = GetComponentInChildren <WeatherEffectDropdown>();
            _weatherEffectDropdown.OnWeatherEffectChanged += delegate(object sender, WeatherEffectEventArgs args)
            {
                _selectedEffect = args.WeatherEffect;
            };

            addButton.onClick.AddListener(AddWeatherEffect);
            removeButton.onClick.AddListener(RemoveWeatherEffect);


            _selectionModeControl.OnChangedSelectionMode += delegate(object sender, ChangeSelectionModeEventArgs args)
            {
                switch (args.NewMode)
                {
                case SelectionMode.Area:
                case SelectionMode.Region:
                    submitClimateChange.interactable = false;
                    break;

                case SelectionMode.Tile:
                case SelectionMode.AreaCreation:
                case SelectionMode.RegionCreation:
                    submitClimateChange.interactable = false;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            };

            _climateDropdown = GetComponentInChildren <ClimateDropdown>();
            _climateDropdown.SetValue(Climate.Temperate);
            submitClimateChange.onClick.AddListener(SubmitClimateChange);
            submitClimateChange.interactable = false;

            _climateDropdown.OnClimateChanged += OnClimateChanged;
        }
Ejemplo n.º 11
0
    private void OnValidate()
    {
        isDirty = true;

        bool root = GetComponentInParent <WeatherEffect>();

        if (isRoot != root)
        {
            isRoot   = root;
            children = GetComponentsInChildren <WeatherEffect>();
            if (isRoot)
            {
                parent = null;
                foreach (var effect in children)
                {
                    if (effect != this)
                    {
                        effect.SetParent(this);
                    }
                }
            }
        }

        if (!Application.isPlaying)
        {
            initialized = false;

            if (isRoot)
            {
                foreach (var effect in children)
                {
                    effect.m_Intensity = Intensity;
                    effect.UpdateParticleSystemSettings();
                }
            }

            UpdateParticleSystemSettings();
        }
    }
Ejemplo n.º 12
0
 public WeatherEffectEventArgs(WeatherEffect weatherEffect)
 {
     WeatherEffect = weatherEffect;
 }
Ejemplo n.º 13
0
    void ChangeWeather(WeatherEffect newEffect)
    {
        if (newEffect != curWeatherEffect)
        {
            //Remove Old
            if (curWeatherEffect != WeatherEffect.none)
            {
                StopCoroutine("DeactivateDelay");
                if (curWeatherEffect == WeatherEffect.rain)
                {
                    curWeatherObj  = null;
                    rainEM.enabled = false;
                    rainMM.loop    = false;
                    StartCoroutine("DeactivateDelay", rainEffect);
                }
                if (curWeatherEffect == WeatherEffect.snow)
                {
                    curWeatherObj  = null;
                    snowEM.enabled = false;
                    snowMM.loop    = false;
                    StartCoroutine("DeactivateDelay", snowEffect);
                }
                if (curWeatherEffect == WeatherEffect.wind)
                {
                    curWeatherObj  = null;
                    windEM.enabled = false;
                    windMM.loop    = false;
                    StartCoroutine("DeactivateDelay", windEffect);
                }
                if (curWeatherEffect == WeatherEffect.sandstorm)
                {
                    curWeatherObj       = null;
                    sandstormEM.enabled = false;
                    sandstormMM.loop    = false;
                    StartCoroutine("DeactivateDelay", sandstormEffect);
                }
            }

            //Start New
            if (newEffect != WeatherEffect.none)
            {
                if (newEffect == WeatherEffect.rain)
                {
                    curWeatherObj = rainEffect;
                    rainEffect.SetActive(true);
                    rainEM.enabled = true;
                    rainMM.loop    = true;
                    rainPS.Play();
                }
                if (newEffect == WeatherEffect.snow)
                {
                    curWeatherObj = snowEffect;
                    snowEffect.SetActive(true);
                    snowEM.enabled = true;
                    snowMM.loop    = true;
                    snowPS.Play();
                }
                if (newEffect == WeatherEffect.wind)
                {
                    curWeatherObj = windEffect;
                    windEffect.SetActive(true);
                    windEM.enabled = true;
                    windMM.loop    = true;
                    windPS.Play();
                }
                if (newEffect == WeatherEffect.sandstorm)
                {
                    curWeatherObj = sandstormEffect;
                    sandstormEffect.SetActive(true);
                    sandstormEM.enabled = true;
                    sandstormMM.loop    = true;
                    sandstormPS.Play();
                }
            }

            curWeatherEffect = newEffect;
        }
    }
Ejemplo n.º 14
0
 private void WeatherEffectChanged(WeatherEffect weatherEffect)
 {
     OnWeatherEffectChanged?.Invoke(this, new WeatherEffectEventArgs(weatherEffect));
 }
Ejemplo n.º 15
0
 private void SetParent(WeatherEffect weatherEffect)
 {
     isRoot = false;
     parent = weatherEffect;
 }