예제 #1
0
 public GameplayStage(PopupManager <PopupType> popupManager, EventAggregator eventAggregator, TimeTicker timeTicker, IconLoader iconLoader)
 {
     _popupManager    = popupManager;
     _eventAggregator = eventAggregator;
     _timeTicker      = timeTicker;
     _iconLoader      = iconLoader;
 }
예제 #2
0
    static int set_OnEnd(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TimeTicker obj = (TimeTicker)o;
            System.Action <TimeTicker> arg0 = null;
            LuaTypes funcType2 = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg0 = (System.Action <TimeTicker>)ToLua.CheckObject(L, 2, typeof(System.Action <TimeTicker>));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                arg0 = DelegateFactory.CreateDelegate(typeof(System.Action <TimeTicker>), func) as System.Action <TimeTicker>;
            }

            obj.OnEnd = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OnEnd on a nil value" : e.Message));
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        // Transitive state
        switch (currentStep)
        {
        case 2:
            gameStartWaitTimer        = new TimeTicker(2).Start();                                               // start timer
            Mask.transform.localScale = new Vector3(0.5f, 0.5f, 1);                                              // init mask size
            StartCoroutine(SoundManager.GetInstance().StartUpVoices[0].PlayWithDelay(0.7f, 1.5f));               // voice #1 after 0.7 secs
            StartCoroutine(SoundManager.GetInstance().StartUpVoices[Random.Range(1, 4)].PlayWithDelay(2, 1.5f)); // voice #2 after 2 secs
            currentStep++;
            return;                                                                                              // do not proceed

        case 3:
            Mask.transform.localScale *= (1 + Time.deltaTime * 5);     // scale up the mask
            if (gameStartWaitTimer.IsTimeout())
            {
                StartGame();
            }
            return;     // do not proceed
        }

        // Interactive state
        var  input        = GetInput();
        bool valueChanged = false;

        switch (currentStep)
        {
        case 0:
            int newFaction = Mathf.Clamp(Faction - input, 0, 1);
            valueChanged = Faction != newFaction;
            Faction      = newFaction;
            break;

        case 1:
            int newLevel = Mathf.Clamp(Level - input, 0, 2);
            valueChanged = Level != newLevel;
            Level        = newLevel;
            break;
        }

        if (valueChanged)
        {
            SoundManager.GetInstance().MenuMoveSound.Play();
        }

        UpdateArrow();

        if (InputUtil.GetButtonDown(0))
        {
            SoundManager.GetInstance().MenuSelectSound.Play();
            currentStep++;
        }

        if (InputUtil.GetButtonDown(1) && currentStep > 0)
        {
            currentStep--;
        }
    }
예제 #4
0
 // Update is called once per frame
 void Update()
 {
     if (flashTimer != null && flashTimer.IsTimeout())
     {
         TextComponent.color = NormalColor;
         flashTimer          = null;
     }
 }
예제 #5
0
        ////////////////

        public TimerHUD(
            Vector2 pos,
            Vector2 dim,
            string title,
            long startTimeTicks,
            bool showTicks,
            Func <bool> enabler,
            TimeTicker ticker)
            : base("Timer_" + title, pos, dim, enabler)
        {
            this.BasicConstructor(title, startTimeTicks, showTicks, ticker);
        }
예제 #6
0
        public static void ActivityThreads2(object sender, EventArgs args)
        {
            DateTime dt = Methods.Start.AddDays(Methods.days).AddHours(9).AddMinutes(49);

            if (Methods.Clock >= dt)
            {
                Thread t3 = new Thread(new ThreadStart(Methods.EndRaport));
                t3.Start();

                TimeTicker.EndTimer();
            }
        }
예제 #7
0
 /// <summary>
 /// 添加帧计时事件
 /// </summary>
 /// <param name="kv"></param>
 /// <param name="param"></param>
 /// <param name="action"></param>
 public void AddFrameActions(Dictionary <uint, uint> kv, object param, Action <uint, object> action)
 {
     foreach (var de in kv)
     {
         var ticker = new TimeTicker();
         ticker.typeId     = de.Key;
         ticker.frameCount = de.Value;
         ticker.refCount   = 0;
         ticker.action     = action;
         ticker.param      = param;
         timeTickers.Add(ticker);
     }
 }
예제 #8
0
    // Use this for initialization
    void Start()
    {
        KeySprite              = transform.Find("Key").gameObject;
        PortalSprite           = transform.Find("Portal").gameObject;
        UncapturedPortalSprite = transform.Find("UncapturedPortal").gameObject;
        coolDownTimer          = new TimeTicker(CoolDown);

        transform.position = transform.position.Set2D(Model.Position);

        SetHasKey(false);
        UpdateSprite();
        ResetEnergy();
    }
예제 #9
0
 static int Stop(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         TimeTicker obj = (TimeTicker)ToLua.CheckObject(L, 1, typeof(TimeTicker));
         obj.Stop();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #10
0
 static int Pause(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         TimeTicker obj  = (TimeTicker)ToLua.CheckObject(L, 1, typeof(TimeTicker));
         bool       arg0 = LuaDLL.luaL_checkboolean(L, 2);
         obj.Pause(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #11
0
 static int StartReverse(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         TimeTicker obj  = (TimeTicker)ToLua.CheckObject(L, 1, typeof(TimeTicker));
         float      arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
         obj.StartReverse(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #12
0
 static int IsPause(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         TimeTicker obj = (TimeTicker)ToLua.CheckObject(L, 1, typeof(TimeTicker));
         bool       o   = obj.IsPause();
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #13
0
        ////

        private void BasicConstructor(
            string title,
            long startTimeTicks,
            bool showTicks,
            TimeTicker ticker)
        {
            this.TitleText    = title;
            this.CurrentTicks = startTimeTicks;
            this.ShowTicks    = showTicks;
            this.Ticker       = ticker;

            this.PerTickAction = () => {
                this.CurrentTicks = this.Ticker.Invoke(this.CurrentTicks, out _);
            };
        }
예제 #14
0
    static int get_OverTime(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TimeTicker obj = (TimeTicker)o;
            float      ret = obj.OverTime;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OverTime on a nil value" : e.Message));
        }
    }
예제 #15
0
    static int get_OnEnd(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TimeTicker obj = (TimeTicker)o;
            System.Action <TimeTicker> ret = obj.OnEnd;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OnEnd on a nil value" : e.Message));
        }
    }
예제 #16
0
    static int get_IsReverse(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TimeTicker obj = (TimeTicker)o;
            bool       ret = obj.IsReverse;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index IsReverse on a nil value" : e.Message));
        }
    }
예제 #17
0
        static void Main(string[] args)
        {
            Methods.IsHamsterEmty();
            Methods.FillCages();

            Console.WriteLine("How many miliseconds do you want one tick to be?");
            int seconds = int.Parse(Console.ReadLine());

            Console.WriteLine("How many days do you want the simulation to last?");
            int days = int.Parse(Console.ReadLine());

            Methods.days = days - 1;



            TimeTicker.Activities += (sender, e) => ActivityThreads(sender, e);
            TimeTicker.Activities += (sender, e) => ActivityThreads2(sender, e);
            TimeTicker.StartTimer(seconds);
        }
예제 #18
0
    static int _CreateTimeTicker(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                TimeTicker obj = new TimeTicker();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: TimeTicker.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #19
0
        ////////////////

        public static (string, Color) RenderTimer(long ticks, bool showTicks, TimeTicker ticker)
        {
            long absTicks   = Math.Abs(ticks);
            long absSeconds = absTicks / 60L;
            long absMinutes = absSeconds / 60L;
            long absHours   = absMinutes / 60L;

            string output = ticks < 0L
                                ? "-"
                                : "";

            if (absHours > 0L)
            {
                output += absHours;

                output += ":";
            }

            long absMinutesPer = absMinutes % 60L;

            if (absMinutesPer < 10L)
            {
                output += "0" + absMinutesPer;
            }
            else
            {
                output += absMinutesPer;
            }

            output += ":";

            long absSecondsPer = absSeconds % 60L;

            if (absSecondsPer < 10L)
            {
                output += "0" + absSecondsPer;
            }
            else
            {
                output += absSecondsPer;
            }

            if (showTicks)
            {
                output += ":";

                long absTicksPer = absTicks % 60L;
                if (absTicksPer < 10L)
                {
                    output += "0" + absTicksPer;
                }
                else
                {
                    output += absTicksPer;
                }
            }

            //

            Color color;
            long  newTicks = ticker.Invoke(ticks, out _);

            long tickDiff = ticks - newTicks;

            ticker.Invoke(ticks + tickDiff, out color);

            return(output, color);
        }
예제 #20
0
 private void Awake()
 {
     Instance = this;
 }