Exemple #1
0
    /// <summary>
    /// 获取当前日期之后几天的日期
    /// </summary>
    /// <param name="afterDay"></param>
    /// <returns></returns>
    public TimeBean GetAfterDay(int afterDay)
    {
        GameDataBean gameData  = GameDataHandler.Instance.manager.GetGameData();
        TimeBean     timeData  = gameData.gameTime;
        int          tempYear  = timeData.year;
        int          tempMonth = timeData.month;
        int          tempDay   = timeData.day;

        for (int i = 0; i < afterDay; i++)
        {
            tempDay += 1;
            if (tempDay > maxForDay)
            {
                tempDay    = 1;
                tempMonth += 1;
            }
            if (tempMonth > 4)
            {
                tempMonth = 1;
                tempYear += 1;
            }
        }
        TimeBean tempTimeData = new TimeBean();

        tempTimeData.SetTimeForYMD(tempYear, tempMonth, tempDay);
        return(tempTimeData);
    }
 /// <summary>
 /// 开始游戏时间
 /// </summary>
 public void startTimer(TimeBean timeBean)
 {
     if (gameTimerControlCpt != null)
     {
         gameTimerControlCpt.startTimer(timeBean);
     }
 }
    /// <summary>
    /// 获取玩家游玩时间
    /// </summary>
    /// <returns></returns>
    public TimeBean GetPlayTime()
    {
        UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
        TimeBean     timeData = userData.timeForPlay;

        return(timeData);
    }
Exemple #4
0
    public override void Start()
    {
        base.Start();

        GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();
        //初始化场景

        SceneInnManager sceneInnManager = GameScenesHandler.Instance.manager.GetSceneManager <SceneInnManager>();
        InnBuildBean    innBuildData    = gameData.GetInnBuildData();

        sceneInnManager.InitScene(innBuildData.innWidth, innBuildData.innHeight);

        //innBuildData.ChangeInnSize(2, innBuildManager, 9, 9);


        //构建地板
        InnBuildHandler.Instance.builderForFloor.StartBuild();
        //构建墙壁
        InnBuildHandler.Instance.builderForWall.StartBuild();
        //构建建筑
        InnBuildHandler.Instance.builderForFurniture.StartBuild();

        //初始化客栈处理
        InnHandler.Instance.InitInn();
        InnHandler.Instance.InitRecord();
        //其他场景切过来需要重置一下客栈数据
        InnHandler.Instance.CloseInn();
        //设置天气
        GameWeatherHandler.Instance.SetWeather(GameCommonInfo.CurrentDayData.weatherToday);
        //打开UI
        UIHandler.Instance.manager.OpenUI <UIGameMain>(UIEnum.GameMain);

        //增加回调
        GameTimeHandler.Instance.RegisterNotifyForTime(NotifyForTime);
        TimeBean timeData = gameData.gameTime;

        if (timeData.hour >= 24 ||
            timeData.hour < 6 ||
            GameTimeHandler.Instance.GetDayStatus() == GameTimeHandler.DayEnum.End)
        {
            //如果是需要切换第二天
            EndDay();
        }
        else
        {
            //如果是其他场景切换过来
            GameTimeHandler.Instance.SetTime(timeData.hour, timeData.minute);
            GameTimeHandler.Instance.SetTimeStatus(false);
            //建造NPC
            RefreshScene();
            //设置位置
            Vector3           startPosition = sceneInnManager.GetTownEntranceLeft();
            ControlForMoveCpt baseControl   = GameControlHandler.Instance.StartControl <ControlForMoveCpt>(GameControlHandler.ControlEnum.Normal);
            baseControl.SetFollowPosition(startPosition);
        }
        //改变四季
        GameSeasonsHandler.Instance.ChangeSeasons();

        StartCoroutine(BuildNavMesh());
    }
Exemple #5
0
        private void SetupTimeBean(TimeBean timeBean, double number)
        {
            if (stockMarketToolStripMenuItem.Checked)
            {
                timeBean.SetStockMarket();
            }
            else
            {
                timeBean.SetForexMarket();
            }

            if (rBtnYear.Checked)
            {
                timeBean.years = number;
            }
            if (rBtnMonth.Checked)
            {
                timeBean.months = number;
            }
            if (rBtnWeek.Checked)
            {
                timeBean.weeks = number;
            }
            if (rBtnCDays.Checked)
            {
                timeBean.calendarDays = number;
            }
            if (rBtnTDays.Checked)
            {
                timeBean.tradingDays = number;
            }
        }
Exemple #6
0
        private void DisplayResultsHMS(TimeBean timeBean)
        {
            string Format = (radioButtonFull.Checked) ? "{0:0.00}" : "{0:0}";
            double cells, degrees;

            cells            = GetUpToNDigits(timeBean.years); degrees = GetUpToNDigits(timeBean.years * 360);
            lblHMSyears.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells             = GetUpToNDigits(timeBean.months); degrees = GetUpToNDigits(timeBean.months * 360);
            lblHMSmonths.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells            = GetUpToNDigits(timeBean.weeks); degrees = GetUpToNDigits(timeBean.weeks * 360);
            lblHMSweeks.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells           = GetUpToNDigits(timeBean.calendarDays); degrees = GetUpToNDigits(timeBean.calendarDays * 360);
            lblHMSdays.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells            = GetUpToNDigits(timeBean.calendarHours); degrees = GetUpToNDigits(timeBean.calendarHours * 360);
            lblHMShours.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells = GetUpToNDigits(timeBean.calendarMinutes); degrees = GetUpToNDigits(timeBean.calendarMinutes * 360);
            lblHMSminutes.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells = GetUpToNDigits(timeBean.calendarSeconds); degrees = GetUpToNDigits(timeBean.calendarSeconds * 360);
            lblHMSseconds.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";
        }
Exemple #7
0
 /// <summary>
 /// 设置结婚日期
 /// </summary>
 /// <param name="time"></param>
 public void SetMarryDate(TimeBean time)
 {
     if (ui_TVMarryDate && time != null)
     {
         ui_TVMarryDate.text = string.Format(TextHandler.Instance.manager.GetTextById(78), time.year + "", time.month + "", time.day + "");
     }
 }
Exemple #8
0
    public static TimeBean GetNowTime()
    {
        DateTime dateTime = DateTime.Now;
        TimeBean timeData = new TimeBean(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);

        return(timeData);
    }
Exemple #9
0
    /// <summary>
    /// 设置时间
    /// </summary>
    /// <param name="hour"></param>
    /// <param name="minute"></param>
    public void SetGameTime(int hour, int minute)
    {
        TimeBean timeData = manager.GetGameTime();

        timeData.hour   = hour;
        timeData.minute = minute;
    }
Exemple #10
0
    //---------------------------------------------------------------------------------------------
    /// <summary>
    /// 开始游戏
    /// </summary>
    public void gameStart()
    {
        //判断是否有存档
        PuzzlesProgressBean paramsData = new PuzzlesProgressBean();

        paramsData.puzzleId     = CommonData.SelectPuzzlesInfo.puzzlesInfo.id;
        paramsData.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name;
        PuzzlesProgressBean progressData = DataStorageManage.getPuzzlesProgressDSHandle().getData(paramsData);

        TimeBean gameTime = null;

        if (progressData != null)
        {
            gameTime = progressData.gameTime;
            GameUtil.setGameProgress(this, progressData);
        }
        else
        {
        }
        CommonData.IsCheating = false;
        CommonData.GameStatus = 1;
        CommonData.IsDargMove = true;
        Camera.main.gameObject.AddComponent <SecretCodeCpt>();
        GameMainUIControl gameMainUI = uiMasterControl.getUIByType <GameMainUIControl>(UIEnum.GameMainUI);

        if (gameMainUI != null)
        {
            gameMainUI.startTimer(gameTime);
        }
    }
Exemple #11
0
 /// <summary>
 /// 检测是否是结婚日
 /// </summary>
 /// <param name="time"></param>
 /// <returns></returns>
 public bool CheckIsMarryDay(TimeBean time)
 {
     if (time.year == timeForMarry.year && time.month == timeForMarry.month && time.day == timeForMarry.day)
     {
         return(true);
     }
     return(false);
 }
Exemple #12
0
    //比较时间------------------------------------------------------------------------------------------------------------
    public static TimeSpan SubtractTime(TimeBean timeOne, TimeBean timeTwo)
    {
        DateTime dateOne  = timeOne.ToDateTime();
        DateTime dateTwo  = timeTwo.ToDateTime();
        TimeSpan timeSpan = dateOne.Subtract(dateTwo);

        return(timeSpan);
    }
Exemple #13
0
    //比较时间------------------------------------------------------------------------------------------------------------
    public static TimeSpan SubtractTime(TimeBean timeOne, TimeBean timeTwo)
    {
        DateTime dateOne  = TypeConversionUtil.TimeBeanToDateTime(timeOne);
        DateTime dateTwo  = TypeConversionUtil.TimeBeanToDateTime(timeTwo);
        TimeSpan timeSpan = dateOne.Subtract(dateTwo);

        return(timeSpan);
    }
Exemple #14
0
 public void Update()
 {
     if (GameHandler.Instance.manager.GetGameState() == GameStateEnum.Gaming)
     {
         TimeBean gameTime = GameTimeHandler.Instance.manager.GetGameTime();
         HandleForSky(gameTime);
         HandleForStar(gameTime);
     }
 }
Exemple #15
0
    /// <summary>
    /// 获取日期
    /// </summary>
    /// <param name="year"></param>
    /// <param name="month"></param>
    /// <param name="day"></param>
    public void GetTime(out int year, out int month, out int day)
    {
        GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();
        TimeBean     timeData = gameData.gameTime;

        year  = timeData.year;
        month = timeData.month;
        day   = timeData.day;
    }
 /// <summary>
 /// 获取主界面时间
 /// </summary>
 /// <returns></returns>
 public TimeBean GetMainTime()
 {
     if (timeForMain == null)
     {
         timeForMain = new TimeBean();
         timeForMain.SetTimeForHM(WorldRandTools.Range(0, 24), 0);
     }
     return(timeForMain);
 }
Exemple #17
0
    /// <summary>
    /// 检测是否长大
    /// </summary>
    /// <returns></returns>
    public bool CheckIsGrowUp(TimeBean currentTime)
    {
        int days = (currentTime.year - birthTime.year) * 42 * 4 + (currentTime.month - birthTime.month) * 42 + (currentTime.day - birthTime.day);

        if (days >= 504 || bornDays >= 504)
        {
            return(true);
        }
        return(false);
    }
Exemple #18
0
    /// <summary>
    /// 处理-天空
    /// </summary>
    public void HandleForSky(TimeBean gameTime)
    {
        float totalTime   = 24f * 60f;
        float currentTime = gameTime.hour * 60 + gameTime.minute;

        timeForSkyAngle = (currentTime / totalTime * 360) + 180;

        Quaternion rotate = Quaternion.AngleAxis(timeForSkyAngle, new Vector3(1, 0, 1));

        manager.sky.transform.rotation = Quaternion.Lerp(manager.sky.transform.rotation, rotate, Time.deltaTime);
    }
Exemple #19
0
 /// <summary>
 /// 处理-星星
 /// </summary>
 /// <param name="gameTime"></param>
 public void HandleForStar(TimeBean gameTime)
 {
     if (gameTime.hour >= 6 && gameTime.hour <= 18)
     {
         manager.star.ShowStar(false);
     }
     else
     {
         manager.star.ShowStar(true);
     }
 }
Exemple #20
0
    /// <summary>
    /// 处理-光照位置旋转
    /// </summary>
    /// <param name="gameTime"></param>
    public void HandleForLightTransform(TimeBean gameTime)
    {
        float lightAlpha = (float)(gameTime.hour * 60f + gameTime.minute) / (24f * 60f);

        float      sunRotation    = Mathf.Lerp(-90, 270, lightAlpha);
        float      moonRotation   = sunRotation - 180;
        Quaternion sunQuaternion  = Quaternion.Euler(sunRotation, -45, 0);
        Quaternion moonQuaternion = Quaternion.Euler(moonRotation, -45, 0);

        manager.sunLight.transform.rotation  = Quaternion.Lerp(manager.sunLight.transform.rotation, sunQuaternion, Time.deltaTime);
        manager.moonLight.transform.rotation = Quaternion.Lerp(manager.moonLight.transform.rotation, moonQuaternion, Time.deltaTime);
    }
Exemple #21
0
    /// <summary>
    /// 处理-游玩时间
    /// </summary>
    public void HandleForPlayTime()
    {
        GameStateEnum gameState = GameHandler.Instance.manager.GetGameState();

        if (gameState != GameStateEnum.Gaming)
        {
            return;
        }
        TimeBean timeData = manager.GetPlayTime();

        timeData.AddTimeForHMS(0, 0, 1);
    }
Exemple #22
0
 /// <summary>
 /// 处理-白天黑夜转换
 /// </summary>
 /// <param name="gameTime"></param>
 public void HnaldeForDayNightTransition(TimeBean gameTime)
 {
     if (gameTime.hour >= 6 && gameTime.hour <= 18)
     {
         manager.sunLight.shadows  = LightShadows.Soft;
         manager.moonLight.shadows = LightShadows.None;
     }
     else
     {
         manager.sunLight.shadows  = LightShadows.None;
         manager.moonLight.shadows = LightShadows.Soft;
     }
 }
    /// <summary>
    /// 获取时间
    /// </summary>
    public TimeBean getGameTimer()
    {
        if (nowTimeSpan == null)
        {
            return(null);
        }
        TimeBean timeBean = new TimeBean();

        timeBean.days         = nowTimeSpan.Days;
        timeBean.hours        = nowTimeSpan.Hours;
        timeBean.minutes      = nowTimeSpan.Minutes;
        timeBean.seconds      = nowTimeSpan.Seconds;
        timeBean.totalSeconds = (int)nowTimeSpan.TotalSeconds;
        return(timeBean);
    }
Exemple #24
0
    public override void Start()
    {
        base.Start();
        //设置时间
        GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();
        TimeBean     timeData = gameData.gameTime;

        GameTimeHandler.Instance.SetTime(timeData.hour, timeData.minute);
        GameTimeHandler.Instance.SetTimeStatus(false);
        //增加回调
        GameTimeHandler.Instance.RegisterNotifyForTime(NotifyForTime);

        //设置角色位置
        InitUserPosition();
        //设置天气
        InitWeather();
    }
Exemple #25
0
 private void CalculateHMS()
 {
     try
     {
         long number = Convert.ToInt64(tHMSnumber.Text);
         if (number > 0)
         {
             TimeBean timeBean = new TimeBean();
             SetupTimeBeanHMS(timeBean, number);
             timeConverter.MakeConversion(timeBean);
             DisplayResultsHMS(timeBean);
         }
     } catch (Exception e)
     {
         throw e;
     }
 }
Exemple #26
0
 private void Calculate()
 {
     try
     {
         double number = Convert.ToDouble(txtBoxInput.Text);
         if (number > 0)
         {
             TimeBean timeBean = new TimeBean();
             SetupTimeBean(timeBean, number);
             timeConverter.MakeConversion(timeBean);
             DisplayResults(timeBean);
         }
     } catch (Exception e)
     {
         throw e;
     }
 }
Exemple #27
0
    /// <summary>
    /// 获取出现详情-时间
    /// </summary>
    /// <param name="gameData"></param>
    /// <param name="conditionData"></param>
    /// <returns></returns>
    protected static ShowConditionBean GetConditionDetailsForTime(GameDataBean gameData, ShowConditionBean conditionData)
    {
        List <int> listTime = StringUtil.SplitBySubstringForArrayInt(conditionData.data, ',').ToList();
        TimeBean   gameTime = gameData.gameTime;

        switch (conditionData.dataType)
        {
        case ShowConditionEnum.TimeForYear:
            if (listTime.Contains(gameTime.year))
            {
                conditionData.isCondition = true;
            }
            break;

        case ShowConditionEnum.TimeForYearAfter:
            int year = listTime[0];
            if (gameTime.year >= year)
            {
                conditionData.isCondition = true;
            }
            break;

        case ShowConditionEnum.TimeForMonth:
            if (listTime.Contains(gameTime.month))
            {
                conditionData.isCondition = true;
            }
            break;

        case ShowConditionEnum.TimeForDay:
            if (listTime.Contains(gameTime.day))
            {
                conditionData.isCondition = true;
            }
            break;

        case ShowConditionEnum.TimeForHour:
            if (listTime.Contains(gameTime.hour))
            {
                conditionData.isCondition = true;
            }
            break;
        }
        return(conditionData);
    }
Exemple #28
0
    /// <summary>
    /// 比较哪个时间更快更短
    /// </summary>
    /// <param name="sourceTime"></param>
    /// <param name="targetTime"></param>
    /// <returns></returns>
    public static bool isFasterTime(TimeBean sourceTime, TimeBean targetTime)
    {
        if (sourceTime == null || targetTime == null)
        {
            return(false);
        }

        int sourceTimeCode = sourceTime.days * 1000 + sourceTime.hours * 100 + sourceTime.minutes * 10 + sourceTime.seconds;
        int targetTimeCode = targetTime.days * 1000 + targetTime.hours * 100 + targetTime.minutes * 10 + targetTime.seconds;

        if (sourceTimeCode > targetTimeCode)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #29
0
        private void DisplayResults(TimeBean timeBean)
        {
            string Format = (radioButtonFull.Checked) ? "{0:0.00}" : "{0:0}";
            double cells, degrees;

            // Years & Months & Weeks
            cells         = GetUpToNDigits(timeBean.years); degrees = GetUpToNDigits(timeBean.years * 360);
            lblYears.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells          = GetUpToNDigits(timeBean.months); degrees = GetUpToNDigits(timeBean.months * 360);
            lblMonths.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells         = GetUpToNDigits(timeBean.weeks); degrees = GetUpToNDigits(timeBean.weeks * 360);
            lblWeeks.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            // Calendar Days & Hours & Minutes & Seconds
            cells         = GetUpToNDigits(timeBean.calendarDays); degrees = GetUpToNDigits(timeBean.calendarDays * 360);
            lblCDays.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells         = GetUpToNDigits(timeBean.calendarHours); degrees = GetUpToNDigits(timeBean.calendarHours * 360);
            lblHours.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells           = GetUpToNDigits(timeBean.calendarMinutes); degrees = GetUpToNDigits(timeBean.calendarMinutes * 360);
            lblMinutes.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells           = GetUpToNDigits(timeBean.calendarSeconds); degrees = GetUpToNDigits(timeBean.calendarSeconds * 360);
            lblSeconds.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            // Trading Days & Hours & Minutes & Seconds
            cells         = GetUpToNDigits(timeBean.tradingDays); degrees = GetUpToNDigits(timeBean.tradingDays * 360);
            lblTDays.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells          = GetUpToNDigits(timeBean.tradingHours); degrees = GetUpToNDigits(timeBean.tradingHours * 360);
            lblTHours.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells            = GetUpToNDigits(timeBean.tradingMinutes); degrees = GetUpToNDigits(timeBean.tradingMinutes * 360);
            lblTMinutes.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";

            cells            = GetUpToNDigits(timeBean.tradingSeconds); degrees = GetUpToNDigits(timeBean.tradingSeconds * 360);
            lblTSeconds.Text = String.Format(Format, cells) + " [" + String.Format(Format, degrees) + "]";
        }
Exemple #30
0
    /// <summary>
    /// 进行下一天
    /// </summary>
    public void GoToNextDay(int nextDay)
    {
        GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();
        TimeBean     timeData = gameData.gameTime;

        for (int i = 0; i < nextDay; i++)
        {
            timeData.day += 1;
            if (timeData.day > maxForDay)
            {
                timeData.day    = 1;
                timeData.month += 1;
            }
            if (timeData.month > 4)
            {
                timeData.month = 1;
                timeData.year += 1;
            }
        }
        SetNewDay();
    }
        /// <summary>
        /// This method generates the WHERE part of the SQL query that will be used against the DDB for retrieving the available codes
        /// </summary>
        /// <param name="criteria">
        /// The list of criteria that will be used to generate the where clauses
        /// </param>
        /// <returns>
        /// A string containing the WHERE part of the SQL Query or an Empty string
        /// </returns>
        private string GenerateWhere(IEnumerable<MemberBean> criteria)
        {
            var sb = new StringBuilder();
            int lastClause = 0;
            TimeBean time;

            foreach (MemberBean member in criteria)
            {
                if (!string.IsNullOrEmpty(member.ComponentRef))
                {
                    if (member.ComponentRef.Equals(this._timeDimension))
                    {
                        // TODO FIXME not sure how time constrains will be included
                        time = new TimeBean();
                        if (member.MemberValue.Count > 0)
                        {
                            time.StartTime = member.MemberValue[0].Value;
                            if (member.MemberValue.Count > 1)
                            {
                                time.EndTime = member.MemberValue[1].Value;
                            }
                        }

                        sb.Append("(");
                        sb.Append(this._timeTranscoder.GenerateWhere(time));
                        sb.Append(")");
                        lastClause = sb.Length;
                        sb.Append(" AND ");
                    }
                    else
                    {
                        ComponentInfo compInfo;
                        if (this._componentMapping.TryGetValue(member.ComponentRef, out compInfo))
                        {
                            sb.Append("(");
                            foreach (MemberValueBean value in member.MemberValue)
                            {
                                sb.Append(compInfo.ComponentMapping.GenerateComponentWhere(value.Value));
                                lastClause = sb.Length;
                                sb.Append(" OR ");
                            }

                            sb.Length = lastClause;
                            sb.Append(")");
                            lastClause = sb.Length;
                            sb.Append(" AND ");
                        }
                    }
                }
            }

            if (this._referencePeriod != null)
            {
                // TODO FIXME not sure how time constrains will be included
                IFormatProvider fmt = CultureInfo.InvariantCulture;
                time = new TimeBean();
                time.StartTime = this._referencePeriod.StartTime.ToString("yyyy-MM-dd", fmt);
                time.EndTime = this._referencePeriod.EndTime.ToString("yyyy-MM-dd", fmt);
                sb.Append("(");
                sb.Append(this._timeTranscoder.GenerateWhere(time));
                sb.Append(")");
                lastClause = sb.Length;
            }

            sb.Length = lastClause;
            if (sb.Length > 0)
            {
                return " where " + sb;
            }

            return string.Empty;
        }