public Roam(Vector3 minRange, Vector3 maxRange) { Children = new Task[2]; Children[0] = new ChooseAndSetNewDestination(minRange, maxRange); Children[1] = new MoveToPosition(); }
void Awake() { aStar = GameObject.Find ("A*").GetComponent<AStar> (); moveToPosition = GetComponent<MoveToPosition> (); }
private void OnEnable() { moveToPosition = (MoveToPosition)target; }
/// <summary> /// Take current active window and place it in left or right 3rd of screen area. /// </summary> /// <param name="centerPercentageOfTotalWidth">Percentage of total width to use when moving window, default is 34, with suggested alternatives being 36-38-40.</param> /// <param name="topBottomBorder">Number of pixels to use as border across top and bottom, default is 0.</param> /// <param name="screenPostions">defines type of screen positions scenario to base action on, default is LeftCenterRight.</param> public void PlaceActiveWindowPosition(ArrangeDirection arrangeDirection, int centerPercentageOfTotalWidth = 34, int topBottomBorder = 0, ScreenPositions screenPositions = ScreenPositions.LeftCenterRight) { //if (arrangeDirection == ArrangeDirection.Up || arrangeDirection == ArrangeDirection.Down) //{ // throw new ApplicationException("unsupported arrange direction specified"); //} var awh = GetActiveWindowHandle(); // if you resize active window that is currently in SW_MAXIMIZE state it ends up not resizing it at all, e.g. in case of chrome, or // resizing it but with an appx 7px space across top and bottom of window and if you minimize it and then restore it comes back as // SW_MAXIMIZE state not expected SW_SHOW[NORMAL] state. so we check for SW_MAXIMIZE state and change to SW_SHOW[NORMAL] before // resizing /* if (!IsWindowInNormalState(awh)) */ PutWindowIntoNormalState(awh); var primaryScreen = Screen.PrimaryScreen; //#if DEBUG // var allScreens = Screen.AllScreens; var heightOfTaskbar = primaryScreen.Bounds.Bottom - primaryScreen.WorkingArea.Bottom; //#endif //var sr = GetScreenRectangle(); // doesn't account for taskbar which you'd have to hardcode depending on display | scale and layout | size of . . . + resolution settings var sr = primaryScreen.WorkingArea; // accounts for taskbar // splitting screen into 3rds is always going to require center 3rd to be rounded up to even number to end up with integer/whole numbers for left and right 3rds var centerWindowSize = (sr.Right - sr.Left) * centerPercentageOfTotalWidth / 100; var leftRightPercentageOfTotalWidth = (100 - centerPercentageOfTotalWidth) / 2; var leftRightWindowSize = (sr.Right - sr.Left) * leftRightPercentageOfTotalWidth / 100; //var centerWindowSize = (sr.Right - sr.Left) - (leftRightWindowSize * 2); var position = new Rect() { Top = sr.Top + topBottomBorder }; position.Bottom = sr.Bottom - topBottomBorder - position.Top; // change in y not absolution y position MoveToPosition mtp = GetMoveToPosition(arrangeDirection, sr, centerWindowSize, leftRightWindowSize, screenPositions); if (mtp == MoveToPosition.Left) { position.Left = 0; position.Right = leftRightWindowSize; // change in x not absolution x position } else if (mtp == MoveToPosition.LeftTwoThirds) { position.Left = 0; position.Right = leftRightWindowSize + centerWindowSize; // change in x not absolution x position } else if (mtp == MoveToPosition.Center) { position.Left = sr.Left + leftRightWindowSize; //position.Left = sr.Right - leftRightWindowSize - centerWindowSize; // alternative calculation position.Right = centerWindowSize; // change in x not absolution x position } else if (mtp == MoveToPosition.RightTwoThirds) { position.Left = sr.Right - leftRightWindowSize - centerWindowSize; //position.Left = sr.Left + leftRightWindowSize; // alternative calculation position.Right = centerWindowSize + leftRightWindowSize; // change in x not absolution x position } else if (mtp == MoveToPosition.Right) { position.Left = sr.Right - leftRightWindowSize; //position.Left = sr.Left + leftRightWindowSize + centerWindowSize; // alternative calculation position.Right = leftRightWindowSize; // change in x not absolution x position } // here is a a couple ways to add/subtract from top/bottom position settings in special app cases or uwp vs desktop app cases //var awt = GetActiveWindowTitle(); //if (awt.EndsWith("- Special App Case 1") || awt.EndsWith("- Special App Case 2")) position.Bottom += 7; //var awh = GetActiveWindowHandle(); // this approach throws exceptions in IsUwpApp cases not seen in unit test runs that needs to be debugged //foreach (var process in Process.GetProcesses()) { if (process.MainWindowHandle == awh && process.IsUwpApp()) { position.Bottom += 7; break; } } SetActiveWindowPosition(position.Left, position.Top, position.Right, position.Bottom); }
private bool GraphDeconstruct(DialogueContainer input) { while (!string.IsNullOrEmpty(currentGUID) && !textboxWait) { //Dialogue Node if (input.DialogueNodeData.Any(x => x.Guid == currentGUID)) { DialogueNodeData node = input.DialogueNodeData.First(x => x.Guid == currentGUID); textboxWait = true; SayDialogue dialogueCutscene = ScriptableObject.CreateInstance <SayDialogue>(); if (!string.IsNullOrEmpty(node.TargetPlayer)) { dialogueCutscene.speakerName = node.TargetPlayer; } else { dialogueCutscene.speakerName = speakerName; } dialogueCutscene.inputText = new TextAsset(node.DialogueText); dialogueCutscene.currentLinks = input.NodeLinks.Where(x => x.BaseNodeGuid == currentGUID).ToList(); dialogueCutscene.deconstructerSource = this; CutsceneController.addCutsceneEvent(dialogueCutscene, cutsceneSource, true, GameDataTracker.cutsceneModeOptions.Cutscene); continue; } //Animation Trigger if (input.AnimationTriggerNodeData.Any(x => x.Guid == currentGUID)) { AnimationTriggerNodeData node = input.AnimationTriggerNodeData.First(x => x.Guid == currentGUID); AnimationTriggerCutscene animationTriggerCutscene = ScriptableObject.CreateInstance <AnimationTriggerCutscene>(); animationTriggerCutscene.TriggerName = node.TriggerName; animationTriggerCutscene.TargetName = node.TargetPlayer; CutsceneController.addCutsceneEvent(animationTriggerCutscene, cutsceneSource, false, GameDataTracker.cutsceneModeOptions.Cutscene); currentGUID = FindNextNode(input, currentGUID); continue; } //Set Flag if (input.SetFlagNodeData.Any(x => x.Guid == currentGUID)) { SetFlagNodeData SetFlagNode = input.SetFlagNodeData.First(x => x.Guid == currentGUID); string FlagName = SetFlagNode.FlagName; string FlagTag = SetFlagNode.FlagTag; if (GameDataTracker.stringFlags.ContainsKey(FlagName)) { GameDataTracker.stringFlags[FlagName] = FlagTag; } else { GameDataTracker.stringFlags.Add(FlagName, FlagTag); } currentGUID = FindNextNode(input, currentGUID); continue; } //Get Flag if (input.GetFlagNodeData.Any(x => x.Guid == currentGUID)) { GetFlagNodeData GetFlagNode = input.GetFlagNodeData.First(x => x.Guid == currentGUID); string FlagName = GetFlagNode.FlagName; if (GameDataTracker.stringFlags.ContainsKey(FlagName)) { string FlagTag = GameDataTracker.stringFlags[FlagName]; if (input.NodeLinks.Any(x => x.PortName == FlagTag)) { currentGUID = input.NodeLinks.First(x => x.PortName == FlagTag && x.BaseNodeGuid == currentGUID).TargetNodeGuid; } else { currentGUID = input.NodeLinks.First(x => x.PortName == "Other" && x.BaseNodeGuid == currentGUID).TargetNodeGuid; } } else { currentGUID = input.NodeLinks.First(x => x.PortName == "Other" && x.BaseNodeGuid == currentGUID).TargetNodeGuid; } continue; } //Boolean Set Flag if (input.BooleanSetFlagNodeData.Any(x => x.Guid == currentGUID)) { BooleanSetFlagNodeData BooleanSetFlagNode = input.BooleanSetFlagNodeData.First(x => x.Guid == currentGUID); string FlagName = BooleanSetFlagNode.FlagName; bool FlagBool = BooleanSetFlagNode.FlagBool; if (GameDataTracker.boolFlags.ContainsKey(FlagName)) { GameDataTracker.boolFlags[FlagName] = FlagBool; } else { GameDataTracker.boolFlags.Add(FlagName, FlagBool); } currentGUID = FindNextNode(input, currentGUID); continue; } //Boolean Get Flag if (input.BooleanGetFlagNodeData.Any(x => x.Guid == currentGUID)) { BooleanGetFlagNodeData BooleanGetFlagNode = input.BooleanGetFlagNodeData.First(x => x.Guid == currentGUID); string FlagName = BooleanGetFlagNode.FlagName; if (GameDataTracker.boolFlags.ContainsKey(FlagName)) { bool FlagBool = GameDataTracker.boolFlags[FlagName]; if (FlagBool) { currentGUID = input.NodeLinks.First(x => x.PortName == "True" && x.BaseNodeGuid == currentGUID).TargetNodeGuid; } else { currentGUID = input.NodeLinks.First(x => x.PortName == "False" && x.BaseNodeGuid == currentGUID).TargetNodeGuid; } } else { currentGUID = input.NodeLinks.First(x => x.PortName == "Other" && x.BaseNodeGuid == currentGUID).TargetNodeGuid; } continue; } //Move To Position if (input.MoveToPosNodeData.Any(x => x.Guid == currentGUID)) { MoveToPosNodeData MoveToPosNode = input.MoveToPosNodeData.First(x => x.Guid == currentGUID); string TargetObject = MoveToPosNode.TargetObject; string ReferenceObject = MoveToPosNode.ReferenceObject; bool Wait = MoveToPosNode.Wait; Vector3 Offset = MoveToPosNode.PosOffset; MoveToPosition moveToPosition = ScriptableObject.CreateInstance <MoveToPosition>(); moveToPosition.PositionOffset = Offset; moveToPosition.ReferenceObject = ReferenceObject; moveToPosition.TargetObject = TargetObject; moveToPosition.Wait = Wait; CutsceneController.addCutsceneEvent(moveToPosition, cutsceneSource, true, GameDataTracker.cutsceneModeOptions.Cutscene); currentGUID = FindNextNode(input, currentGUID); continue; } } if (!textboxWait && string.IsNullOrEmpty(currentGUID)) { done = true; return(true); } return(false); }
/// <summary> /// Get the Move to Position component /// </summary> void Awake() { mMoveToPosition = GetComponent <MoveToPosition>(); }