Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            WaitFunction function = (WaitFunction)target;

            EditorGUILayout.PropertyField(serializedObject.FindProperty("waitType"), GUIContent.none);
            float min   = EditorGUILayout.FloatField("Minutes", function.waitTime.minutes);
            int   hour  = EditorGUILayout.IntField("Hours", function.waitTime.hours);
            int   day   = 0;
            int   week  = 0;
            int   month = 0;

            if (function.waitType == WaitType.RELATION || function.waitType == WaitType.ABSOLUTE)
            {
                day   = EditorGUILayout.IntField("Days", function.waitTime.days);
                week  = EditorGUILayout.IntField("Weeks", function.waitTime.weeks);
                month = EditorGUILayout.IntField("Months", function.waitTime.months);
            }
            GameTime gameTime = new GameTime
            {
                minutes = min,
                hours   = hour,
                days    = day,
                weeks   = week,
                months  = month
            };

            function.waitTime = GameTime.Convert(gameTime);
            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }