Exemple #1
0
    void Start()
    {
        Popup.SetActive(false);
        StartCoroutine("TimeOfDayFiniteStateMachine");
        //Start TimeOfDayFiniteStateMachine on Start up

        _dayPhases = DayPhases.Night;
        //Set day phase to night on start up

        _hours = 0;
        //hours equal five on start up
        _minutes = 0;
        //minutes equals fifty nine on start up
        _counter = 0;
        //Counter equals fifty nine on start up

        //date.time.now 현재시간 가져오기
        //저장기능 가져오기

        _days = 1;
        //Days equal one on start up

        if (_instance == null)
        {
            _instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }
    private void Update()
    {
        Hour24 += Time.deltaTime / m_secPerHour;
        Hour12 += Time.deltaTime / m_secPerHour;
        if (Hour24 > 24)
        {
            if (m_onDayEnded != null)
            {
                m_onDayEnded();
            }
            Hour24 = 0;
            m_currentDay++;
        }
        if (Hour12 > 12)
        {
            Hour12 = 0;

            if (m_currentDayPhase == DayPhases.DAY)
            {
                m_currentDayPhase = DayPhases.NIGHT;
                m_blackWhiteMat.SetFloat("_isReverse", 1);
            }
            else
            {
                m_currentDayPhase = DayPhases.DAY;
                m_blackWhiteMat.SetFloat("_isReverse", 0);
            }
            if (m_onDayNightChanged != null)
            {
                m_onDayNightChanged();
            }
        }
    }
Exemple #3
0
    void Dusk()
    {
        Debug.Log("Dusk");

        if (_hours == _nightStartTime)
        //if hours equals night start time
        {
            _dayPhases = DayPhases.Night;
            //set day phase to Night
        }
    }
Exemple #4
0
    void Night()
    {
        //Debug.Log("Night");

        NightSunLightManager();                                         //Call function NightSunManager
        NightAmbientLightManager();                                     //Call function NightAmbientLightManager

        if (_hours == _dawnStartTime && _hours < _dayStartTime)         //if hours equas dawn start time AND hours is still less thank day start time
        {
            _dayPhases = DayPhases.Dawn;                                //Set day Phase to dawn
        }
    }
Exemple #5
0
    void Day()
    {
        //Debug.Log("Day");

        DaySunLightManager();                                     //Call DaySunLightManager
        DayAmbientLightManager();                                 //Call DayAmbientLightManager

        if (_hours == _duskStartTime && _hours < _nightStartTime) //if hours equas dusk start time AND hours is still less thank night start time
        {
            _dayPhases = DayPhases.Dusk;                          //Set day Phase to dusk
        }
    }
Exemple #6
0
    /*
     * void SunRotationManager()
     * {
     *  //Debug.Log("SunRotationManager");
     *  if (_spring == true)                                //if spring equals true
     *      _dayTemp = _springDayLength / 10;               //then day temp equals spring day length divided by ten
     *
     *  if (_summer == true)                                //if summer equals true
     *      _dayTemp = _summerDayLength / 10;               //then day temp equals summer day length divided by ten
     *
     *  if (_autumn == true)                                //if autumn equals true
     *      _dayTemp = _autumnDayLength / 10;               //then day temp equals autumn day length divided by ten
     *
     *  if (_winter == true)                                //if winter equals true
     *      _dayTemp = _winterDayLength / 10;               //then day temp equals winter day length divided by ten
     *
     *
     *  _rotTemp = (_dayTemp / SecondMultiplier);                        //Rotation temp equals the day temp devided by (360 + 180) degrees
     *
     *  transform.RotateAround (                            //rotate sun around
     *      _sunPivotPoint.position,                        //the pivot point (axis)
     *      Vector3.forward,                                //shorthand for writing vector 3 (0,0,1) (point)
     *      _rotTemp * Time.deltaTime);                     //by rotation temp times time.deltatime
     *
     * }
     */


    void Dawn()
    {
        //Debug.Log("Dawn");

        DawnSunLightManager();                                  //Call DawnSunlightManager function
        DawnAmbientLightManager();                              //Call DawnAmbientLightManager function

        if (_hours == _dayStartTime && _hours < _duskStartTime) //if hours equas day start time AND hours is still less thank dusk start time
        {
            _dayPhases = DayPhases.Day;                         //Set day Phase to day
        }
    }
Exemple #7
0
    void Night()
    {
        Debug.Log("Night");

        if (_hours == _dawnStartTime && _hours < _dayStartTime)
        //if hours equals down start time and hours is still
        //less than day start time
        {
            _dayPhases = DayPhases.Dawn;
            //set day phase to Dawn
        }
    }
Exemple #8
0
    void Dawn()
    {
        Debug.Log("Dawn");

        if (_hours == _dayStartTime && _hours < _duskStartTime)
        //if hours equals day start time and hours is still
        //less than dusk start time
        {
            _dayPhases = DayPhases.Day;
            //set day phase to day
        }
    }
Exemple #9
0
    void Day()
    {
        Debug.Log("Day");


        if (_hours == _duskStartTime && _hours < _nightStartTime)
        //if hours equals dusk start time and hours is still
        //less than night start time
        {
            _dayPhases = DayPhases.Dusk;
            //set day phase to dusk
        }
    }
Exemple #10
0
    void Dusk()
    {
        //Debug.Log("Dusk");

        DuskSunLightManager();
        DuskAmbientLightManager();



        if (_hours == _nightStartTime)                  //if hours equas dusk start time
        {
            _dayPhases = DayPhases.Night;               //Set day Phase to night
        }
    }
Exemple #11
0
    // Use this for initialization
    void Start()
    {
        StartCoroutine("TimeOfDayFiniteStateMachine"); //Start TimeOfDayFiniteStateMachine on start up

        _dayPhases = DayPhases.Day;                    //Set day Phase to day


        //_sun.color = Color.Lerp(Color.black, Color.white, Time.time * 0.001f);

        _hours   = 11;                                       //hours equals time set on start up
        _minutes = 59;                                       //minutes equals time set on start up
        _counter = 55;                                       //Counter equals time set on start up

        _days = 1;                                           //Days equals one on start up

        _calendarDays = 1;                                   //calendar days equal one on start up
        _october      = true;                                //start in the month of october on start up
        _autumn       = true;                                //start in the season of autumn on start up

        _dawnStartTime  = _dawnAutumnStartTime;              //Dawn start time is equal to Autumn
        _dayStartTime   = _dayAutumnStartTime;               //Day start time is equal to Autumn
        _duskStartTime  = _duskAutumnStartTime;              //Dusk start time is equal to Autumn
        _nightStartTime = _nightAutumnStartTime;             //Night start time is equal to Autumn

        _autumnDayLength = _nightStartTime - _dawnStartTime; //autumn daylength equals night start time minus the dusk start time

        _years            = 2016;                            //years equal 2016 on startup
        _leapYearsCounter = 4;                               //leap year counter equals 4 on startup

        /*
         * GameObject _sunPivotGO =                            //sun pivot game object is equal to
         *  GameObject.FindGameObjectWithTag("SunPivot");   //game object "SunPivot" tag
         *
         * _sunPivotPoint = _sunPivotGO.transform;             //Caches sun pivot point position
         *
         * _sunPivotPoint.transform.position =                 //Set sun pivot point
         *  new Vector3(                                    //to a new vector 3
         *      _centreOfGameWorld,0,_centreOfGameWorld);   //at this position (centre of scene)
         */

        DiverManager.Instance.WaveCount = _days;

        //light.color = new Color(r, g, b);
    }
Exemple #12
0
    void Awake()
    {
        Instance = this;

        _dayPhases = DayPhases.Night;                             //Set day Phase to night on start up

        RenderSettings.ambientIntensity = _nightAmbientIntensity; //RenderSettings ambient intensity is equal to night startup

        //GetComponent<Light>().intensity = _nightSunIntensity; //Set sun intensity to night on start up

        /*
         * transform.position =                                //position is equal to
         *  new Vector3(                                    //a new vector 3 position
         *  (_centreOfGameWorld * 2),0,_centreOfGameWorld); //at this position
         *
         * transform.localEulerAngles = new Vector3(0, -90, 0);//Suns rotation is equal to these (x, x, x) values
         */
        lightAnims.SetBool("Playanim", true);
        lightAnims.speed = 0.01f;
    }
Exemple #13
0
        private void SetLevelTestValues(Level level)
        {
            var globalLightShadowMapParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0,
                                                                   PixelInternalFormat.DepthComponent16, EngineStatics.globalSettings.ShadowMapRezolution.X, EngineStatics.globalSettings.ShadowMapRezolution.Y,
                                                                   PixelFormat.DepthComponent, PixelType.Float, TextureWrapMode.Repeat);

            level.DirectionalLight = new DirectionalLightWithShadow(level.Camera, globalLightShadowMapParams, new Vector3(-100, -10, 50), new Vector4(0.4f, 0.4f, 0.4f, 1),
                                                                    new Vector4(0.7f, 0.7f, 0.7f, 1.0f), new Vector4(1, 1, 1, 1));

            var dayPhases = new DayPhases(new Morning(new Vector3(0.3f, 0.3f, 0.3f), new Vector3(0.7f, 0.7f, 0.7f), new Vector3(.7f)),
                                          new DayPhases.Day(new Vector3(0.4f, 0.4f, 0.4f), new Vector3(0.9f, 0.79f, 0.79f), new Vector3(1.0f)),
                                          new Evening(new Vector3(0.3f, 0.3f, 0.3f), new Vector3(0.7f, 0.30f, 0.30f), new Vector3(0.9f)),
                                          new Night(new Vector3(0.09f, 0.09f, 0.09f), new Vector3(0.1f, 0.1f, 0.1f), new Vector3(0.0f)));

            level.DayCycle = new DayLightCycle(level.DirectionalLight,
                                               Math.Max(level.LevelSize.X, level.LevelSize.Y), dayPhases);
            level.DayCycle.SetTime(25);
            level.DayCycle.TimeFlow = 0.001f;

            level.Mist = new MistComponent(0.003f, 1f, new Vector3(0.7f, 0.75f, 0.8f));

            // temporary
            //level.terrain = new Landscape(level.MAP_SIZE, level.MAP_HEIGHT, 3,
            //       ProjectFolders.HeightMapsTexturesPath + "heightmap2.png",
            //       ProjectFolders.MultitexturesPath + "NewLandscape/volcanictundrarocks01.jpg",
            //       ProjectFolders.MultitexturesPath + "NewLandscape/tundra02.jpg",
            //       ProjectFolders.MultitexturesPath + "b.png",
            //       ProjectFolders.MultitexturesPath + "NewLandscape/snow01.jpg",
            //       ProjectFolders.MultitexturesPath + "blendMap.png");

            //level.terrain.SetNormalMapR(ProjectFolders.MultitexturesPath + "NewLandscape/volcanictundrarocks01_n.png");
            //level.terrain.SetNormalMapG(ProjectFolders.MultitexturesPath + "NewLandscape/tundra02_n.png");
            ////level.Map.SetNormalMapBlack(ProjectFolders.MultitexturesPath + "NewLandscape/snow01_n.png");
            //level.terrain.SetNormalMapB(ProjectFolders.NormalMapsPath + "brick_nm_high.png");
            //level.terrain.SetMist(level.Mist);

            string modelPath       = ProjectFolders.ModelsPath + "house00.obj";
            string texturePath     = ProjectFolders.TextureAtlasPath + "houseDiffuse.jpg";
            string normalMapPath   = ProjectFolders.NormalMapsPath + "houseNormal.jpg";
            string specularMapPath = ProjectFolders.SpecularMapsPath + "brick_sm.png";

            StaticEntityArguments staticMeshArg = new StaticEntityArguments(modelPath, texturePath, normalMapPath, specularMapPath,
                                                                            new Vector3(170, 13f + EngineStatics.MAP_HEIGHT, 170), new Vector3(0, 180, 0), new Vector3(20));
            var house1 = EngineObjectCreator.CreateInstance <Building>(staticMeshArg);

            level.StaticMeshCollection.AddToList(house1);

            DeserializeWrapper deserializer = new DeserializeWrapper();

            foreach (var item in level.StaticMeshCollection)
            {
                var inner_wrapper = deserializer.Deserialize <CollisionComponentsWrapper>("house.cl");
                item.SetComponents(inner_wrapper.SerializedComponents);
                item.SetCollisionHeadUnit(CollisionHeadUnitObject);

                item.SetMistComponent(level.Mist);
            }

            modelPath       = ProjectFolders.ModelsPath + "playerCube.obj";
            texturePath     = ProjectFolders.MultitexturesPath + "path.png";
            normalMapPath   = ProjectFolders.NormalMapsPath + "brick_nm_high.png";
            specularMapPath = ProjectFolders.SpecularMapsPath + "brick_sm.png";

            MovableEntityArguments movableMeshArg = new MovableEntityArguments(modelPath, texturePath, normalMapPath, specularMapPath, new Vector3(175, 1200, 170), new Vector3(0, 0, 0), new Vector3(4f));

            modelPath   = ProjectFolders.ModelsPath + "model.dae";
            texturePath = ProjectFolders.MultitexturesPath + "diffuse.png";

            level.SkeletalMesh = new MovableSkeletalMeshEntity(modelPath, texturePath, normalMapPath, specularMapPath, 0.5f, new Vector3(175, 60, 170), new Vector3(-90, 0, 0), new Vector3(1));

            level.Player.AddToWrapper(EngineObjectCreator.CreateInstance <MovableMeshEntity>(movableMeshArg));
            level.Player.GetData().SetMistComponent(level.Mist);

            var wrapper = deserializer.Deserialize <CollisionComponentsWrapper>("2.cl");

            level.Player.GetData().SetComponents(wrapper.SerializedComponents);

            level.Player.GetData().SetCollisionHeadUnit(CollisionHeadUnitObject);
            level.Player.GetData().Speed = 0.6f;

            modelPath   = ProjectFolders.ModelsPath + "playerCube.obj";
            texturePath = ProjectFolders.MultitexturesPath + "b.png";

            movableMeshArg = new MovableEntityArguments(modelPath, texturePath, normalMapPath, specularMapPath, new Vector3(180, 200, 220), new Vector3(0, 0, 0), new Vector3(10));

            var bot = EngineObjectCreator.CreateInstance <MovableMeshEntity>(movableMeshArg);

            bot.SetMistComponent(level.Mist);

            wrapper = deserializer.Deserialize <CollisionComponentsWrapper>("2.cl");
            bot.SetComponents(wrapper.SerializedComponents);
            bot.SetCollisionHeadUnit(CollisionHeadUnitObject);
            level.Bots.AddToList(bot);
            movableMeshArg = null;

            level.Skybox = new SkyboxEntity(
                new string[] { ProjectFolders.SkyboxTexturesPath + "/Day/" + "right.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "left.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "top.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "bottom.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "back.bmp",
                               ProjectFolders.SkyboxTexturesPath + "/Day/" + "front.bmp" },
                new string[] { ProjectFolders.SkyboxTexturesPath + "/Night/" + "right.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "left.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "top.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "bottom.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "back.png",
                               ProjectFolders.SkyboxTexturesPath + "/Night/" + "front.png" });
            level.Skybox.setMistComponent(level.Mist);

            level.Water.AddToWrapper(new WaterPlane(ProjectFolders.WaterTexturePath + "DUDV.png", ProjectFolders.WaterTexturePath + "normal.png",
                                                    new Vector3(160, 29, 200), new Vector3(0, 0, 0), new Vector3(200, 1, 200), new WaterQuality(true, true, true), 10));

            level.SunRenderer.AddToWrapper(new SunRenderer(level.DirectionalLight, ProjectFolders.SunTexturePath + "sunC.png",
                                                           ProjectFolders.SunTexturePath + "sunB.png", 150, 130));

            // Set third person target
            ThirdPersonCamera thirdPersonCamera = (level.Camera as ThirdPersonCamera);

            thirdPersonCamera?.SetThirdPersonTarget(level.Player.GetData());

            //ch = new ComputeShader();
            //ch.Init();
        }