示例#1
0
        public void CreateWaitAction(iLogicMapContainer owner, UnityAction trueAction, UnityAction falseAction)
        {
            Timeline   timeline = Timeline.GetInstantiate();
            GameObject goAction = new GameObject(string.Format("TimelineAction_WaitChallenge"));

            goAction.transform.parent = timeline.transform;
            TimelineAction waitAction = goAction.AddComponent <TimelineAction>();

            waitAction.actionType = TimelineActionType.WAIT;
            waitAction.action     = delegate
            {
                bool result = Realize(owner);
                if (result)
                {
                    trueAction();
                }
                else
                {
                    falseAction();
                }
            };
            if (waitType == WaitType.ABSOLUTE)
            {
                waitAction.timer = GameTime.ConvertToFloat(waitTime);
            }
            else if (waitType == WaitType.RELATION)
            {
                waitAction.timer = timeline.GetTime() + GameTime.ConvertToFloat(waitTime);
            }
            else if (waitType == WaitType.ABSOLUTE_HOURS)
            {
                GameTime curTime = GameTime.Convert(timeline.GetTime());
                if (curTime.GetDayHour() <= waitTime)
                {
                    GameTime resultTime = new GameTime()
                    {
                        minutes = waitTime.minutes,
                        hours   = waitTime.hours,
                        days    = curTime.days,
                        weeks   = curTime.weeks,
                        months  = curTime.months
                    };
                    waitAction.timer = GameTime.ConvertToFloat(resultTime);
                }
                else if (curTime.GetDayHour() > waitTime)
                {
                    GameTime resultTime = new GameTime()
                    {
                        minutes = waitTime.minutes,
                        hours   = waitTime.hours,
                        days    = curTime.days + 1,
                        weeks   = curTime.weeks,
                        months  = curTime.months
                    };
                    waitAction.timer = GameTime.ConvertToFloat(resultTime);
                }
            }
            timeline.RegistrateAction(waitAction);
            Debug.Log(string.Format("ждать челендж {0}", waitTime.ToString()), this);
        }
示例#2
0
        public void CreateWaitAction(UnityAction action)
        {
            Timeline   timeline = Timeline.GetInstantiate();
            GameObject goAction = new GameObject(string.Format("TimelineAction_Wait"));

            goAction.transform.parent = timeline.transform;
            TimelineAction waitAction = goAction.AddComponent <TimelineAction>();

            waitAction.actionType = TimelineActionType.WAIT;
            waitAction.action     = delegate
            {
                realize = true;
                action();
            };
            if (waitType == WaitType.ABSOLUTE)
            {
                waitAction.timer = GameTime.ConvertToFloat(waitTime);
            }
            else if (waitType == WaitType.RELATION)
            {
                waitAction.timer = timeline.GetTime() + GameTime.ConvertToFloat(waitTime);
            }
            else if (waitType == WaitType.ABSOLUTE_HOURS)
            {
                GameTime curTime = GameTime.Convert(timeline.GetTime());
                if (curTime.GetDayHour() <= waitTime)
                {
                    GameTime resultTime = new GameTime()
                    {
                        minutes = waitTime.minutes,
                        hours   = waitTime.hours,
                        days    = curTime.days,
                        weeks   = curTime.weeks,
                        months  = curTime.months
                    };
                    waitAction.timer = GameTime.ConvertToFloat(resultTime);
                }
                else if (curTime.GetDayHour() > waitTime)
                {
                    GameTime resultTime = new GameTime()
                    {
                        minutes = waitTime.minutes,
                        hours   = waitTime.hours,
                        days    = curTime.days + 1,
                        weeks   = curTime.weeks,
                        months  = curTime.months
                    };
                    waitAction.timer = GameTime.ConvertToFloat(resultTime);
                }
            }
            timeline.RegistrateAction(waitAction);
            Debug.Log(string.Format("wait {0}", waitTime), this);
        }