コード例 #1
0
        /// <summary>
        /// Gets all files recursivly from the given directory. Recommended to end the path with "/"
        /// </summary>
        /// <param name="dir">The path</param>
        /// <returns>The list with all files</returns>
        public InteractionResult <List <FileSystemObject> > GetObjectsFromDirRecursive(string dir)
        {
            List <FileSystemObject> result = new List <FileSystemObject>();
            Queue <string>          toScan = new Queue <string>();
            bool root = mHasRoot ? mDevice.HasRoot : false;

            toScan.Enqueue(dir);

            while (toScan.Count > 0)
            {
                InteractionResult <List <FileSystemObject> > res = this.GetObjectsFromDir(toScan.Dequeue());

                if (res.WasSuccessful)
                {
                    foreach (FileSystemObject fso in res.Result)
                    {
                        if (fso.IsDirectory)
                        {
                            toScan.Enqueue(fso.Path);
                        }
                        else if (!fso.IsDirectory)
                        {
                            result.Add(fso);
                        }
                    }
                }
            }

            return(new InteractionResult <List <FileSystemObject> >(result, true, null));
        }
コード例 #2
0
        /// <summary>
        /// Helper function to get the cmi.interactions.n.result value
        /// </summary>
        public override string GetRteResult(InteractionResult result)
        {
            switch (result.State)
            {
            case InteractionResultState.Correct:
                return("correct");

            case InteractionResultState.Incorrect:
                return("wrong");

            case InteractionResultState.Neutral:
                return("neutral");

            case InteractionResultState.Unanticipated:
                return("unanticipated");

            case InteractionResultState.Numeric:
            {
                if (result.NumericResult != null)
                {
                    return(RteFloatValue((float)result.NumericResult));
                }
            }
            break;

            default:
                break;
            }
            return(null);
        }
コード例 #3
0
        private bool CanCloseDocument(bool askForSaveLocation)
        {
            if (DocumentStatus == IgExcelDocumentStatus.NoDocumentLoaded ||
                DocumentStatus == IgExcelDocumentStatus.BlankNotModified ||
                DocumentStatus == IgExcelDocumentStatus.TemplateNotModified ||
                DocumentStatus == IgExcelDocumentStatus.ExistingNotModified)
            {
                return(true);
            }

            InteractionResult msgCloseResult = InteractionResult.Cancel;

            if (DocumentStatus == IgExcelDocumentStatus.BlankModified || DocumentStatus == IgExcelDocumentStatus.ExistingModified)
            {
                var tempDocumentName = string.Format(ResourceStrings.ResourceStrings.Text_TempDocumentName, 1);
                msgCloseResult = this.messageBoxService.Show(ResourceStrings.ResourceStrings.Text_ApplicationTitle, string.Format(ResourceStrings.ResourceStrings.Msg_WantToSaveChanges, tempDocumentName), MessageBoxButtons.YesNoCancel);
            }
            else
            {
                msgCloseResult = this.messageBoxService.Show(ResourceStrings.ResourceStrings.Text_ApplicationTitle, string.Format(ResourceStrings.ResourceStrings.Msg_WantToSaveChanges, fileName), MessageBoxButtons.YesNoCancel);
            }

            if (msgCloseResult == InteractionResult.Cancel)
            {
                return(false);
            }

            if (msgCloseResult == InteractionResult.No)
            {
                ClearDataProperties();
                return(true);
            }

            if (msgCloseResult == InteractionResult.Yes)
            {
                if (askForSaveLocation)
                {
                    string fileNameTemp;
                    var    filters = ShellParameters.FileDialogFilter;
                    dialogService.ShowSaveFileDialog(string.Empty, out fileNameTemp, filters);
                    ClearDataProperties();
                    return(true);
                }
                else
                {
                    ExecuteSaveDocument();
                    closeRequested = true;
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
 public InteractionResult Harvest()
 {
     if (plant != null)
     {
         InteractionResult res = plant.Harvest(fruitParent);
         if (res.destroyed)
         {
             planterReg.DeregisterPlant(plant);
             plant = null;
         }
         return(res);
     }
     return(new InteractionResult(null, false));
 }
コード例 #5
0
        static void Main(string[] args)
        {
            while (Console.ReadLine() != "end")
            {
                var wrapper = new BiometricDeviceController();
                var output  = new InteractionResult();
                // enter a unsafe block
                unsafe
                {
                    // initialise
                    wrapper.Initialise(new HFVBSBiometricDeviceConfigurationData());
                    Console.WriteLine("Please type one of the following commands to perform the action:");
                    Console.WriteLine("ENROLL");
                    Console.WriteLine("IDENTIFY");
                    Console.WriteLine("VERIFY");
                    Console.WriteLine("Press Enter To run the command once finished typing");

                    var command = Console.ReadLine();
                    if (!string.IsNullOrEmpty(command))
                    {
                        switch (command.ToUpper())
                        {
                        case "ENROLL":
                            output = wrapper.Enroll();
                            break;

                        case "IDENTIFY":
                            output = wrapper.Identify();
                            break;

                        case "VERIFY":
                            output = wrapper.Verify();
                            break;

                        default:
                            Console.WriteLine("ERROR: INVALID COMMAND {UNKNOWN}:" + command);

                            output = wrapper.CancelOperations();
                            break;
                        }
                    }
                }

                Console.Write(output.Data.ToString());
                //Console.Read();
            }
        }
コード例 #6
0
    public bool InteractWithInteractable(Interactable i)
    {
        InteractionResult result = null;

        if (curCarrying)
        {
            result = curCarrying.InteractWith(i);
        }
        else
        {
            result = InteractWith(i);
        }
        Carry(result.carryable);
        FeedBack(result.success);
        ChangeColor();
        return(true);
    }
コード例 #7
0
        public InteractionResult ShowError(string body, Exception exception, InteractionResult buttons = InteractionResult.Close)
        {
#if DEBUG
            var extended = exception.ToString();
#else
            string extended = body != exception.Message ? exception.Message : null;
            if (exception.InnerException != null)
            {
                if (!string.IsNullOrEmpty(extended))
                {
                    extended += System.Environment.NewLine;
                    extended += exception.GetBaseException().Message;
                }
            }
#endif

            return(this.ShowError(body, buttons, extendedInfo: extended));
        }
コード例 #8
0
        /// <summary>
        /// Check the object. <see cref="InteractionResult{T}.Error.Message"/> == "Not Found" when it doesnt exist. Otherwise you will get the <see cref="FileSystemObject"/>
        /// </summary>
        /// <param name="path">The object to check</param>
        /// <returns>The matching <see cref="FileSystemObject"/></returns>
        public InteractionResult <FileSystemObject> GetObject(string path)
        {
            InteractionResult <List <FileSystemObject> > filesRes = this.GetObjectsFromDir(path.GetUpperPathAndroid());

            if (!filesRes.WasSuccessful)
            {
                return(new InteractionResult <FileSystemObject>(null, false, filesRes.Error));
            }

            foreach (FileSystemObject fso in filesRes.Result)
            {
                if (fso.Path.Equals(path))
                {
                    return(new InteractionResult <FileSystemObject>(fso, true, null));
                }
            }

            return(new InteractionResult <FileSystemObject>(null, false, new Exception("Not Found")));
        }
コード例 #9
0
    IEnumerator EnemyStep()
    {
        Debug.Log("***ENEMY ACTIVATION STEP");
        var im = FindObjectOfType <InteractionManager>();
        var fm = FindObjectOfType <FightManager>();
        var mm = FindObjectOfType <MonsterManager>();

        Monster[] monsters = mm.monsterList.ToArray();
        bool      waiting  = true;

        //foreach ( var monster in monsters )
        for (int i = 0; i < monsters.Length; i++)
        {
            mm.UnselectAll();

            if (monsters[i].isExhausted || monsters[i].isStunned)
            {
                continue;
            }

            Debug.Log("***MONSTER ACTIVATING");
            yield return(new WaitForSeconds(1));

            //yield return fm.MonsterStep( monsters[i] );

            //snip below
            string            heroName = Bootstrap.GetRandomHero();
            InteractionResult iResult  = null;
            //select monster button group
            mm.SelectMonster(monsters[i], true);
            //ask if it can move and attack
            waiting            = true;
            allowAttacks       = true;
            allowedMonsterGUID = monsters[i].GUID;
            var tp = im.GetNewTextPanel();

            //Move X: Attack NAME (or closest Hero)
            //buttons: Attack/No Target
            doInterrupt = false;
            tp.ShowYesNo($"Move {monsters[i].movementValue}: Attack {heroName} or closest Hero.\r\n\r\nCan this enemy group attack a target?\r\n\r\nIf you have a skill to attack or apply damage to this enemy group, do it now by selecting its Enemy Button.", res =>
            {
                waiting = false;
                iResult = res;
            });
            //wait
            //int startingActive = monsters[i].ActiveMonsterCount;
            while (waiting)
            {
                if (monsters[i].ActiveMonsterCount == 0 ||
                    (!monsters[i].isElite && monsters[i].isExhausted) ||
                    (monsters[i].isElite && monsters[i].isStunned ||
                     doInterrupt)
                    /*|| monsters[i].ActiveMonsterCount < startingActive*/)                     //something died
                {
                    tp.RemoveBox();
                    waiting = false;
                }
                yield return(null);
            }

            allowAttacks = false;

            //if group was just removed from an interruption, wait until reward and any OnDefeated Events are complete
            yield return(new WaitForSeconds(.25f));

            yield return(WaitUntilFinished());

            //check if monster group is dead/exhausted and abort this monter's attack if needed
            if (monsters[i].ActiveMonsterCount == 0 ||
                (!monsters[i].isElite && monsters[i].isExhausted) ||
                (monsters[i].isElite && monsters[i].isStunned) ||
                doInterrupt)
            {
                tp.RemoveBox();
                waiting = true;
                im.GetNewTextPanel().ShowOkContinue($"This enemy group's activation is canceled.", ButtonIcon.Continue, () => { waiting = false; });
                while (waiting)
                {
                    yield return(null);
                }
            }
            else
            {
                if (iResult.btn1)                  //yes, attack
                {
                    Debug.Log("***YES ATTACK");
                    waiting = true;
                    im.GetNewDamagePanel().ShowCombatCounter(monsters[i], () => waiting = false);
                    //wait
                    while (waiting)
                    {
                        yield return(null);
                    }
                    //exhaust the enemy
                    mm.ExhaustMonster(monsters[i], true);
                }
                else
                {
                    Debug.Log("***NO ATTACK");
                    waiting = true;
                    im.GetNewTextPanel().ShowOkContinue($"Move {monsters[i].dataName} group {monsters[i].movementValue * 2} spaces towards {heroName}.", ButtonIcon.Continue, () => waiting = false);
                    //wait
                    while (waiting)
                    {
                        yield return(null);
                    }
                    //exhaust the enemy
                    mm.ExhaustMonster(monsters[i], true);
                }
            }
        }

        mm.UnselectAll();
    }
コード例 #10
0
    private void Update()
    {
        Vector3 uV = new Vector3(0.0f, -1.0f, 0.0f);

        Ray ray = new Ray(transform.position, transform.forward);

        if (pI.IsStrafingRight)
        {
            ray = new Ray(transform.position, Quaternion.AngleAxis(
                              90, transform.forward) * uV);
        }
        else if (pI.IsStrafingLeft)
        {
            ray = new Ray(transform.position, Quaternion.AngleAxis(
                              -90, transform.forward) * uV);
        }
        else if (pI.IsWalkingBack)
        {
            ray = new Ray(transform.position, -transform.forward);
        }

        IsColliding = Physics.Raycast(ray, out currentWorldObject,
                                      pI.MoveDistance, ~0, QueryTriggerInteraction.Ignore);


        if (!pI.CanInput)
        {
            if (pI.Bump)
            {
                GameObject temp = currentWorldObject.transform?.gameObject;
                temp?.GetComponent <BreakingWall>()?.Break();
            }

            return;
        }

        if (IsColliding)
        {
            // Definetly change this to do it one time.
            ObjectTouched = currentWorldObject.transform.gameObject;
            // This could be better
            if ((ObjectTouched.layer == 8) || (ObjectTouched.layer == 9))
            {
                objectHolder = ObjectTouched.GetComponent <DataHolder>();
                objectData   = objectHolder?.GetData(inventory.equipedItem);

                mD.DisplayMessage(objectData);
            }
        }

        else
        {
            IsColliding   = false;
            objectData    = null;
            ObjectTouched = null;
            mD.CleanMessage();
        }

        if ((ObjectTouched != null) &&
            !pI.IsStrafingLeft && !pI.IsStrafingRight)
        {
            if (!pI.IsWalking && pI.IsInteracting && IsColliding)
            {
                if (objectData == null)
                {
                    return;
                }

                switch (objectData.InteractionType)
                {
                case InteractionType.isGrabable:
                    inventory.AddItem(objectData as ItemData);
                    objectHolder.DestroyObject();
                    mD.CleanMessage();
                    objectData = null;
                    break;

                case InteractionType.isUsable:
                    interactor =
                        ObjectTouched.GetComponent <ManualInteractor>();

                    InteractionResult itemused =
                        interactor.Toggle(
                            inventory?.equipedItem, transform.position);

                    switch (itemused)
                    {
                    case InteractionResult.WrongIntMessage:
                        StartDialogue(wrongInteaction);
                        break;

                    case InteractionResult.UseItem:
                        inventory.ClearEquiped();
                        break;
                    }
                    break;

                case InteractionType.isExit:
                    interactor =
                        ObjectTouched.GetComponent <ManualInteractor>();
                    interactor.Toggle(
                        inventory?.equipedItem, transform.position);
                    break;

                case InteractionType.isNPC:
                    StartDialogue((objectData as NpcData).Dialogue);
                    break;

                default:
                    print("Porque é que essa coisa é trigger ?");
                    break;
                }
            }

            pI.IsInteracting = false;
        }
    }
コード例 #11
0
 public DialogClosedEventArgs(InteractionResult result)
 {
     Result = result;
 }
コード例 #12
0
ファイル: Change.cs プロジェクト: rusticgames/rts
 void Reset()
 {
     manualResult = InteractionResult.NONE;
     results = new HashSet<InteractionResult>();
     me = this.gameObject;
 }
コード例 #13
0
 /// <summary>
 /// Helper function to get the cmi.interactions.n.result value
 /// </summary>
 public abstract string GetRteResult(InteractionResult result);
コード例 #14
0
        public int ShowMessage(string body, IReadOnlyCollection <string> buttons, string title = null, string extendedInfo = null, InteractionResult systemButtons = InteractionResult.None)
        {
            var taskDialog = new TaskDialog
            {
                MainIcon    = TaskDialogIcon.Information,
                ButtonStyle = TaskDialogButtonStyle.CommandLinks
            };

            foreach (var item in buttons)
            {
                var btn = new TaskDialogButton(ButtonType.Custom)
                {
                    Text = item
                };

                taskDialog.Buttons.Add(btn);
            }

            if (systemButtons != InteractionResult.None)
            {
                var bts = new[] { InteractionResult.Yes, InteractionResult.No, InteractionResult.OK, InteractionResult.Cancel, InteractionResult.Close };
                foreach (var bt in bts)
                {
                    if ((systemButtons & bt) == bt)
                    {
                        taskDialog.Buttons.Add(new TaskDialogButton((ButtonType)(int)bt));
                    }
                }
            }

            taskDialog.CenterParent = true;
            taskDialog.Content      = body;

            if (!string.IsNullOrEmpty(extendedInfo))
            {
                taskDialog.ExpandedInformation = extendedInfo;
            }

            taskDialog.WindowTitle = title ?? "MSIX Hero";

            int clickedIndex = -1;
            // ReSharper disable once ConvertToLocalFunction
            EventHandler <TaskDialogItemClickedEventArgs> handler = (_, args) =>
            {
                var taskDialogButton = args.Item as TaskDialogButton;
                if (taskDialogButton == null)
                {
                    return;
                }

                clickedIndex = taskDialog.Buttons.IndexOf(taskDialogButton);
            };

            try
            {
                taskDialog.ButtonClicked += handler;

                if (this.context == null)
                {
                    taskDialog.ShowDialog(GetActiveWindow());
                }

                var dispatcher = Application.Current.Dispatcher;
                if (dispatcher != null)
                {
                    dispatcher.Invoke(() =>
                    {
                        this.context.Send(
                            _ => taskDialog.ShowDialog(GetActiveWindow()),
                            null);
                    },
                                      DispatcherPriority.SystemIdle);
                }
            }
            finally
            {
                taskDialog.ButtonClicked -= handler;
            }

            return(clickedIndex);
        }
コード例 #15
0
    private void OnDirectionPressed(Direction direction)
    {
        bool anyEntityShifted = true;

        Vector2Int directionVector = directionVectors[direction];

        IterateOverGrid(direction, (x, y, entity) =>
        {
            Vector2Int shiftedIndeces = new Vector2Int(x + directionVector.x, y + directionVector.y);

            bool positionValid           = IsPositionValid(shiftedIndeces.x, shiftedIndeces.y);
            EntityBase shiftTargetEntity = positionValid ? Grid[shiftedIndeces.x, shiftedIndeces.y] : null;

            bool shiftSpaceEmpty = positionValid &&
                                   shiftTargetEntity == null;
            if (entity != null && shiftSpaceEmpty && entity.movedThisTurn == false)
            {
                anyEntityShifted = true;
                MoveEntityToIndeces(entity, shiftedIndeces.x, shiftedIndeces.y, true);
                entity.movedThisTurn = true;
            }
            else if (entity != null && positionValid && shiftTargetEntity != null)
            {
                InteractionResult result = InteractionSystem.Handle(entity, shiftTargetEntity);


                switch (result)
                {
                case InteractionResult.NONE:
                    InteractionResult swappedResult = InteractionSystem.Handle(shiftTargetEntity, entity);
                    switch (swappedResult)
                    {
                    case InteractionResult.TARGET_DEATH:
                        entity.Die();
                        break;

                    case InteractionResult.ACTOR_DEATH:
                        shiftTargetEntity.Die();
                        break;
                    }
                    break;

                case InteractionResult.TARGET_DEATH:
                    shiftTargetEntity.Die();
                    break;

                case InteractionResult.ACTOR_DEATH:
                    entity.Die();
                    break;
                }

                if (entity != null && entity.morphingInto.HasValue)
                {
                    entity.Die();
                }
                else if (shiftTargetEntity != null && shiftTargetEntity.morphingInto.HasValue)
                {
                }
            }
        });

        IterateOverGrid(direction, (x, y, e) =>
        {
            if (e != null)
            {
                e.movedThisTurn = false;
            }
        });

        if (anyEntityShifted)
        {
            //Get cell for spawn
            List <Vector2Int> emptyEdgeCells = GetEdgeCellsForDirection(direction);

            if (emptyEdgeCells.Count == 0)
            {
                ResetGrid();
            }
            else
            {
                Vector2Int emptyCell = emptyEdgeCells[UnityEngine.Random.Range(0, emptyEdgeCells.Count)];

                EntityType randomEntityType = autspawnEntities[UnityEngine.Random.Range(0, autspawnEntities.Length)];
                CreateNewEntity(randomEntityType, emptyCell.x, emptyCell.y);
            }
        }
    }
コード例 #16
0
 public DialogClosedEventArgs(InteractionResult result, object viewModel)
 {
     Result    = result;
     ViewModel = viewModel;
 }
コード例 #17
0
 /// <summary>
 /// Helper function to get the cmi.interactions.n.result value
 /// </summary>
 public abstract string GetRteResult(InteractionResult result);
コード例 #18
0
        public InteractionResult ShowInfo(string body, InteractionResult buttons = InteractionResult.Close, string title = null, string extendedInfo = null)
        {
            var taskDialog = new TaskDialog
            {
                MainIcon    = TaskDialogIcon.Information,
                ButtonStyle = TaskDialogButtonStyle.Standard
            };

            if (buttons.HasFlag(InteractionResult.Retry))
            {
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Retry));
            }

            if (buttons.HasFlag(InteractionResult.OK))
            {
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Ok));
            }

            if (buttons.HasFlag(InteractionResult.Yes))
            {
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Yes));
            }

            if (buttons.HasFlag(InteractionResult.No))
            {
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.No));
            }

            if (buttons.HasFlag(InteractionResult.Cancel))
            {
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Cancel));
            }

            if (buttons.HasFlag(InteractionResult.Close))
            {
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Close));
            }

            taskDialog.CenterParent = true;
            taskDialog.Content      = body;

            if (!string.IsNullOrEmpty(extendedInfo))
            {
                taskDialog.ExpandedInformation = extendedInfo;
            }

            taskDialog.WindowTitle = title ?? "MSIX Hero";

            if (this.context == null)
            {
                return((InteractionResult)(int)taskDialog.ShowDialog(GetActiveWindow()).ButtonType);
            }

            var result = 0;

            var dispatcher = Application.Current.Dispatcher;

            if (dispatcher != null)
            {
                dispatcher.Invoke(() =>
                {
                    this.context.Send(
                        _ => result = (int)taskDialog.ShowDialog(GetActiveWindow()).ButtonType,
                        null);
                },
                                  DispatcherPriority.SystemIdle);
            }

            return((InteractionResult)result);
        }
コード例 #19
0
ファイル: Change.cs プロジェクト: rusticgames/rts
 public void addChange(InteractionResult r)
 {
     results.Add(r);
 }
コード例 #20
0
        public bool CanCloseDialog()
        {
            InteractionResult msgCloseResult = InteractionResult.None;

            if (!_isDirty && !ActiveContact.HasErrors())
            {
                return(true);
            }

            if (!_isDirty && _isNewContact && !_closeRequested)
            {
                return(true);
            }

            if (_closeRequested)
            {
                msgCloseResult = _saveChanges ? InteractionResult.Yes : InteractionResult.No;
            }
            else
            {
                msgCloseResult = _messageBoxService.Show("IG Outlook", ResourceStrings.SaveChangesMessage_Text, MessageBoxButtons.YesNoCancel);
            }

            if (msgCloseResult == InteractionResult.Cancel)
            {
                _saveChanges = false;
                return(false);
            }
            else
            {
                _saveChanges = msgCloseResult == InteractionResult.Yes;

                if (_saveChanges)
                {
                    InteractionResult msgInvalidDataResult = InteractionResult.None;

                    if (ActiveContact.HasErrors())
                    {
                        msgInvalidDataResult = _messageBoxService.Show("IG Outlook", ResourceStrings.InvalidContactDataMessage_Text, MessageBoxButtons.YesNo);
                    }

                    if (msgInvalidDataResult == InteractionResult.No)
                    {
                        return(true);
                    }
                    else
                    {
                        if (_isNewContact)
                        {
                            ContactService.AddContact(ActiveContact);
                            return(true);
                        }
                    }

                    ContactService.UpdateContact(ActiveContact);
                    EventAggregator.GetEvent <ContactUpdatedEvent>().Publish(ActiveContact);
                }

                return(true);
            }
        }
コード例 #21
0
 /// <summary>
 /// Helper function to get the cmi.interactions.n.result value
 /// </summary>
 public override string GetRteResult(InteractionResult result)
 {
     switch (result.State)
     {
         case InteractionResultState.Correct:
             return "correct";
         case InteractionResultState.Incorrect:
             return "incorrect";
         case InteractionResultState.Neutral:
             return "neutral";
         case InteractionResultState.Unanticipated:
             return "unanticipated";
         case InteractionResultState.Numeric:
             {
                 if (result.NumericResult != null)
                 {
                     return RteFloatValue((float)result.NumericResult);
                 }
             }
             break;
         default:
             break;
     }
     return null;
 }
コード例 #22
0
ファイル: Interaction.cs プロジェクト: rusticgames/rts
 public void logInteraction(InteractionResult r, GameObject g)
 {
     Debug.LogWarning ("<" + this + "> performing <" + r + "> because of <" + g + ">");
 }