Esempio n. 1
0
 private void Awake()
 {
     Scene.ActiveMB           = this;
     Scene.GameStats          = this._gameStats;
     Scene.SceneTracker       = this._sceneTracker;
     Scene.MutantControler    = this._mutantControler;
     Scene.MutantSpawnManager = this._mutantSpawnManager;
     Scene.Yacht            = this._yacht;
     Scene.PlaneCrash       = this._plane;
     Scene.PlaneCrashAnimGO = this._planeCrashAnimGO;
     Scene.TriggerCutScene  = this._triggerCutScene;
     Scene.RainFollowGO     = this._rainFollowGO;
     Scene.RainTypes        = this._rainTypes;
     Scene.WeatherSystem    = this._weatherSystem;
     Scene.HudGui           = this._hudGui;
     Scene.Cams             = this._cams;
     Scene.Clock            = this._clock;
     Scene.Atmosphere       = this._atmos;
     Scene.WorkScheduler    = this._workScheduler;
     Scene.LoadSave         = this._loadSave;
     Scene.PlaneGreebles    = this._planeGreebles;
     Scene.OceanFlat        = this._oceanFlat;
     Scene.OceanCeto        = this._oceanCeto;
     Scene.ShoreMask        = this._shoreMask;
     Scene.SinkHoleCenter   = this._sinkHoleCenter;
     Scene.CaveGrounds      = this._caveGrounds;
 }
Esempio n. 2
0
        // Timer fields.
        #endregion

        public CowBehaviour(KhvGame game, Animal owner)
            : base(game, owner)
        {
            texture = game.Content.Load <Texture2D>(Path.Combine("Entities", owner.Dataset.AssetName));
            world   = (game.GameStateManager.Current as GameplayScreen).World;

            calendarSystem = game.Components.GetGameComponent <CalendarSystem>();
            calendarSystem.OnDayChanged += new CalendarEventHandler(calendarSystem_OnDayChanged);

            weatherSystem = game.Components.GetGameComponent <WeatherSystem>();
            mapManager    = (game.GameStateManager.Current as GameplayScreen).World.MapManager;

            timers = new TimerWrapper()
            {
                AutoCreateNewTimers = true
            };
            owner.Components.AddComponent(timers);

            random = new Random();

            brain.PushState(Walk);
            brain.PushState(ChangeDirection);

            owner.Collider.OnCollision += new CollisionEventHandler(Collider_OnCollision);
        }
Esempio n. 3
0
    protected void UpdateWeather(WeatherSystem weatherSystem)
    {
        switch (state)
        {
        case WeatherState.STARTING:
            OnStarting(weatherSystem, (Time.time - _startTime) / _enterCrossTime);
            if (Time.time - _startTime >= _enterCrossTime)
            {
                _state = WeatherState.RUNNING;
            }
            break;

        case WeatherState.RUNNING:
            OnRunning(weatherSystem);
            break;

        case WeatherState.STOPPING:
            var factor = Mathf.Clamp((Time.time - _stopTime) / _exitCrossTime, 0, 1);
            if (_audioSource != null)
            {
                _audioSource.volume = 1 - factor;
            }
            OnStoping(weatherSystem, factor);
            break;
        }
    }
Esempio n. 4
0
 private void OnDestroy()
 {
     Scene.ActiveMB           = null;
     Scene.GameStats          = null;
     Scene.SceneTracker       = null;
     Scene.MutantControler    = null;
     Scene.MutantSpawnManager = null;
     Scene.Yacht            = null;
     Scene.PlaneCrash       = null;
     Scene.PlaneCrashAnimGO = null;
     Scene.TriggerCutScene  = null;
     Scene.RainFollowGO     = null;
     Scene.RainTypes        = null;
     Scene.WeatherSystem    = null;
     Scene.HudGui           = null;
     Scene.Cams             = null;
     Scene.Clock            = null;
     Scene.Atmosphere       = null;
     Scene.WorkScheduler    = null;
     Scene.LoadSave         = null;
     Scene.PlaneGreebles    = null;
     Scene.OceanFlat        = null;
     Scene.OceanCeto        = null;
     Scene.ShoreMask        = null;
     Scene.SinkHoleCenter   = null;
     Scene.CaveGrounds      = null;
 }
Esempio n. 5
0
    private void Awake()
    {
        components    = FindObjectsOfType <DragAndDropComponent>();
        weatherSystem = FindObjectOfType <WeatherSystem>();

        ClearUIText();
    }
Esempio n. 6
0
 protected override void OnStoping(WeatherSystem weatherSystem, float factor)
 {
     base.OnStoping(weatherSystem, factor);
     rainAmount = Mathf.LinearToGammaSpace(Mathf.Lerp(_rainAmount, 0, factor));
     weatherSystem.SetWeatherAmount(_rainAmount);
     UpdateRainWave(weatherSystem);
 }
Esempio n. 7
0
 protected override void OnStop(WeatherSystem weatherSystem)
 {
     if (weatherSystem.lightingBolt != null)
     {
         weatherSystem.lightingBolt.enabled = weatherSystem.weatherType == WeatherType.Rain || weatherSystem.weatherType == WeatherType.Heavy_Rain;
     }
 }
Esempio n. 8
0
 protected override void OnStarting(WeatherSystem weatherSystem, float factor)
 {
     base.OnStarting(weatherSystem, factor);
     rainAmount += _rainSpeed * Time.deltaTime;
     weatherSystem.SetWeatherAmount(_rainAmount);
     UpdateRainWave(weatherSystem);
 }
Esempio n. 9
0
        private async void UI_Load(object sender, EventArgs e)
        {
            Text = @"Yi Server - IP: " + YiCore.ServerIp;
            //await DbConverter.Convert();
            //await Db.SaveAsJsonAsync(SaveType.All);
            //await Database.Converters.MonsterDb.Load();
            //await Database.Converters.MagicTypeConverter.Load();
            //await Database.Converters.LevelExpConverter.Load();
            //Db.Serialize("Skills", Collections.Skills);
            //Db.Serialize("LevelExps", Collections.LevelExps);
            //Db.Serialize("BaseMonsters", Collections.BaseMonsters);
            //Db.Serialize("Monsters", Collections.Monsters);
            await Db.Load();

            BoothSystem.SetUpBooths();
            ScriptWatcher.Start();
            WeatherSystem.Start();
            //DayNightSystem.Start();

            //if (arg.Length > 0)
            //{
            //    Output.WriteLine("Running as 2nd Instance!");
            //    Servers.Start(5816);
            //}
            //else
            //{
            //    Output.WriteLine("Running as 1st Instance!");
            Servers.Start(9958);
            //    Process.Start("yi.exe", "secondInstance");
            //}

            PerformanceMonitor.Start();
        }
Esempio n. 10
0
 protected override void OnStart(WeatherSystem weatherSystem)
 {
     windDir.x = weatherSystem.windDir.x;
     windDir.y = weatherSystem.windDir.y;
     windDir.z = weatherSystem.windDir.z;
     windDir.w = 0;
     weatherSystem.SetGlobalVector("_WindDir", windDir);
 }
Esempio n. 11
0
        public TimeWidget(KhvGame khvGame, GameObject owner, WidgetManager owningManager, string name)
            : base(khvGame, owner, owningManager, name)
        {
            calendar      = khvGame.Components.GetGameComponent <CalendarSystem>();
            weatherSystem = khvGame.Components.GetGameComponent <WeatherSystem>();

            Initialize();
        }
Esempio n. 12
0
    protected override void OnStop(WeatherSystem weatherSystem)
    {
        var flare = GameObject.FindObjectOfType <LensFlare> ();

        if (flare != null)
        {
            flare.gameObject.SetActive(false);
        }
    }
Esempio n. 13
0
    protected override float GetWindProbability(WeatherSystem weatherSystem)
    {
        if (weatherType == WeatherType.Clear)
        {
            return(0.85f);
        }

        return(0);
    }
Esempio n. 14
0
 public override void Update(WeatherSystem weatherSystem)
 {
     if (state == WeatherState.STARTING || state == WeatherState.RUNNING)
     {
         //_sunnyIntensity = Mathf.Lerp(_sunnyIntensity, GetWeatherSunIntensity(weatherSystem),Time.deltaTime * weatherSystem.weatherCrossSpeed);
         //_skyIntensity = Mathf.Lerp(_skyIntensity, GetWeatherSkyIntensity(weatherSystem),Time.deltaTime * weatherSystem.weatherCrossSpeed);
     }
     base.Update(weatherSystem);
 }
Esempio n. 15
0
 protected override void OnClear(WeatherSystem weatherSystem)
 {
     _snowAmount = 0;
     weatherSystem.SetWeatherAmount(_snowAmount);
     if (weatherSystem.weatherType != WeatherType.Snow && weatherSystem.weatherType != WeatherType.Heavy_Snow)
     {
         weatherSystem._snowAmount = _snowAmount;
     }
 }
Esempio n. 16
0
    protected override float GetWindProbability(WeatherSystem weatherSystem)
    {
        if (weatherType == WeatherType.Snow)
        {
            return(0.85f);
        }

        return(base.GetWindProbability(weatherSystem));
    }
Esempio n. 17
0
    public override float GetWeatherSunIntensity(WeatherSystem weatherSystem)
    {
        if (weatherType == WeatherType.Heavy_Snow)
        {
            return(weatherSystem.snowSunIntensity * 0.1f);
        }

        return(weatherSystem.snowSunIntensity);
    }
Esempio n. 18
0
        public void InterpolationTest()
        {
            double v1       = 20;
            double v2       = 100;
            double weightv1 = 50;
            double result   = WeatherSystem.InterpolateWeighedDouble(v1, v2, weightv1);

            weightv1 = 80;
            result   = WeatherSystem.InterpolateWeighedDouble(v1, v2, weightv1);
        }
Esempio n. 19
0
        private void DoneEveryStartOfDay()
        {
            if (JobManager.Instance.CurrentJob != null)
            {
                JobManager.Instance.CurrentJob.WorkedToday = false;
            }

            WeatherSystem.ChangeWeather();
            Bank.Instance.AddPercentageToBalance();
        }
Esempio n. 20
0
        public void WeatherSystemTest()
        {
            int      CloudCover = 0;
            DateTime date       = new DateTime(2009, 10, 12);

            date = date.AddHours(7);
            Coordinate coord    = new Coordinate(64, 10);
            double     sunshine = WeatherSystem.CalculateSunShineWm2(date, 5, coord, CloudCover);
            //Assert.IsTrue(sunshine > 510 && sunshine < 560,
            //    string.Format("Sunshine Wm2 is {0}; should be between 510 and 560", sunshine));

            double sunheightDeg = WeatherSystem.CalculateSunHeightDeg(date, coord);
            //Assert.IsTrue(sunheightDeg > 32 && sunheightDeg < 34,
            //    string.Format("Sunheight Deg is {0}; should be around 33.8", sunheightDeg));

            double sunDeclination = WeatherSystem.CalculateSunDeclination(date, coord);
            //Assert.IsTrue(sunDeclination > 4.1 && sunDeclination < 4.4,
            //    string.Format("Sun Declination Deg is {0}; should be 4.3", sunDeclination));


            DateTimeFromTo SunRiseSet = WeatherSystem.CalculateSunRiseSunSet(date, coord);

            if (SunRiseSet.ToTime != null && SunRiseSet.FromTime != null)
            {
                GameManager.Instance.Log.LogDebug(string.Format(
                                                      "WeatherSystemTest() : Sunrise at {0}, Sunset at {1}",
                                                      SunRiseSet.FromTime, SunRiseSet.ToTime));
            }
            GameManager.Instance.CreateGame(new Player(), "test game");
            GameManager.Instance.Game.GameStartTime    = date;
            GameManager.Instance.Game.UpperLeftCorner  = new Coordinate(70, -10);
            GameManager.Instance.Game.LowerRightCorner = new Coordinate(40, 10);
            GameManager.Instance.GameData.InitMainWeatherSystems(
                GameConstants.WeatherSystemTypes.Rough,
                GameConstants.WeatherSystemSeasonTypes.Autumn);
            GameManager.Instance.GameData.RecreateWeatherDataFromMain();
            WeatherSystem weather = GameManager.Instance.GameData.GetWeather(new Coordinate(60, 5));

            Assert.IsNotNull(weather, "Weather should not be null.");

            var weather50degN = WeatherSystem.CreateRandomWeatherSystem(GameConstants.WeatherSystemTypes.Fine, GameConstants.WeatherSystemSeasonTypes.Autumn, 50);
            var weather70degN = WeatherSystem.CreateRandomWeatherSystem(GameConstants.WeatherSystemTypes.Fine, GameConstants.WeatherSystemSeasonTypes.Autumn, 70);

            GameManager.Instance.Game.GameCurrentTime = new DateTime(2030, 9, 29, 13, 20, 0);
            GameManager.Instance.GameData.RecreateWeatherDataFromMain();
            var wsystem1 = GameManager.Instance.GameData.GetWeather(new Coordinate(60, 5));

            Assert.IsTrue(wsystem1.TotalLightPercent > 75, "There should be daylight.");

            GameManager.Instance.Game.GameCurrentTime = new DateTime(2030, 9, 29, 22, 20, 0);
            GameManager.Instance.GameData.RecreateWeatherDataFromMain();
            var wsystem2 = GameManager.Instance.GameData.GetWeather(new Coordinate(60, 5));

            Assert.IsTrue(wsystem2.TotalLightPercent < 10, "There should be night.");
        }
Esempio n. 21
0
 public virtual void LateUpdate(WeatherSystem weatherSystem)
 {
     if (_state == WeatherState.IDLE || _state == WeatherState.OVER)
     {
         return;
     }
     if (weatherObject)
     {
         UpdateParticle(weatherSystem);
     }
 }
Esempio n. 22
0
 void Awake()
 {
     Debug.Log("WeatherSystem Init " + name);
     InitSky();
     if (useLighting)
     {
         InitLights();
     }
     UpdateWeather(false);
     OnAwake();
     _instance = this;
 }
Esempio n. 23
0
    protected override void OnStarting(WeatherSystem weatherSystem, float factor)
    {
        var sunLight = weatherSystem.sunLight;

        sunLight.shadowStrength = Mathf.Clamp01(Mathf.Lerp(sunLight.shadowStrength, weatherSystem.snowSkyIntensity, factor));
        snowAmount += _snowSpeed * Time.deltaTime;
        weatherSystem._snowAmount = snowAmount;
        weatherSystem.SetWeatherAmount(snowAmount);

        /*var bloom = Camera.main.GetComponent<UnityStandardAssets.ImageEffects.Bloom> ();
         * if(bloom!=null)
         *      bloom.bloomIntensity = (1-factor) * (weatherSystem.maxBloomIntensity - weatherSystem.minBloomIntensity) + weatherSystem.minBloomIntensity;*/
    }
Esempio n. 24
0
    protected override void OnStoping(WeatherSystem weatherSystem, float factor)
    {
        var sunLight = weatherSystem.sunLight;

        sunLight.shadowStrength = Mathf.Lerp(sunLight.shadowStrength, weatherSystem.lightSource.shadowStrength, factor);

        snowAmount = Mathf.LinearToGammaSpace(Mathf.Lerp(_snowAmount, 0, factor));
        weatherSystem.SetWeatherAmount(_snowAmount);

        /*var bloom = Camera.main.GetComponent<UnityStandardAssets.ImageEffects.Bloom> ();
         * if(bloom!=null)
         *      bloom.bloomIntensity = factor * (weatherSystem.maxBloomIntensity - weatherSystem.minBloomIntensity) + weatherSystem.minBloomIntensity;*/
    }
Esempio n. 25
0
 public void Stop(WeatherSystem weatherSystem, float crossTime)
 {
     foreach (var weatherParticle in weatherParticles)
     {
         weatherParticle.Stop();
     }
     if (crossTime >= 0)
     {
         _exitCrossTime = crossTime;
     }
     _stopTime = Time.time;
     _state    = WeatherState.STOPPING;
     OnStop(weatherSystem);
 }
Esempio n. 26
0
 protected void OnDestroy()
 {
     foreach (var activeWeather in activeWeathers)
     {
         if (activeWeather != weather)
         {
             weather.Destroy(this);
         }
     }
     weather.Destroy(this);
     activeWeathers.Clear();
     ClearGlobalShaders();
     if (_instance == this)
     {
         _instance = null;
     }
 }
Esempio n. 27
0
    public virtual void Init(WeatherSystem weatherSystem)
    {
        this.weatherType = weatherSystem.weatherType;

        var weatherPrefab = GetWeatherPrefab(weatherSystem);

        if (weatherPrefab && !weatherSystem.dontShowParticles)
        {
            weatherObject = GameObject.Instantiate <GameObject> (weatherPrefab);
            var weatherParticle = weatherObject.GetComponent <ParticleSystem> ();
            if (weatherParticle == null)
            {
                for (int i = 0; i < weatherObject.transform.childCount; ++i)
                {
                    weatherParticle = weatherObject.transform.GetChild(i).GetComponent <ParticleSystem> ();
                    if (weatherParticle != null)
                    {
                        weatherParticle.playOnAwake = false;
                        weatherParticle.Pause();
                        weatherParticles.Add(weatherParticle);
                    }
                }
            }
            weatherObject.transform.parent     = weatherSystem.transform;
            weatherObject.transform.localScale = Vector3.one;
            weatherParticle.playOnAwake        = false;
            weatherParticle.Pause();
            UpdateParticle(weatherSystem);
        }

        var weatherSound = GetWeatherSound(weatherSystem);

        if (weatherSound != null && !weatherSystem.soundMute)
        {
            _audioSource             = weatherSystem.gameObject.AddComponent <AudioSource> ();
            _audioSource.playOnAwake = false;
            _audioSource.loop        = true;
            _audioSource.clip        = weatherSound;
            _audioSource.volume      = GetWeatherSoundVolume(weatherSystem);
        }

        _state          = WeatherState.IDLE;
        _enterCrossTime = weatherSystem.weatherEnterCrossTime;
        _exitCrossTime  = weatherSystem.weatherExitCrossTime;
    }
Esempio n. 28
0
    protected override void OnStart(WeatherSystem weatherSystem)
    {
        if (weatherType == WeatherType.Rain)
        {
            foreach (var weatherParticle in weatherParticles)
            {
                weatherParticle.maxParticles = weatherParticle.maxParticles * 3 / 4;
            }

            //weatherParticle.emission.rate.constantMin = weatherParticle.emission.rate.constantMin * 3 / 4;
        }
        if (weatherSystem.lightingBolt != null)
        {
            weatherSystem.lightingBolt.enabled = true;
        }
        weatherSystem.Temperature = 20;
        rainAmount = 0;
    }
Esempio n. 29
0
    protected override void UpdateParticle(WeatherSystem weatherSystem)
    {
        var forward = weatherSystem.weatherCamera.transform.forward;
        var right   = weatherSystem.weatherCamera.transform.right;

        forward.y = 0;
        forward.Normalize();
        right.y = 0;
        right.Normalize();

        Vector3 offset = forward * weatherSystem.windParticleOffset.z + right * weatherSystem.windParticleOffset.x + Vector3.up * weatherSystem.windParticleOffset.y;

        weatherObject.transform.position = weatherSystem.weatherCamera.transform.position + offset;
        var direction = (weatherSystem.weatherCamera.transform.position + forward * weatherSystem.windParticleOffset.z - weatherObject.transform.position);

        direction.y = 0;
        direction.Normalize();
        weatherObject.transform.rotation = Quaternion.LookRotation(direction);
    }
Esempio n. 30
0
    public void Start(WeatherSystem weatherSystem)
    {
        if (_state != WeatherState.IDLE)
        {
            return;
        }

        foreach (var weatherParticle in weatherParticles)
        {
            weatherParticle.Play();
        }

        if (audioSource != null)
        {
            audioSource.Play();
        }
        _startTime = Time.time;
        _state     = WeatherState.STARTING;
        OnStart(weatherSystem);
    }
Esempio n. 31
0
 private void Awake()
 {
     Scene.ActiveMB = this;
     Scene.GameStats = this._gameStats;
     Scene.SceneTracker = this._sceneTracker;
     Scene.MutantControler = this._mutantControler;
     Scene.MutantSpawnManager = this._mutantSpawnManager;
     Scene.Yacht = this._yacht;
     Scene.PlaneCrash = this._plane;
     Scene.PlaneCrashAnimGO = this._planeCrashAnimGO;
     Scene.TriggerCutScene = this._triggerCutScene;
     Scene.RainFollowGO = this._rainFollowGO;
     Scene.RainTypes = this._rainTypes;
     Scene.WeatherSystem = this._weatherSystem;
     Scene.HudGui = this._hudGui;
     Scene.Cams = this._cams;
     Scene.Clock = this._clock;
     Scene.Atmosphere = this._atmos;
     Scene.WorkScheduler = this._workScheduler;
     Scene.LoadSave = this._loadSave;
     Scene.PlaneGreebles = this._planeGreebles;
     Scene.OceanFlat = this._oceanFlat;
     Scene.OceanCeto = this._oceanCeto;
     Scene.ShoreMask = this._shoreMask;
     Scene.SinkHoleCenter = this._sinkHoleCenter;
     Scene.CaveGrounds = this._caveGrounds;
 }
Esempio n. 32
0
 private void OnDestroy()
 {
     Scene.ActiveMB = null;
     Scene.GameStats = null;
     Scene.SceneTracker = null;
     Scene.MutantControler = null;
     Scene.MutantSpawnManager = null;
     Scene.Yacht = null;
     Scene.PlaneCrash = null;
     Scene.PlaneCrashAnimGO = null;
     Scene.TriggerCutScene = null;
     Scene.RainFollowGO = null;
     Scene.RainTypes = null;
     Scene.WeatherSystem = null;
     Scene.HudGui = null;
     Scene.Cams = null;
     Scene.Clock = null;
     Scene.Atmosphere = null;
     Scene.WorkScheduler = null;
     Scene.LoadSave = null;
     Scene.PlaneGreebles = null;
     Scene.OceanFlat = null;
     Scene.OceanCeto = null;
     Scene.ShoreMask = null;
     Scene.SinkHoleCenter = null;
     Scene.CaveGrounds = null;
 }