예제 #1
0
        public string GetFormattedStringBlock(TimeHolder time)
        {
            if (time is null)
            {
                throw new ArgumentNullException();
            }

            if (time.Hours < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            var sb = new StringBuilder();

            var firstLineMultiplier = time.Hours / 5;

            for (int i = 0; i < FirstLineLampsCount; i++)
            {
                sb.Append(_colorProvider.GetColor(i < firstLineMultiplier));
            }

            sb.AppendLine();

            var secondLineMultiplier = time.Hours % 5;

            for (int i = 0; i < SecondLineLampsCount; i++)
            {
                sb.Append(_colorProvider.GetColor(i < secondLineMultiplier));
            }

            sb.AppendLine();
            return(sb.ToString());
        }
예제 #2
0
 void Start()
 {
     rb2d               = FindObjectOfType <Rigidbody2D> ();
     checkpoint         = FindObjectOfType <Checkpointscript> ();
     levelcomplete.text = "";
     addtime            = FindObjectOfType <TimeHolder> ();
     anim.SetBool("Done", false);
 }
예제 #3
0
    // public int maxTime = 0;

    // private GameController() {
    //     stepCollection = new CookingStepCollection();
    // }

    // public static GameController GetInstance()
    // {
    //     return instance;
    // }

    private void Awake()   // 必须比别的脚本先调用
    {
        Screen.SetResolution(1600, 900, false);
        stepCollection = new CookingStepCollection();
        MenuHolder     = GameObject.FindWithTag("MenuHolder").GetComponent <MenuHolder>();
        timeHolder1    = GameObject.FindWithTag("TimeHolder1").GetComponent <TimeHolder>();
        timeHolder2    = GameObject.FindWithTag("TimeHolder2").GetComponent <TimeHolder>();
    }
예제 #4
0
 void Start()
 {
     rb2d               = FindObjectOfType <Rigidbody2D> ();
     checkpoint         = FindObjectOfType <Checkpointscript> ();
     deathcount         = PlayerPrefs.GetInt("Deaths35");
     levelcomplete.text = "";
     t = FindObjectOfType <TimeHolder> ();
     anim.SetBool("Done", false);
 }
예제 #5
0
        void CalcSmoothDeltaTime(TimeHolder time)
        {
            // If existing weight is zero, don't take existing value into account
            time.m_SmoothingWeight *= (1.0F - kNewDeltaTimeWeight);
            time.m_SmoothingWeight += kNewDeltaTimeWeight;
            // As confidence in smoothed value increases the divisor goes towards 1
            float normalized = kNewDeltaTimeWeight / time.m_SmoothingWeight;

            time.m_SmoothDeltaTime = Mathf.Lerp(time.m_SmoothDeltaTime, time.m_DeltaTime, normalized);
        }
    /// <summary>
    /// Initializes the primary structure and sub-components.
    /// </summary>
    public void Initialize()
    {
        Time     = new TimeHolder();
        Graphics = new GraphicsHolder();
        Settings = new SettingHolder();
        Input    = new InputHolder();

        Input.Initialize(this);
        Time.Initialize();
        Graphics.Initialize(this);
    }
예제 #7
0
        public void GetFormatedString(int second)
        {
            var timeHolder = new TimeHolder()
            {
                Hours = 0, Minutes = 0, Seconds = second,
            };

            var formatter = new SecondFormatter(_yellowColorProvider);
            var result    = formatter.GetFormattedStringBlock(timeHolder);

            var trimmed = result.TrimEnd();

            Assert.AreEqual(1, trimmed.Length);
        }
예제 #8
0
        public string GetFormattedStringBlock(TimeHolder time)
        {
            if (time is null)
            {
                throw new ArgumentNullException(nameof(time));
            }

            if (time.Seconds < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            var isSecondPlaceholderEnabled = time.Seconds % 2 == 0;

            return($"{_colorProvider.GetColor(isSecondPlaceholderEnabled)}{Environment.NewLine}");
        }
예제 #9
0
        void SetTime(double time)
        {
            m_DynamicTime.m_LastFrameTime = m_DynamicTime.m_CurFrameTime;
            m_DynamicTime.m_CurFrameTime  = time;
            m_DynamicTime.m_DeltaTime     = (float)(m_DynamicTime.m_CurFrameTime - m_DynamicTime.m_LastFrameTime);

            m_DynamicTime.m_InvDeltaTime = CalcInvDeltaTime(m_DynamicTime.m_DeltaTime);
            CalcSmoothDeltaTime(m_DynamicTime);

            m_ActiveTime = m_DynamicTime;

            // Sync m_ZeroTime with timemanager time
            m_ZeroTime = GetTimeSinceStartup() - m_DynamicTime.m_CurFrameTime;
                #if DEBUG_TIME_MANAGER
            printf_console("time: set to %f, sync zero to %f\n", time, m_ZeroTime);
                #endif
        }
예제 #10
0
        public void GetFormatedString(int hours)
        {
            var timeHolder = new TimeHolder()
            {
                Hours   = hours,
                Minutes = 0,
                Seconds = 0,
            };

            var formatter = new HourFormatter(_redColorProvider);
            var result    = formatter.GetFormattedStringBlock(timeHolder);

            var lines = result.Split(new [] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            Assert.AreEqual(2, lines.Length);
            Assert.AreEqual(4, lines[0].Length);
            Assert.AreEqual(4, lines[1].Length);
        }
예제 #11
0
    void Start()
    {
        dragRect = GetComponent <RectTransform>();
        transform.SetSiblingIndex(1); // 把这个物体放在最上,防止按不到

        MenuHolder  = GameObject.FindWithTag("MenuHolder").GetComponent <MenuHolder>();
        timeHolder1 = GameObject.FindWithTag("TimeHolder1").GetComponent <TimeHolder>();
        timeHolder2 = GameObject.FindWithTag("TimeHolder2").GetComponent <TimeHolder>();

        menuRect    = MenuHolder.transform.parent.GetComponent <RectTransform>();
        timeRect1   = timeHolder1.GetComponent <RectTransform>();
        timeRect2   = timeHolder2.GetComponent <RectTransform>();
        cookingStep = GetComponent <CookingStep>();

        children = GetComponentsInChildren <Transform>();
        clock    = children.Where(x => x.name == "ClockImage").First();

        rt         = children.Where(x => x.name == "Image").First().GetComponent <RectTransform>();
        frameImage = children.Where(x => x.name == "FrameImage").First().GetComponent <RectTransform>();

        animationController = FindObjectOfType <AnimationController>();
        cookingSteps        = FindObjectOfType <GameController>().stepCollection;
    }
예제 #12
0
파일: Timer.cs 프로젝트: pedsm/White-Rabbit
 public void finishGame()
 {
     endTime = Time.time;
     TimeHolder.setDuration(endTime - startTime);
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
 }
예제 #13
0
 // Update is called once per frame
 void Update()
 {
     GameObject.Find("time").GetComponent <Text>().text = "Your time was:\n" + TimeHolder.getDuration().ToString() + "s";
     Restart();
 }
예제 #14
0
 void Awake()
 {
     timeHolder = FindObjectOfType<TimeHolder>();
 }
예제 #15
0
 void Awake()
 {
     timeHolder = FindObjectOfType <TimeHolder>();
 }
예제 #16
0
 void Awake()
 {
     meshFilter = GetComponent<MeshFilter>();
     meshRenderer = GetComponent<MeshRenderer>();
     timeHolder = FindObjectOfType<TimeHolder>();
 }