예제 #1
0
    public override InputResult CanPutIntoPosition(PositionVO _target)
    {
        InputResult result = new InputResult(true, "Success");

        Minion target = MinionController.Instance.GetMinionByPosition(_target);
        if (_target.PlayerType != PlayerType.Opponent)
        {
            result.SetFailReason("Not Nec Target");
            return result;
        }

        Minion tMinion = MinionController.Instance.GetMinionByPosition(_target);
        if (tMinion == null)
        {
            result.SetFailReason("No Minion");
            return result;
        }

        if (tMinion.ContainTag(Tag.Hero))
        {
            result.SetFailReason("Taget Can't be Hero");
            return result;
        }

        return result;
    }
예제 #2
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig jig = new InputJig();

            // Get the first box point from the jig
            InputResult res = jig.GetPoint("Select first point:");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            _pnt1 = res.Point;

            // Add the object to the database
            this.DbEntity.AddToCurrentDocument();

            //Exclude the object from snap points
            jig.ExcludeObject(ID);

            // Monitoring mouse moving and interactive entity redrawing
            jig.MouseMove = (s, a) => { TryModify(); _pnt2 = a.Point; this.DbEntity.Update(); };

            // Get the second box point from the jig
            res = jig.GetPoint("Select second point:");
            if (res.Result != InputResult.ResultCode.Normal)
            {
                this.DbEntity.Erase();
                return(hresult.e_Fail);
            }
            _pnt2 = res.Point;

            return(hresult.s_Ok);
        }
예제 #3
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig    jig = new InputJig();
            InputResult res = jig.SelectObject("Select Line");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }

            LineSeg3d line = res.Geometry.LineSeg;

            _pnt1 = line.StartPoint;
            _pnt2 = line.EndPoint;

            McObjectId id        = res.ObjectId;
            DbGeometry selection = id.GetObject();

            //if (selection.IsKindOf(DbPolyline.TypeID))
            //{
            //    MessageBox.Show("poly");
            //}
            //else if (selection.IsKindOf(DbLine.TypeID))
            //{
            //    MessageBox.Show("line");
            //}
            //else
            //{
            //    MessageBox.Show("Objecttype isn't valid");
            //    DbEntity.Erase();
            //    return hresult.e_Fail;
            //}
            DbEntity.AddToCurrentDocument();
            return(hresult.s_Ok);
        }
예제 #4
0
 protected void InputThreadSheduler()
 {
     while (true)
     {
         LastInput = GetInputDirection();
     }
 }
예제 #5
0
    public void UploadUserInput(string jsonInput)
    {
        //test override code
        //string pTest = "{\"parcelation\": \"[{\\\"user_id\\\":2.0,\\\"floor\\\":2,\\\"loc\\\":[3,12],\\\"type\\\":\\\"FitnessCentre\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"FitnessCentre\\\",\\\"ss\\\":1}},{\\\"user_id\\\":1591783415.5496323109,\\\"floor\\\":2,\\\"loc\\\":[13,15],\\\"type\\\":\\\"Assisted\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"Assisted\\\",\\\"ageGroup\\\":\\\"Elderly\\\",\\\"pax\\\":2,\\\"affordable\\\":true,\\\"requiredRooms\\\":{\\\"SingleBedroom\\\":0,\\\"SharedBedroom\\\":0,\\\"Study\\\":2},\\\"location\\\":[\\\"0\\\",\\\"1\\\"],\\\"preferredSharedSpaces\\\":[\\\"Lounge\\\",\\\"Salon\\\",\\\"Cafeteria\\\"]}},{\\\"user_id\\\":3.0,\\\"floor\\\":9,\\\"loc\\\":[0,9],\\\"type\\\":\\\"SportsHall\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"SportsHall\\\",\\\"ss\\\":1}},{\\\"user_id\\\":1591787245.2690422535,\\\"floor\\\":9,\\\"loc\\\":[13,15],\\\"type\\\":\\\"Multi\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"Multi\\\",\\\"ageGroup\\\":\\\"Elderly\\\",\\\"pax\\\":3,\\\"affordable\\\":false,\\\"requiredRooms\\\":{\\\"SingleBedroom\\\":0,\\\"SharedBedroom\\\":0,\\\"Study\\\":1},\\\"location\\\":[\\\"2\\\",\\\"1\\\"],\\\"preferredSharedSpaces\\\":[\\\"Salon\\\",\\\"SportsHall\\\",\\\"Cafeteria\\\"]}},{\\\"user_id\\\":1591787369.0874810219,\\\"floor\\\":20,\\\"loc\\\":[4,11],\\\"type\\\":\\\"Multi\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"Multi\\\",\\\"ageGroup\\\":\\\"Midlife\\\",\\\"pax\\\":7,\\\"affordable\\\":false,\\\"requiredRooms\\\":{\\\"SingleBedroom\\\":2,\\\"SharedBedroom\\\":2,\\\"Study\\\":2},\\\"location\\\":[\\\"1\\\",\\\"0\\\"],\\\"preferredSharedSpaces\\\":[\\\"Salon\\\",\\\"FitnessCentre\\\",\\\"CommunityFarm\\\"]}},{\\\"user_id\\\":0.0,\\\"floor\\\":23,\\\"loc\\\":[0,9],\\\"type\\\":\\\"Cafeteria\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"Cafeteria\\\",\\\"ss\\\":1}},{\\\"user_id\\\":1.0,\\\"floor\\\":31,\\\"loc\\\":[0,9],\\\"type\\\":\\\"CommunityFarm\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"CommunityFarm\\\",\\\"ss\\\":1}},{\\\"user_id\\\":4.0,\\\"floor\\\":27,\\\"loc\\\":[3,12],\\\"type\\\":\\\"Lounge\\\",\\\"user_input\\\":{\\\"livingArrangement\\\":\\\"Lounge\\\",\\\"ss\\\":1}}]\", \"ssCount\": \"{\\\"Cafeteria\\\": 2, \\\"CommunityFarm\\\": 1, \\\"FitnessCentre\\\": 1, \\\"SportsHall\\\": 1, \\\"Lounge\\\": 1, \\\"Salon\\\": 3, \\\"Library\\\": 0, \\\"Tailor\\\": 0, \\\"Market\\\": 0, \\\"Playscape\\\": 0, \\\"PlayRoom\\\": 0, \\\"Restaurant\\\": 0, \\\"MultiGenCenter\\\": 0, \\\"HealthcareClinic\\\": 0, \\\"Makerspace\\\": 0, \\\"Childcare\\\": 0}\", \"inputCount\": 3}";
        //GetParcelationResult result = Newtonsoft.Json.JsonConvert.DeserializeObject<GetParcelationResult>(pTest);
        //List<BuildingUnit> newState = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BuildingUnit>>(result.parcelation);
        //Dictionary<string, int> ssCount = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, int>>(result.ssCount);
        //ParcelationManager.Instance.UpdateParcelation(newState);
        //CreateUnitScreen.Instance.UpdateQ6Counters(ssCount);
        //UiCanvasManager.Instance.CongratulatoryScreen();
        //Debug.LogError(jsonInput);

        //Show loader
        StartCoroutine(IEUploadUserInput(jsonInput, callback: result =>
        {
            Debug.LogWarning(result);
            InputResult res = Newtonsoft.Json.JsonConvert.DeserializeObject <InputResult>(result);
            List <BuildingUnit> newState = Newtonsoft.Json.JsonConvert.DeserializeObject <List <BuildingUnit> >(res.parcelation);
            ParcelationManager.Instance.currentUserId = res.userId;
            Debug.LogWarning("UserId: " + res.userId.ToString());
            ParcelationManager.Instance.UpdateParcelation(newState);
            //Hide loader overlay
            UiCanvasManager.Instance.CongratulatoryScreen();
        }));
    }
예제 #6
0
        private void OneObject(InputResult inputResult)
        {
            var obj = inputResult.Objects.Single();
            inputResult.Grammar = inputResult.Verb.Grammars.FirstOrDefault(x => x.Preposition == inputResult.Preposition);
            string msg = "What do you want to {0} the {1} {2}?".F(inputResult.Verb.Name, obj.Name, inputResult.Preposition);
            Context.Output.Print(msg);

            string reply = Context.CommandPrompt.GetInput();
            if (string.IsNullOrEmpty(reply))
            {
                inputResult.Action = UserInput.ErrorAction(L.DoNotUnderstand);
            }

            var tokenizer = new InputTokenizer();
            var tokens = tokenizer.Tokenize(reply);

            //TODO: this should fail in some cases
            string input = null;

            if (!tokens.StartsWithVerb())
            {
                input = "{0} {1} {2} {3}".F(inputResult.Verb.Name, obj.Synonyms[0], inputResult.Preposition, reply);
            }
            else
            {
                input = reply;
            }

            inputResult.ParserResults.AddRange(Context.Parser.Parse(input));
            inputResult.Handled = true;
        }
예제 #7
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig    jig = new InputJig();
            InputResult res = jig.GetPoint("Select first point:");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            _pnt = res.Point;
            DbEntity.AddToCurrentDocument();
            //Exclude this from osnap to avoid osnap to itself
            jig.ExcludeObject(ID);
            //Monitor mouse move
            jig.MouseMove = (s, a) => {
                TryModify();
                _pnt2 = a.Point;
                _pnt3 = new Point3d(_pnt2.X, _pnt.Y, 0);
                _pnt1 = new Point3d(_pnt.X, _pnt2.Y, 0);
                DbEntity.Update();
            };

            res = jig.GetPoint("Select second point:", res.Point);
            if (res.Result != InputResult.ResultCode.Normal)
            {
                DbEntity.Erase();
                return(hresult.e_Fail);
            }
            _pnt2 = res.Point;
            _pnt1 = new Point3d(_pnt.X, _pnt2.Y, 0);
            _pnt3 = new Point3d(_pnt2.X, _pnt.Y, 0);
            return(hresult.s_Ok);
        }
예제 #8
0
 public override void HandleYourCardSelection(Board board, Hand playerHand, ref InputResult result)
 {
     if (this.strictActiveInputHandler != InputDelegatorHandler.InputType.None)
     {
         this.inputs[(Int32)this.strictActiveInputHandler].HandleYourCardSelection(board, playerHand, ref result);
     }
     else
     {
         foreach (InputHandler inputHandler in this.inputs)
         {
             inputHandler.HandleYourCardSelection(board, playerHand, ref result);
         }
     }
     if (Input.GetMouseButtonUp(0))
     {
         Vector3         worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         SpriteClickable component  = this.MouseInput.CardNameToggleButton.GetComponent <SpriteClickable>();
         if (component != (UnityEngine.Object)null && component.Contains(worldPoint) && this.MouseInput.CardNameDialogSlider.IsReady)
         {
             this.MouseInput.CardNameDialogSlider.IsShowCardName = !this.MouseInput.CardNameDialogSlider.IsShowCardName;
             if (this.MouseInput.CardNameDialogSlider.IsShowCardName)
             {
                 this.MouseInput.CardNameDialogSlider.ShowCardNameDialog(playerHand);
             }
             else
             {
                 this.MouseInput.CardNameDialogSlider.HideCardNameDialog(playerHand);
             }
             SoundEffect.Play(QuadMistSoundID.MINI_SE_CURSOL);
         }
     }
 }
예제 #9
0
 public override InputResult CanPutIntoPosition(PositionVO _target)
 {
     InputResult result = new InputResult(true, "Success");
     List<Minion> tMinions = MinionController.Instance.GetMinionsByPlayerType(PlayerType.Opponent);
     if (tMinions == null)
         result.SetFailReason("No Valid Minion");
     return result;
 }
예제 #10
0
 public override InputResult CanPutIntoPosition(PositionVO _target)
 {
     InputResult result = new InputResult(true, "Success");
     Minion tMinion = MinionController.Instance.GetMinionByPosition(_target);
     if (tMinion == null)
         result.SetFailReason("No Minion");
     return result;
 }
예제 #11
0
 private void inputDoneCallback(WaveVR_IMEManager.InputResult results)
 {
     if (mCallback != null)
     {
         InputResult inputResult = new InputResult(results.InputContent);
         mCallback(inputResult);
     }
 }
예제 #12
0
 public override void HandleConfirmation(ref InputResult result)
 {
     if (Input.GetMouseButtonUp(0))
     {
         SoundEffect.Play(QuadMistSoundID.MINI_SE_CURSOL);
         this.delegateInputHandler.LastActiveInputHandler = InputDelegatorHandler.InputType.Mouse;
         result.Used();
     }
 }
예제 #13
0
        //
        public static SavePresetWindow Init(string name, InputResult callback)
        {
            Rect             rect   = new Rect(Screen.width * 0.5f, Screen.height * 0.5f, 300f, 60f);
            SavePresetWindow window = GetWindowWithRect <SavePresetWindow>(rect, true, "Specify Preset Name", true);

            window.callback   = callback;
            window.presetName = name;
            return(window);
        }
예제 #14
0
        public void TestIfHelpAsked()
        {
            result = SetupMockInputResult("--help");

            var rpc = new RunParameterChecker(fakeOutput, result, appsb);

            rpc.ParametersAreValid().Should().BeFalse();
            rpc.Errs.Count.Should().Be(0);
        }
예제 #15
0
 public override void HandleConfirmation(ref InputResult result)
 {
     if (UIManager.Input.GetKeyTrigger(Control.Confirm))
     {
         SoundEffect.Play(QuadMistSoundID.MINI_SE_CARD_MOVE);
         this.delegateInputHandler.LastActiveInputHandler = InputDelegatorHandler.InputType.Keyboard;
         result.Used();
     }
 }
예제 #16
0
    /// <summary>
    /// Check if there was a tap on the plane
    ///
    /// To-do: extend input
    /// </summary>
    /// <returns></returns>
    private void CheckTapOnARPlane()
    {
        LayerMask   layer      = LayerMask.NameToLayer("Tower");
        InputResult resultInfo = XInput.Instance.CheckTap(1 << layer, TouchPhase.Began);

        if (resultInfo.result == ResultType.Success)
        {
            PlaceTrap(resultInfo.hit.point);
        }
    }
예제 #17
0
        public void GivenInputToMoveThenThePlayerLocationIsUpdated(InputResult inputResult)
        {
            var originalPosition = _player.Location.Clone();

            _input.SendInput(inputResult);

            _player
            .Location
            .Should()
            .NotBe(originalPosition);
        }
예제 #18
0
        private void tabs_addBtn_Click(object sender, EventArgs e)
        {
            HKTextInputForm inputForm = new HKTextInputForm();

            inputForm.titleText = "新名单名";
            InputResult result = inputForm.showTextInputForm();

            if (result.confirm == true)
            {
                tabs_addNewStuList(result.input);
            }
        }
예제 #19
0
 public override InputResult CanPutIntoPosition(PositionVO _target)
 {
     InputResult result = new InputResult(true, "Success");
     Minion target = MinionController.Instance.GetMinionByPosition(_target);
     if (target == null)
         return result.SetFailReason("No Valid Minion");
     if (target.PlayerType == PlayerType.Opponent || target.PlayerType == PlayerType.You)
     {
         return result;
     }
     return result.SetFailReason("No Valid Minion");
 }
예제 #20
0
 public override InputResult CanPutIntoPosition(PositionVO _target)
 {
     InputResult result = new InputResult(true, "Success");
     Minion minion = MinionController.Instance.GetMinionByPosition(_target);
     if (minion == null)
     {
         return result.SetFailReason("No Valid Minion");
     }
     if (minion.PlayerType == PlayerType)
         result.SetFailReason("Not Enemy Minion");
     return result;
 }
예제 #21
0
 public override void HandleDialog(ref InputResult result)
 {
     if (Input.GetMouseButtonUp(0))
     {
         this.delegateInputHandler.LastActiveInputHandler = InputDelegatorHandler.InputType.Mouse;
         Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         if (QuadMistConfirmDialog.IsShowing && QuadMistConfirmDialog.MessageSelect(worldPos))
         {
             result.Used();
         }
     }
 }
예제 #22
0
        public void TestIfFormatExceptionIsHandled()
        {
            result           = SetupMockInputResult("--lalala");
            result.HelpAsked = false;
            result.Errors.Clear();

            readMock.Setup(x => x.ReadJSONFile()).Throws(new FormatException());

            var rpc = new RunParameterChecker(fakeOutput, result, appsb);

            rpc.ParametersAreValid().Should().BeFalse();
            rpc.Errs.Should().BeEquivalentTo("Error reading JSON file");
        }
예제 #23
0
 public override InputResult CanPutIntoPosition(PositionVO _target)
 {
     InputResult result = new InputResult(true, "Success");
     Minion tHero = MinionController.Instance.GetHeroByPlayerType(PlayerType);
     if (tHero == null)
         result.SetFailReason("No Hero");
     if (_target.PlayerType != PlayerType)
         result.SetFailReason("Not Friendly Minion");
     Minion tMinion = MinionController.Instance.GetMinionByPosition(_target);
     if (tMinion == null)
         result.SetFailReason("No Minion");
     return result;
 }
예제 #24
0
        public void PollForInput_ValidInput_FireEvent(ConsoleKey key, InputResult expectedResult)
        {
            Input sut = new Input();

            sut.ReadKey = () => new ConsoleKeyInfo(key.ToString()[0], key, false, false, false);

            sut.MonitorEvents();

            sut.PollForInput();
            var eventMonitored = sut.ShouldRaise(nameof(Input.InputReceived));

            eventMonitored.First().Parameters.First().Should().Be(expectedResult);
        }
예제 #25
0
        private void tabBtnMenuMethod_ConfirmToChange(string title, object userData)
        {
            HKTextInputForm inputForm = new HKTextInputForm();

            inputForm.titleText    = "修改名称";
            inputForm.textBox.text = title;
            InputResult result = inputForm.showTextInputForm();

            if (result.confirm)
            {
                tabBtnMenuMethod_ChangeName((string)userData, result.input);
            }
        }
예제 #26
0
 public override void HandlePreSelection(PreBoard preBoard, Hand playerHand, ref InputResult result)
 {
     if (this.strictActiveInputHandler != InputDelegatorHandler.InputType.None)
     {
         this.inputs[(Int32)this.strictActiveInputHandler].HandlePreSelection(preBoard, playerHand, ref result);
     }
     else
     {
         foreach (InputHandler inputHandler in this.inputs)
         {
             inputHandler.HandlePreSelection(preBoard, playerHand, ref result);
         }
     }
 }
예제 #27
0
        protected void HandleSubActions(SceneGame scene)
        {
            var first = SubActions.First();

            first.HandleInput(scene);
            if (first.Result == InputResult.CloseAll)
            {
                Result = first.Result;
            }
            if (first.Done)
            {
                SubActions.RemoveAt(0);
            }
        }
예제 #28
0
 public override void HandleDialog(ref InputResult result)
 {
     if (this.strictActiveInputHandler != InputDelegatorHandler.InputType.None)
     {
         this.inputs[(Int32)this.strictActiveInputHandler].HandleDialog(ref result);
     }
     else
     {
         foreach (InputHandler inputHandler in this.inputs)
         {
             inputHandler.HandleDialog(ref result);
         }
     }
 }
예제 #29
0
        public void TestWrongArgument()
        {
            List <string> errorList = new List <string>()
            {
                nameof(ArgErrorType.WrongCommand),
                nameof(ArgErrorType.WrongInputDirectory)
            };

            result = SetupMockInputResult("--privet druzja");

            var rpc = new RunParameterChecker(fakeOutput, result, appsb);

            rpc.ParametersAreValid().Should().BeFalse();
            rpc.Errs.Should().BeEquivalentTo(errorList);
        }
예제 #30
0
 public override void HandlePreSelection(PreBoard preBoard, Hand playerHand, ref InputResult result)
 {
     if (Input.GetMouseButtonUp(0))
     {
         Vector3 worldPoint        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         Int32   indexByWorldPoint = preBoard.GetIndexByWorldPoint(worldPoint);
         if (indexByWorldPoint >= 0)
         {
             preBoard.SetPreviewCardID(indexByWorldPoint);
         }
         else
         {
             if (preBoard.GetPreviewByWorldPoint(worldPoint))
             {
                 if (playerHand.Count != 5)
                 {
                     QuadMistCard item = preBoard.RemoveSelected();
                     playerHand.Add(item);
                     if (playerHand.Count == 5)
                     {
                         result.Used();
                         return;
                     }
                 }
                 else if (playerHand.Count == 5)
                 {
                     result.Used();
                     return;
                 }
             }
             Int32 lrbyWorldPoint = preBoard.GetLRByWorldPoint(worldPoint);
             if (lrbyWorldPoint == 1)
             {
                 preBoard.NextCard();
             }
             if (lrbyWorldPoint == -1)
             {
                 preBoard.PrevCard();
             }
         }
         Int32 indexByWorldPoint2 = playerHand.GetIndexByWorldPoint(worldPoint);
         if (indexByWorldPoint2 >= 0)
         {
             preBoard.Add(playerHand[indexByWorldPoint2]);
             playerHand.RemoveAt(indexByWorldPoint2);
         }
     }
 }
예제 #31
0
    /// <summary>
    /// Handles moving traps around
    ///
    /// To-do: extend the input class
    /// </summary>
    void MoveTrap()
    {
        if (currentlySelectedTrap == null)
        {
            return;
        }

        LayerMask layer = LayerMask.NameToLayer("Tower");
        //LayerMask layer2 = LayerMask.NameToLayer("Trap");
        InputResult resultInfo = XInput.Instance.CheckTap((1 << layer), TouchPhase.Moved, TouchPhase.Stationary);

        if (resultInfo.result == ResultType.Success)
        {
            currentlySelectedTrap.transform.position = resultInfo.hit.point;// + Vector3.up * currentlySelectedTrap.transform.localScale.y / 2;
        }
    }
예제 #32
0
 public override void HandleYourCardSelection(Board board, Hand hand, ref InputResult result)
 {
     if (!this.animated)
     {
         hand.State = Hand.STATE.ENEMY_PLAY;
         this.ai.Think(hand);
         this.animated = true;
     }
     else if (this.animated && !this.ai.thinking)
     {
         this.ai.SetCard(board, hand, ref result);
         hand.RemoveAt(result.index);
         result.Used();
         this.animated = false;
     }
 }
예제 #33
0
        private static InputResult VerifyInput(string input, out int number)
        {
            InputResult result = InputResult.Error;

            if (input == END_SUM)
            {
                number = 0;
                result = InputResult.Equals;
            }
            else if (int.TryParse(input, out number))
            {
                result = InputResult.Number;
            }

            return(result);
        }
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig jig = new InputJig();

            // Get the first box point from the jig
            InputResult res = jig.GetPoint("Select first point:");
            if (res.Result != InputResult.ResultCode.Normal)
                return hresult.e_Fail;

            _pnt1 = res.Point;

            // Add the object to the database
            DbEntity.AddToCurrentDocument();
                        
            return hresult.s_Ok;
        }
예제 #35
0
        public void onInputCompletedwithObject(AndroidJavaObject resultObject)
        {
            Log.i(LOG_TAG, "unity callback with result object");
            if (mCallback == null)
            {
                Log.w(LOG_TAG, "unity callback but user callback is null ");
            }

            int    id           = resultObject.Get <int>("id");
            int    errorCode    = resultObject.Get <int>("errorCode");
            string inputContent = resultObject.Get <string>("inputContent");

            InputResult inputResult = new InputResult(id, inputContent, errorCode);

            mCallback(inputResult);
        }
예제 #36
0
    /// <summary>
    /// Check if there was a tap on the security screen
    ///
    /// Extend input class
    /// </summary>
    void CheckTapOnSecurityScreen()
    {
        LayerMask   layer      = LayerMask.NameToLayer("UI");
        InputResult resultInfo = XInput.Instance.CheckTap(1 << layer, TouchPhase.Began);

        if (resultInfo.result == ResultType.Success)
        {
            currentlySelectedTrap = resultInfo.hit.collider.GetComponent <SecurityScreen>().associatedCamera;
            currentlySelectedTrap.ToggleSelected();
            TogglePreviouslySelectedTrap();
        }
        else if (resultInfo.result == ResultType.MissTap)
        {
            currentlySelectedTrap = null;
            TogglePreviouslySelectedTrap();
        }
    }
예제 #37
0
    /// <summary>
    /// Checks if a tap hits a trap
    ///
    /// To-do: Extend an input class to do this
    /// </summary>
    void CheckTapOnTraps()
    {
        LayerMask   layer      = LayerMask.NameToLayer("Trap");
        InputResult resultInfo = XInput.Instance.CheckTap(1 << layer, TouchPhase.Began);

        if (resultInfo.result == ResultType.Success)
        {
            currentlySelectedTrap = resultInfo.hit.transform.GetComponent <TrapDefense>();
            currentlySelectedTrap.ToggleSelected();
            TogglePreviouslySelectedTrap();
        }
        else if (resultInfo.result == ResultType.MissTap)
        {
            currentlySelectedTrap = null;
            TogglePreviouslySelectedTrap();
        }
    }
예제 #38
0
        public void Handle(InputResult inputResult)
        {
            L = new Library();

            if (inputResult.Preposition.HasValue())
            {
                if (inputResult.Objects.Count == 1)
                {
                    OneObject(inputResult);
                }

            }
            else
            {
                inputResult.Grammar = inputResult.Verb.Grammars.First();
                if (inputResult.Preposition.HasValue())
                {
                    // dupe code from block above
                    if (inputResult.Objects.Count == 1)
                    {
                        OneObject(inputResult);
                    }
                    else if (inputResult.Objects.Count > 1)
                    {
                        MultipleObjects(inputResult);
                    }
                    else
                    {
                        NoObject(inputResult);
                    }
                }
            }

            //if (inputResult.Grammar == null)
            //{
            //    throw new Exception("What do we do with no Grammar?");
            //}

            //return false;
        }
예제 #39
0
 public void ShowDialogTest9()
 {
     IWin32Window owner = null; // TODO: Initialize to an appropriate value
     string message = string.Empty; // TODO: Initialize to an appropriate value
     Type[] types = null; // TODO: Initialize to an appropriate value
     InputResult expected = new InputResult(); // TODO: Initialize to an appropriate value
     InputResult actual;
     actual = InputDialog.ShowDialog(owner, message, types);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #40
0
        private bool FindGrammar(InputResult result, Verb verb, IEnumerable<string> grammars)
        {
            foreach (var possibleGrammar in grammars)
            {
                var matchedGrammar = verb.Grammars.FirstOrDefault(x => x.Format == possibleGrammar);

                if (matchedGrammar != null)
                {
                    result.Grammar = matchedGrammar;
                    return true;
                }
            }

            return false;
        }
예제 #41
0
 private void FindVerb(InputResult result, IEnumerable<Verb> possibleVerbs, IEnumerable<string> grammars)
 {
     foreach (var verb in possibleVerbs)
     {
         if (FindGrammar(result, verb, grammars))
         {
             result.Verb = verb;
             return;
         }
     }
 }
예제 #42
0
        public InputResult Parse(string input)
        {
            var result = new InputResult();

            var tokenizer = new InputTokenizer();
            var tokens = tokenizer.Tokenize(input);

            Action removeVerbToken = () => tokens.RemoveAt(0);

            if (tokens.Count == 0)
            {
                result.Action = () =>
                {
                    Context.Parser.Print(L.DoNotUnderstand);
                    return true;
                };
                return result;
            }

            // there can be more than one match for verbs like "switch"
            // which has one class that handles "switch on" and another 
            // class that handles "switch off"
            var possibleVerbs = VerbList.GetVerbsByName(tokens[0]);

            if (possibleVerbs.Count == 0)
            {
                result.Verb = new NullVerb();
                result.Action = ErrorAction(L.VerbNotRecognized);
                return result;
            }
            
            if (possibleVerbs.Count == 1)
            {
                result.Verb = possibleVerbs.First();
            }
            //else { NOT sure what to do about multiple possible verbs here}


            // remove verb token
            removeVerbToken();

            var grammarTokens = new List<string>();
            bool hasPreposition = false;

            foreach (string token in tokens)
            {
                bool hasObject = result.Objects.Count > 0;

                var objects = Objects.WithName(token);
                
                if (!hasObject)
                {
                    var rooms = Rooms.WithName(token);
                    foreach (var room in rooms)
                    {
                        objects.Add(room);
                    }
                }
                
                if (objects.Count == 0)
                {
                    bool isDirection = possibleVerbs.Count == 1 && 
                                       Compass.Directions.Contains(token) &&
                                       result.Objects.Count == 0;
                    bool isPreposition = Prepositions.Contains(token);
                
                    if (isDirection)
                    {
                        possibleVerbs.Clear();
                        possibleVerbs.Add(VerbList.GetVerbByName(token));
                    }
                    else if (isPreposition)
                    {
                        hasPreposition = true;
                        grammarTokens.Add(token);
                        result.Preposition = token;
                    }
                    else if (token == K.ALL)
                    {
                       // result.Objects.AddRange(L.ObjectsInScope());
                        grammarTokens.Add(token);
                        result.IsAll = true;
                    }
                    else if (token == K.EXCEPT)
                    {
                        if (!result.IsAll && !result.Objects.Any())
                        {
                            result.Action = ErrorAction(L.CantSeeObject);
                            return result;
                        }
                        result.IsExcept = true;
                    }
                    else
                    {
                        if (result.IsPartial)
                        {
                            string partial = String.Format("I only understood you as far as wanting to {0} the {1}.", possibleVerbs[0].Name, result.Objects[0].Name);
                            result.Action = ErrorAction(partial);
                            return result;
                        }
                        
                        result.Action = ErrorAction(L.CantSeeObject);
                        return result;
                    }
                }
                else
                {
                    // need to implement "Which do you mean, the red cape or the black cape?" type behavior here
                    Object obj;
                    var ofInterest = objects.Where(x => x.InScope).ToList();
                    if (ofInterest.Count > 1)
                    {
                        obj = ofInterest.FirstOrDefault(x => x.InInventory);
                    }
                    else
                    {
                        obj = ofInterest.FirstOrDefault();
                    }
                    //-------------------------------------------------------------------------------------
                    
                    bool isIndirectObject = hasPreposition && hasObject;
                    
                    if (obj == null)
                    {
                        result.Action = ErrorAction(L.CantSeeObject);
                        return result;
                    }
                    
                    if (isIndirectObject)
                    {
                        grammarTokens.Add(K.INDIRECT_OBJECT_TOKEN);
                        result.IndirectObject = obj;
                    }
                    else if (result.IsExcept)
                    {
                        //result.Objects.Remove(obj);
                        result.Exceptions.Add(obj);
                    }
                    else
                    {
                        if (!grammarTokens.Contains(K.OBJECT_TOKEN))
                            grammarTokens.Add(K.OBJECT_TOKEN);
                        if (!result.Objects.Contains(obj))
                            result.Objects.Add(obj);
                        result.IsPartial = true;
                    }
                }

               
            }

            result.Pregrammar = string.Join(" ", grammarTokens.ToArray());

            var grammarBuilder = new GrammarBuilder(grammarTokens);
            var grammars = grammarBuilder.Build();

            FindVerb(result, possibleVerbs, grammars);

            if (result.Grammar == null)
            {
                var incomplete = new IncompleteInput();
                incomplete.Handle(result);
            }
            
            if (result.IsAll)
            {
                if (result.ObjectsMustBeHeld)
                {
                    result.Objects = result.Objects.Where(x => x.InInventory).ToList();
                }
                else
                {
                    result.Objects = L.ObjectsInScope();
                }
            }

            if (result.IsExcept)
            {
                result.Exceptions.ForEach(x => result.Objects.Remove(x));
            }

            return result;
        }
예제 #43
0
        private void HandleInputResult(InputResult inputResult)
        {
            CommandBuilder builder = new CommandBuilder(inputResult);
            var commands = builder.Build();

            foreach(var command in commands)
            {
                ExecuteCommand(command);
            }
            
        }
예제 #44
0
 public void ShowDialogTest2()
 {
     IWin32Window owner = null; // TODO: Initialize to an appropriate value
     string message = string.Empty; // TODO: Initialize to an appropriate value
     Predicate<object> predicate = null; // TODO: Initialize to an appropriate value
     Tuple<Type, string>[] fields = null; // TODO: Initialize to an appropriate value
     InputResult expected = new InputResult(); // TODO: Initialize to an appropriate value
     InputResult actual;
     actual = InputDialog.ShowDialog(owner, message, predicate, fields);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #45
0
		// 
		public static SavePresetWindow Init(string name, InputResult callback)
		{
			Rect rect = new Rect(Screen.width * 0.5f, Screen.height * 0.5f, 300f, 60f);
			SavePresetWindow window = GetWindowWithRect<SavePresetWindow>(rect, true, "Specify Preset Name", true);
			window.callback = callback;
			window.presetName = name;
			return window;
		}
예제 #46
0
 private void MultipleObjects(InputResult inputResult)
 {
     inputResult.ParserResults.Add(L.DidntUnderstandSentence);
     inputResult.Handled = true;
 }
예제 #47
0
 public void PlaySound(InputResult result)
 {
     if(result != InputResult.Match)
         AudioSource.PlayClipAtPoint(keySound, Camera.main.transform.position);
 }
예제 #48
0
        public static InputResult ShowDialog(
            IWin32Window owner,
            string message,
            Predicate<object> predicate,
            Type inputType,
            int inputCount)
        {
            if (inputCount <= 0) throw new ArgumentException("It must contain atleast one input", "inputCount");
            if (inputCount == 1) return ShowDialog(owner, message, predicate, inputType);
            InputDialog dialog = new InputDialog();

            dialog.messageLabel.Text = message;

            for (int i = 0; i < inputCount; ++i)
            {
                dialog.textBoxes.Insert(i, new TextBox());
                dialog.textBoxes[i].WordWrap = false;
                dialog.textBoxes[i].Width = Math.Max(dialog.flowLayoutPanel.ClientSize.Width / inputCount, 100);
                dialog.flowLayoutPanel.Controls.Add(dialog.textBoxes[i]);
            }

            dialog.flowLayoutPanel.Top = dialog.messageLabel.Top + dialog.messageLabel.Height + 5;

            dialog.Controls.Add(dialog.flowLayoutPanel);

            DialogResult dres = dialog.ShowDialog(owner);

            InputResult result;
            if (dres == DialogResult.OK)
                result = new InputResult
                {
                    DialogResult = dres,
                    Values = CastArray((from tbox in dialog.textBoxes select tbox.Text).ToArray(), inputType),
                };
            else
                result = new InputResult { DialogResult = dres };
            return result;
        }
예제 #49
0
        public static InputResult ShowDialog(
            IWin32Window owner,
            string message,
            Predicate<object> predicate,
            Type inputType)
        {
            InputDialog dialog = new InputDialog();

            dialog.messageLabel.Text = message;

            // FIX: Leave out flowLayoutPanel.
            dialog.textBoxes.Insert(0, new TextBox());
            dialog.textBoxes[0].WordWrap = false;
            // BUG: doesn't work?
            dialog.textBoxes[0].Width = dialog.flowLayoutPanel.ClientSize.Width;
            dialog.flowLayoutPanel.Controls.Add(dialog.textBoxes[0]);

            dialog.flowLayoutPanel.Top = dialog.messageLabel.Top + dialog.messageLabel.Height + 5;

            dialog.Controls.Add(dialog.flowLayoutPanel);

            DialogResult dres = dialog.ShowDialog(owner);

            InputResult result;
            if (dres == DialogResult.OK)
                result = new InputResult
                {
                    DialogResult = dres,
                    Values = CastArray((from tbox in dialog.textBoxes select tbox.Text).ToArray(), inputType),
                };
            else result = new InputResult { DialogResult = dres };
            return result;
        }
예제 #50
0
        private void NoObject(InputResult inputResult)
        {
            string msg = "What do you want to {0}?".F(inputResult.Verb.Name);
            Context.Output.Print(msg);

            string reply = Context.CommandPrompt.GetInput();
            if (string.IsNullOrEmpty(reply))
            {
                inputResult.Action = UserInput.ErrorAction(L.DoNotUnderstand);
            }

            var tokenizer = new InputTokenizer();
            var tokens = tokenizer.Tokenize(reply);

            string input = null;

            if (!tokens.StartsWithVerb())
            {
                input = "{0} {1}".F(inputResult.Verb.Name, reply);
            }
            else
            {
                input = reply;
            }

            Context.Parser.Parse(input);
            //inputResult.ParserResults.AddRange();
            inputResult.Handled = true;
        }
예제 #51
0
    private static InputResult GetInput(GameObject gameObject, Phase phase)
    {
        InputResult result = new InputResult();

        #if UNITY_ANDROID

        if (Input.touchCount > 0)
        {
            for(int i = 0; i < Input.touchCount; i++)
            {
                Touch currentTouch = Input.GetTouch(i);

                if (validateInput(gameObject, currentTouch.position))
                {
                    switch (phase)
                    {
                    case Phase.BEGAN:
                        result.Input = currentTouch.phase == TouchPhase.Began;
                        break;
                    case Phase.MOVED:
                        result.Input = currentTouch.phase == TouchPhase.Moved;
                        break;
                    case Phase.ENDED:
                        result.Input = currentTouch.phase == TouchPhase.Ended;
                        break;
                    default:
                        throw new System.ArgumentException("Incorrect InputExtensions.Phase " + phase.ToString());
                    }
                }

                result.InputId = currentTouch.fingerId;
                result.Position = currentTouch.position;
            }
        }

        #endif

        #if UNITY_WEBPLAYER || UNITY_EDITOR

        if (validateInput(gameObject, Input.mousePosition))
        {
            switch (phase)
            {
            case Phase.BEGAN:
                result.Input = Input.GetMouseButtonDown(0);
                break;
            case Phase.MOVED:
                result.Input = Input.GetMouseButton(0);
                break;
            case Phase.ENDED:
                result.Input = Input.GetMouseButtonUp(0);
                break;
            default:
                throw new System.ArgumentException("Incorrect InputExtensions.Phase " + phase.ToString());
            }
        }

        result.Position = Input.mousePosition;

        #endif

        return result;
    }
예제 #52
0
파일: CmdReturn.cs 프로젝트: kjlam/Ginwoo2
 public CmdReturn()
 {
     inputSuccess = InputResult.UNDEFINED;
 }
예제 #53
0
파일: CmdReturn.cs 프로젝트: kjlam/Ginwoo2
 public CmdReturn()
 {
     inputSuccess = InputResult.UNDEFINED;
     fileList = null;
 }