コード例 #1
0
        public void Given_I_Have_a_list_of_10_frames_and_10th_frame_is_a_spare_I_will_get_back_1()
        {
            //given I have a a list of 10 frames
            FrameObject frame1  = new FrameObject();
            FrameObject frame2  = new FrameObject();
            FrameObject frame3  = new FrameObject();
            FrameObject frame4  = new FrameObject();
            FrameObject frame5  = new FrameObject();
            FrameObject frame6  = new FrameObject();
            FrameObject frame7  = new FrameObject();
            FrameObject frame8  = new FrameObject();
            FrameObject frame9  = new FrameObject();
            FrameObject frame10 = new FrameObject();

            //and the 10th frame is a spare
            frame10.wasSpare = true;
            //when I call the additional bowl calculator
            List <FrameObject> frameList = new List <FrameObject>()
            {
                frame1, frame2, frame3, frame4, frame5, frame6, frame7, frame8, frame9, frame10
            };
            IDetermineAdditionalBowls determineAdditionalBowls = new DetermineAdditionalBowls();
            int bowls = determineAdditionalBowls.determineAdditionalBowls(frameList);

            //then I will get back a 1
            Assert.AreEqual(1, bowls);
        }
コード例 #2
0
        public void Given_I_have_a_list_of_frames_where_the_first_frame_is_a_spare_and_the_second_frame_first_bowl_is_9_I_will_get_back_a_list_of_frames_the_score_of_the_spare_is_19()
        {
            //given I have a list of frames
            FrameObject frame1 = new FrameObject();
            FrameObject frame2 = new FrameObject();

            //and the first frame total score is 10
            frame1.score = 10;
            //and the spare bool for the 1st frame is true
            frame1.wasSpare = true;
            //and the second frame first bowl score is 9
            frame2.bowl1 = 9;
            //and the strike bool for the 2nd frame is false
            frame2.wasStrike = false;
            //when the update frame score is calculated
            List <FrameObject> frameList = new List <FrameObject>()
            {
                frame1, frame2
            };
            ICalculateSpareScore calculateUpdatedFrame = new CalculateSpareScore();

            frameList = calculateUpdatedFrame.CalculateFrameScore(frameList);
            //then the first frame total score will be 19
            Assert.AreEqual(19, frame1.score);
        }
コード例 #3
0
        public void Given_I_have_a_list_of_frames_where_the_third_frame_is_a_spare_and_the_fourth_frame_first_bowl_is_10_I_will_get_back_a_list_of_frames_the_score_of_the_spare_is_20()
        {
            //given I have a list of frames
            FrameObject frame1 = new FrameObject();
            FrameObject frame2 = new FrameObject();
            FrameObject frame3 = new FrameObject();
            FrameObject frame4 = new FrameObject();

            //and the third frame total score is 10
            frame3.score = 10;
            //and the spare bool for the 3rd frame is true
            frame3.wasSpare = true;
            //and the fourth frame first bowl score is 10
            frame4.bowl1 = 10;
            //and the strike bool for the 3rd frame is false
            frame4.wasStrike = true;
            //when the update frame score is calculated
            List <FrameObject> frameList = new List <FrameObject>()
            {
                frame1, frame2, frame3, frame4
            };
            ICalculateSpareScore calculateUpdatedFrame = new CalculateSpareScore();

            frameList = calculateUpdatedFrame.CalculateFrameScore(frameList);
            //then the first frame total score will be 20
            Assert.AreEqual(20, frame3.score);
        }
コード例 #4
0
        public void Given_I_have_a_list_of_frames_and_one_is_a_strike_and_the_second_frame_is_a_strike_and_third_frame_first_bowl_is_a_5_then_first_strike_total_is_25()
        {
            //given I have a list of frames
            FrameObject frame1 = new FrameObject();
            FrameObject frame2 = new FrameObject();
            FrameObject frame3 = new FrameObject();

            //and the first frame total score is 10
            frame1.score = 10;
            //and the strike bool for the first frame is true
            frame1.wasStrike = true;
            //and the second frame total score is 10
            frame2.score = 10;
            //and the strike bool for the second frame is true
            frame2.wasStrike = true;
            //and the third frame total score is 1
            frame3.bowl1 = 5;
            //and the third frame strike bool is false
            frame3.wasStrike = false;
            //and the third frame spare bool is false
            frame3.wasSpare = false;
            //when the update strike score is called
            List <FrameObject> frameList = new List <FrameObject>()
            {
                frame1, frame2, frame3
            };
            ICalculateStrikeScore calculateUpdatedFrame = new CalculateStrikeScore();

            frameList = calculateUpdatedFrame.CalculateFrameScore(frameList);
            //then the second frame total score will be 25
            Assert.AreEqual(25, frame1.score);
        }
コード例 #5
0
        public void Given_I_have_a_list_of_frames_and_one_is_a_strike_and_the_fourth_frame_has_a_score_of_5_then_strike_total_is_15()
        {
            //given I have a list of frames
            FrameObject frame1 = new FrameObject();
            FrameObject frame2 = new FrameObject();
            FrameObject frame3 = new FrameObject();
            FrameObject frame4 = new FrameObject();

            //and the third frame total score is 10
            frame3.score = 10;
            //and the strike bool for the third frame is true
            frame3.wasStrike = true;
            //and the fourth frame total score is 5
            frame4.score = 5;
            //and the fourth frame strike bool is false
            frame4.wasStrike = false;
            //and the fourth frame spare bool is false
            frame4.wasSpare = false;
            //when the update strike score is called
            List <FrameObject> frameList = new List <FrameObject>()
            {
                frame1, frame2, frame3, frame4
            };
            ICalculateStrikeScore calculateUpdatedFrame = new CalculateStrikeScore();

            frameList = calculateUpdatedFrame.CalculateFrameScore(frameList);
            //then the second frame total score will be 15
            Assert.AreEqual(15, frame3.score);
        }
コード例 #6
0
ファイル: RightBracket.cs プロジェクト: yamiew00/NEO4
 /// <summary>
 /// 畫面設定
 /// </summary>
 /// <param name="text">Control的text</param>
 /// <param name="frameObject">畫面物件</param>
 /// <returns>Task</returns>
 public Task SetFrame(string text, FrameObject frameObject)
 {
     return(Task.Run(() =>
     {
         InputController.Instance.SetRightBracket();
         frameObject.AppendPanel(text);
     }));
 }
コード例 #7
0
 /// <summary>
 /// 畫面設定
 /// </summary>
 /// <param name="text">Control的text</param>
 /// <param name="frameObject">畫面物件</param>
 /// <returns>Task</returns>
 public Task SetFrame(string text, FrameObject frameObject)
 {
     return(Task.Run(() =>
     {
         InputController.Instance.BackSpace();
         frameObject.PanelString = frameObject.PanelString.RemoveLast(1);
     }));
 }
コード例 #8
0
ファイル: Operator.cs プロジェクト: yamiew00/NEO4
        /// <summary>
        /// 畫面設定
        /// </summary>
        /// <param name="text">Control的text</param>
        /// <param name="frameObject">畫面物件</param>
        /// <returns>Task</returns>
        public async Task SetFrame(string text, FrameObject frameObject)
        {
            InputController.Instance.SetOperator(text);
            frameObject.AppendPanel(text);

            //裡面也有畫面處理
            await NetworkController.Instance.OperatorRequest(InputController.Instance.CreateOperatorExpression(), frameObject);
        }
コード例 #9
0
ファイル: ClearError.cs プロジェクト: yamiew00/NEO4
 /// <summary>
 /// 畫面設定
 /// </summary>
 /// <param name="text">Control的text</param>
 /// <param name="frameObject">畫面物件</param>
 /// <returns>Task</returns>
 public Task SetFrame(string text, FrameObject frameObject)
 {
     return(Task.Run(() =>
     {
         var BackLength = InputController.Instance.NumberStr.Length + 2;
         frameObject.PanelString = frameObject.PanelString.RemoveLast(BackLength);
         InputController.Instance.ClearError();
     }));
 }
コード例 #10
0
 /// <summary>
 /// 畫面設定
 /// </summary>
 /// <param name="text">Control的text</param>
 /// <param name="frameObject">畫面物件</param>
 /// <returns>Task</returns>
 public Task SetFrame(string text, FrameObject frameObject)
 {
     return(Task.Run(() =>
     {
         InputController.Instance.Clear();
         NetworkController.Instance.ClearRequest();
         frameObject.PanelString = string.Empty;
     }));
 }
コード例 #11
0
ファイル: MainWindow.xaml.cs プロジェクト: jpgithub/jprepost
 private void InitializeFrames()
 {
     while (count <= 200)
     {
         FrameObject frame = new FrameObject();
         frame.FieldOne = (uint)count;
         Frames.Add(frame);
         count++;
     }
 }
コード例 #12
0
 void Init()
 {
     _frameObject = (new GameObject("WebViewObject")).AddComponent <FrameObject>();
     _frameObject.Init(
         cb: (msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); },
         err: (msg) => { Debug.Log(string.Format("CallOnError[{0}]", msg)); },
         started: (msg) => { Debug.Log(string.Format("CallOnStarted[{0}]", msg)); },
         ld: (msg) => { _frameObject.SetVisibility(true); }, enableWKWebView: true,
         transparent: true);
 }
コード例 #13
0
ファイル: Number.cs プロジェクト: yamiew00/NEO4
 /// <summary>
 /// 畫面設定
 /// </summary>
 /// <param name="text">Control的text</param>
 /// <param name="frameObject">畫面物件</param>
 /// <returns>Task</returns>
 public Task SetFrame(string text, FrameObject frameObject)
 {
     return(Task.Run(() =>
     {
         if (InputController.Instance.AddNumber(text))
         {
             frameObject.AppendPanel(text);
         }
     }));
 }
コード例 #14
0
ファイル: MainWindow.xaml.cs プロジェクト: jpgithub/jprepost
        private void stopBtn_Click(object sender, RoutedEventArgs e)
        {
            frametimer.Stop();
            isReverse = false;
            //DisplayOutput(Frame.First());

            FrameObject begin = Frames.First();

            count             = (int)begin.FieldOne;
            FrameTime.Content = "Frame " + count.ToString();
        }
コード例 #15
0
ファイル: TagManager.cs プロジェクト: yamiew00/NEO4
 /// <summary>
 /// 當執行特定順序的Tag時該處理的特別狀況
 /// </summary>
 /// <param name="frameObject">畫面物件</param>
 private void TagCombo(FrameObject frameObject)
 {
     if (ITag == Operator.Instance && LastITag == Operator.Instance)
     {
         frameObject.PanelString = frameObject.PanelString.RemoveLast(1);
     }
     else if (LastITag == Equal.Instance)
     {
         frameObject.PanelString    = string.Empty;
         frameObject.SubPanelString = string.Empty;
     }
 }
コード例 #16
0
ファイル: Unary.cs プロジェクト: yamiew00/NEO4
        /// <summary>
        /// 畫面設定
        /// </summary>
        /// <param name="text">Control的text</param>
        /// <param name="frameObject">畫面物件</param>
        /// <returns>Task</returns>
        public Task SetFrame(string text, FrameObject frameObject)
        {
            return(Task.Run(() =>
            {
                InputController.Instance.AddUnary(text);
                var LastNumberStr = InputController.Instance.NumberStr;

                frameObject.PanelString = frameObject.PanelString.RemoveLast(LastNumberStr.Length);
                frameObject.AppendPanel(text);
                frameObject.AppendPanel(LastNumberStr);
            }));
        }
コード例 #17
0
ファイル: TagManager.cs プロジェクト: yamiew00/NEO4
        /// <summary>
        /// 畫面設定
        /// </summary>
        /// <param name="text">Control的text</param>
        /// <param name="frameObject">畫面物件</param>
        /// <returns>Task</returns>
        public Task SetFrame(string text, FrameObject frameObject)
        {
            return(Task.Run(async() =>
            {
                //執行特定順序的Tag時該處理的特別狀況
                TagCombo(frameObject);

                await ITag.SetFrame(text, frameObject);

                //記錄這次的Tag
                RecordThisItag();
            }));
        }
コード例 #18
0
        /// <summary>
        /// 拿取(Feature, Content)的api接口。回傳Panel與SubPanel的物件
        /// </summary>
        /// <param name="userId">用戶ID</param>
        /// <returns>FrameResponse物件的JSON: 帶有Panel和SubPanel的字串</returns>
        public IHttpActionResult PostIntegrate(int userId)
        {
            //拿body中的Feature與Content。並存為Instruct物件
            Instruct instruct = Request.Content.ReadAsAsync <Instruct>().Result;

            //向Feature類別索取FrameObject
            FrameObject frameObject = FeatureReactor.GetFrameObject(userId, instruct);

            //將response包成Json格式
            JObject json = frameObject.ToJson <FrameObject>();

            return(Ok(json));
        }
コード例 #19
0
        public void Given_I_Have_a_frame_with_a_score_of_10_and_a_score_of_0_then_i_will_get_back_strike_bool_true()
        {
            //given i have a frame
            FrameObject frame;

            frame = new FrameObject {
                bowl1 = 10, bowl2 = 0, score = 10
            };
            //when the frame score is calculated
            IDetermineStrikeSpareOpen determineStrikeSpareOpen = new DetermineStrikeSpareOpen();

            frame = determineStrikeSpareOpen.CalculateFrameScore(frame);
            //then strike bool being true
            Assert.AreEqual(true, frame.wasStrike);
        }
コード例 #20
0
        public void Given_I_Have_a_frame_with_a_score_of_1_and_a_score_of_1_then_i_will_get_back_spare_bool_false()
        {
            //given i have a frame
            FrameObject frame;

            frame = new FrameObject {
                bowl1 = 1, bowl2 = 1, score = 2
            };
            //when the frame score is calculated
            IDetermineStrikeSpareOpen determineStrikeSpareOpen = new DetermineStrikeSpareOpen();

            frame = determineStrikeSpareOpen.CalculateFrameScore(frame);
            //then spare bool being false
            Assert.AreEqual(false, frame.wasSpare);
        }
コード例 #21
0
        public void Given_I_Have_a_frame_with_a_score_of_1_and_a_score_of_8_then_i_will_get_back_a_score_of_9_with_both_bool_being_false()
        {
            //given i have a frame
            FrameObject frame;

            frame = new FrameObject {
                bowl1 = 1, bowl2 = 8
            };
            //when the frame score is calculated
            ICalculateFrame calculateFrame = new CalculateFrame();

            frame = calculateFrame.CalculateFrameScore(frame);
            //then i will get back a score of 9
            Assert.AreEqual(9, frame.score);
        }
コード例 #22
0
        public FrameObject CalculateFrameScore(FrameObject frame)
        {
            if (frame.bowl1 == 10)
            {
                frame.wasStrike = true;
                return(frame);
            }

            if (frame.score == 10)
            {
                frame.wasSpare = true;
                return(frame);
            }
            return(frame);
        }
コード例 #23
0
        /// <summary>
        /// 根據「上一次執行命令的tag」,來決定該做什麼事
        /// </summary>
        /// <param name="frameObject">目前的frameObject</param>
        /// <param name="tag">control的tag</param>
        /// <param name="text">control的text</param>
        /// <returns></returns>
        public static Task FrameDealer(FrameObject frameObject, string tag, string text)
        {
            return(Task.Run(async() =>
            {
                //按完等號之後需要清空畫面
                if (LastTag.Equals("Equal"))
                {
                    frameObject.PanelString = string.Empty;
                    frameObject.SubPanelString = string.Empty;
                }

                //按tag做事
                await Actions[tag](text, frameObject);

                //記錄這次執行命令的tag
                LastTag = tag;
            }));
        }
コード例 #24
0
ファイル: FrameObjectStore.cs プロジェクト: ikorin24/Elffy
 public void AddFrameObject(FrameObject frameObject)
 {
     Debug.Assert(frameObject is null == false);
     _addedBuf.Add(frameObject);
 }
コード例 #25
0
 public FrameObject CalculateFrameScore(FrameObject frame)
 {
     frame.score = frame.bowl1 + frame.bowl2;
     return(frame);
 }
コード例 #26
0
        /// <summary>
        /// 畫面設定
        /// </summary>
        /// <param name="text">Control的text</param>
        /// <param name="frameObject">畫面物件</param>
        /// <returns>Task</returns>
        public async Task SetFrame(string text, FrameObject frameObject)
        {
            await NetworkController.Instance.EqualRequest(InputController.Instance.CreateEqualExpression(), frameObject);

            frameObject.AppendPanel(text);
        }
コード例 #27
0
ファイル: BoardObject.cs プロジェクト: yamiew00/NEO4
 /// <summary>
 /// 全體初始化
 /// </summary>
 public void Init()
 {
     CompleteExpression = string.Empty;
     FrameObject        = new FrameObject();
 }
コード例 #28
0
 /// <summary>
 /// 建構子
 /// </summary>
 public FrameObjectFactory()
 {
     FrameObject        = new FrameObject();
     CompleteExpression = string.Empty;
     OrderingChecker    = new OrderingChecker();
 }
コード例 #29
0
    public override void OnEvent(EventData e)
    {
        if ((imageType == ImageType.Color && (int)e.posz != 0) ||
            (imageType == ImageType.Depth && (int)e.posz != -1)
            )
        {
            return;
        }
        byte[] bitmapBytes = e.extraData;
        receivedExtraDataSize = (int)bitmapBytes.Length;

        // Total pixels * RGBA channels (byte per channel)
        int bytesPerImage  = totalImagePixelCount * 4;
        int bytesPerPacket = bytesPerImage / numberOfPacketsPerImage;

        calculatedExtraDataSize = bytesPerPacket;

        int packetID = (int)e.flags; // Packet number 0 - (numberOfPacketsPerImage - 1)

        int frameID = (int)e.sourceId;

        if (forceCompleteFrames)
        {
            if (frameIndexLookup.ContainsKey(frameID))
            {
                int currentFrameIndex = (int)frameIndexLookup[frameID];
                currentFrameObject = frames[currentFrameIndex];

                currentFrameObject.packetsReceived[packetID] = 1;
                currentFrameObject.packetsReady = currentFrameObject.packetsReady + 1;

                frames[currentFrameIndex] = currentFrameObject;

                // Debug.Log("Updated timestamp " + frameID + " index " + currentFrameIndex + " " + packetID + "/" + numberOfPacketsPerImage);
            }
            else
            {
                // Debug.Log("New timestamp " + frameID + " added to frame index " + nextFrameIndex);

                frameIndexLookup.Add(frameID, nextFrameIndex);
                currentFrameObject                 = frames[nextFrameIndex];
                currentFrameObject.texture         = new Texture2D(imageWidth, imageHeight);
                currentFrameObject.packetsReceived = new int[numberOfPacketsPerImage];
                currentFrameObject.packetsReady    = 1;
                frames[nextFrameIndex]             = currentFrameObject;

                if (nextFrameIndex < frameBufferSize - 1)
                {
                    nextFrameIndex++;
                }
                else
                {
                    nextFrameIndex = 0;
                }
            }
        }

        int extraDataSize = calculatedExtraDataSize;

        // Calculate the pixel (x,y) position from segment of a
        // linear array representing all the pixels
        int pixelsPerPacket = extraDataSize / 4;
        int linesPerPacket  = pixelsPerPacket / imageWidth;

        // Determine if the packet of pixels ends in the middle
        // of a horizontal line and determine the offset/shift
        // that needs to be applied
        int packetShift = 0;
        int lineOffset  = pixelsPerPacket % imageWidth;

        if (lineOffset != 0)
        {
            packetShift = packetID % (imageWidth / lineOffset);
        }

        x = packetShift * lineOffset;
        y = packetID * linesPerPacket;

        // Read through all the bytes in the array
        // Pulling out every 4 bytes (each RGBA element)
        for (int i = 0; i < extraDataSize; i += 4)
        {
            Array.Copy(bitmapBytes, i, byteSample, 0, 4);

            // Format from Kinect is BGRA (not RGBA)
            Color color = new Color(byteSample[2] / 255.0f, byteSample[1] / 255.0f, byteSample[0] / 255.0f);

            // If pixel array reaches end of image width, next line
            if (x >= imageWidth)
            {
                x = 0;
                y++;
            }

            if (forceCompleteFrames)
            {
                currentFrameObject.texture.SetPixel(x, y, color);
            }
            else
            {
                texture.SetPixel(x, y, color);
            }
            x++;
        }
    }
コード例 #30
0
ファイル: FrameObjectStore.cs プロジェクト: ikorin24/Elffy
 public void RemoveFrameObject(FrameObject frameObject)
 {
     Debug.Assert(frameObject is null == false);
     _removedBuf.Add(frameObject);
 }