private void TestUpdate(Action <Server, Server, HintSet> update, bool useHints) { var s1 = Clone(srv); var s2 = Clone(srv); var hints = new HintSet(s1, s2); update.Invoke(s1, s2, hints); if (!useHints) { hints = new HintSet(s1, s2); } TestLog.Info("Update test ({0} hints)", useHints ? "with" : "without"); // s1.Dump(); // s2.Dump(); s1.Validate(); s2.Validate(); // Comparing different models TestLog.Info("Comparing models:"); var comparer = new Comparer(); var diff = comparer.Compare(s1, s2, hints); TestLog.Info("\r\nDifference:\r\n{0}", diff); var actions = new ActionSequence() { new Upgrader().GetUpgradeSequence(diff, hints, comparer) }; TestLog.Info("\r\nActions:\r\n{0}", actions); }
/// <summary> /// Uses a collection of HMMs to recognize which action among a corpus of actions was performed /// </summary> /// <param name="action">The motion sequence representing the action</param> /// <returns></returns> public Tuple<string, double> recognizeAction(ActionSequence<HumanSkeleton> action) { // Compute most likely position action double[] likelihoods = new double[positionActionClassifier.Classes]; int cls = positionActionClassifier.Compute(action.toArray(), out likelihoods); double maxPositionLikelihood = likelihoods.Max(); //maxPositionLikelihood = 0; // Compute most likely joint action likelihoods = new double[jointActionClassifier.Classes]; int jointCls = jointActionClassifier.Compute(action.toArray(true), out likelihoods); double maxJointLikelihood = likelihoods.Max(); double maxLikelihood = Math.Max(maxJointLikelihood, maxPositionLikelihood); if (maxLikelihood < 1e-300 || (jointCls == -1 && cls == -1)) { return Tuple.Create("", maxLikelihood); } // And return the one which is more likely among the two if (maxJointLikelihood > maxPositionLikelihood) { return Tuple.Create(jointClasses[jointCls], maxJointLikelihood); } else { return Tuple.Create(positionClasses[cls], maxPositionLikelihood); } }
void Start () { SetButtons(); buttonSequence = new ActionSequence(); AttackButton.IsEnabled = false; InitActionButtons(new int[] { 1, 2, 5 }); //For Testing }
/// <summary> /// Ajoute un paramètre dans l'action d'une séquence d'action. /// </summary> /// <param name="actionParameter">ActionParameter à ajouter</param> /// <param name="actionSequenceId">Id de la séquence d'action cible</param> /// <returns>Message de retour</returns> public async Task <ActionParameter> AddActionParameter(ActionParameter actionParameter, long actionSequenceId) { if (actionParameter == null) { throw new WrongParameterException("ActionSequenceDomain.AddAction : ActionParameter is null."); } ActionSequence actionSequence = await UnitOfWork.GetDbContext().ActionSequence .Where(aseq => aseq.Id == actionSequenceId) .FirstOrDefaultAsync(); if (actionSequence == null) { throw new WrongParameterException($"ActionSequenceDomain.AddAction : ActionSequence don't exist with id = {actionSequenceId}."); } UnitOfWork.ActionParameterRepository.PrepareAddForObject(actionParameter); actionParameter.ReferenceSequence = actionSequence.Reference; actionParameter.OrderSequence = actionSequence.Order; int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync(); if (nbr <= 0) { throw new DatabaseException("ActionSequenceDomain.AddAction : Impossible to save ActionParameter."); } return(actionParameter); }
void HandleMovement() { var canMove = m_CanMove && !m_Boosting; if (!canMove) { return; } var movementInput = m_InputAxis; var grounded = m_Grounded; var xDelta = Mathf.Abs(transform.position.x - m_PreviousX); var noActiveSequences = !m_LandingSquashSequence.Active && !m_FrontSquashSequence.Active && !m_HopSequence.Active; if (grounded && xDelta > 0 && noActiveSequences) { var normalizedDelta = (xDelta / Time.deltaTime) / m_MovementSpeed; var height = m_HopHeight * normalizedDelta; var duration = (m_HopDuration / 2) * Mathf.Sqrt(normalizedDelta); m_HopSequence = ActionMaster.Actions.Sequence(); m_HopSequence.MoveLocalY(m_HopNode.gameObject, m_HopDefaultY + height, duration, new Ease(Ease.Quad.Out)); m_HopSequence.MoveLocalY(m_HopNode.gameObject, m_HopDefaultY, duration, new Ease(Ease.Quad.In)); } HandleFacing(movementInput); var velocity = m_Rigidbody2D.velocity; velocity.x = movementInput * m_MovementSpeed; m_Rigidbody2D.velocity = velocity; }
public void TestExecuteActions() { ActionSequence sequence = new ActionSequence(); // stage StageForTest stage = new StageForTest() { moveLimit = 1 }; // action StageActionForTest action = new StageActionForTest(); stage.Register(action); // sequence for (int i = 0; i < 2; i++) { sequence.Register(action); } Assert.AreEqual(stage.moveLimit, 1); // should execute sequence.NextAction(); Assert.AreEqual(stage.moveLimit, 0); // should not sequence.NextAction(); sequence.UndoAction(); Assert.AreEqual(stage.moveLimit, 1); }
void Die() { if (m_Dead) { return; } GlobalData.DispatchHeroDied(); m_Dead = true; m_CanMove = false; m_CanJump = false; m_Rigidbody2D.freezeRotation = false; var velocity = m_Rigidbody2D.velocity; velocity.y = m_DeathVelocity; m_Rigidbody2D.velocity = velocity; var angularVelocity = m_FacingLeft ? m_DeathAngularVelocity : -m_DeathAngularVelocity; m_Rigidbody2D.angularVelocity = angularVelocity; if (m_Boosting) { EndBoosting(); } m_DeathSequence.Cancel(); m_DeathSequence = ActionMaster.Actions.Sequence(); m_DeathSequence.SpriteAlpha(m_BodySpriteRenderer.gameObject, 0, m_DeathPreDelay, new Ease(Ease.Quad.Out)); m_DeathSequence.Call(Return, gameObject); m_DeathSequence.Delay(m_DeathPostDelay); m_DeathSequence.Call(RegainControl, gameObject); }
public static void TolstoyRomantic(Entity main, Entity other, out ActionSequence mainActionSequence, out ActionSequence otherActionSequence) { mainActionSequence = new ActionSequence("TolstoyRomanticOneMain"); otherActionSequence = new ActionSequence("TolstoyRomanticOneOther"); var ordering = CommonActions.GoToPaypointAndOrderDrink(main, DrinkRecipes.GetRandomDrinkRecipe()); mainActionSequence.Add(ordering); var talkToPlayer = CommonActions.TalkToPlayer(new TolstoyOneDialogue()); mainActionSequence.Add(talkToPlayer); otherActionSequence.Add(CommonActions.Wander()); var sync = new SyncedAction(main, other); mainActionSequence.Add(sync); otherActionSequence.Add(sync); mainActionSequence.Add(new SetTargetEntityAction(other)); mainActionSequence.Add(new GoToMovingEntityAction()); otherActionSequence.Add(new SetTargetEntityAction(main)); otherActionSequence.Add(new GoToMovingEntityAction()); var sync2 = new SyncedAction(main, other); mainActionSequence.Add(sync2); otherActionSequence.Add(sync2); var branchingDialogue = new DialogueBranchAction( new Dictionary <DialogueOutcome, Action> { { DialogueOutcome.Romantic, () => { ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(main, new UpdateMoodAction(Mood.Happy)); } }, { DialogueOutcome.Mean, () => { ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(main, new UpdateMoodAction(Mood.Angry)); } }, { DialogueOutcome.Nice, () => { ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(main, new UpdateMoodAction(Mood.Happy)); } } }); mainActionSequence.Add(branchingDialogue); otherActionSequence.Add(new PauseAction(3)); otherActionSequence.Add(new UpdateMoodAction(Mood.Angry)); var sync3 = new SyncedAction(main, other); mainActionSequence.Add(sync3); otherActionSequence.Add(sync3); mainActionSequence.Add(CommonActions.TalkToPlayer(new TolstoyTwoDialogue())); mainActionSequence.Add(new LeaveBarAction()); otherActionSequence.Add(new LeaveBarAction()); }
private void ProcessTick(params Interaction[] interactionsToAdd) { List <InputDevice> usedDevices = new List <InputDevice>(); foreach (Interaction interaction in interactionsToAdd) { InputDevice actionDevice = interaction.SourceDevice; if (usedDevices.Contains(actionDevice)) { throw new ArgumentException("You can only add one action per device for a single tick."); } } List <InputDevice> unusedDevices = new List <InputDevice>(this.sequences.Keys); foreach (Interaction interaction in interactionsToAdd) { ActionSequence sequence = this.FindSequence(interaction.SourceDevice); sequence.AddAction(interaction); unusedDevices.Remove(interaction.SourceDevice); } foreach (InputDevice unusedDevice in unusedDevices) { ActionSequence sequence = this.sequences[unusedDevice]; sequence.AddAction(new PauseInteraction(unusedDevice, TimeSpan.Zero)); } }
public void runAction(ActionSequence<NaoSkeleton> action) { Executor executor = new Executor(action, nao, FPS); Thread t = new Thread(new ThreadStart(executor.run)); t.Start(); t.Join(); }
public void PlayNodeAction(BaseNode pNode, ActionData aData) { ushort actionId = 1; if (pNode.ID == 5001) { actionId = 1; } if (pNode.ID == 5002) { actionId = 2; } if (pNode.ID == 5003) { actionId = 3; } ActionSequence actSeq = GameData.Instance.actConfig.GetActionSequence(actionId); while (actSeq != null) { PlayingActionInfo playingActionInfo = new PlayingActionInfo(); playingActionInfo.actionInfo = actSeq.actionInfo; playingActionInfo.actionData = aData; playingActionInfo.srcNode = pNode; playAction(playingActionInfo); actSeq = actSeq.nextActionSequence; } }
void Land() { m_LandingSquashSequence.Cancel(); m_LandingSquashSequence = ActionMaster.Actions.Sequence(); m_LandingSquashSequence.Scale(m_LandingSquashNode.gameObject, m_LandingSquashScale, m_LandingSquashDuration / 2, new Ease(Ease.Quad.Out)); m_LandingSquashSequence.Scale(m_LandingSquashNode.gameObject, Vector3.one, m_LandingSquashDuration / 2, new Ease(Ease.Quad.In)); }
void HandleFrontAndBackSquashing() { var frontTouching = m_FrontSensor.IsTouchingLayers(); var backTouching = m_BackSensor.IsTouchingLayers(); var xDelta = Mathf.Abs(transform.position.x - m_PreviousX); var normalizedDelta = (xDelta / Time.deltaTime) / m_MovementSpeed; var clampedDelta = Mathf.Clamp(normalizedDelta, 0, m_MaxSquashFactor); var squashScale = Vector3.LerpUnclamped(Vector3.one, m_FrontSquashScale, clampedDelta); var duration = (m_FrontSquashDuration / 2) * clampedDelta; if (frontTouching && !m_FrontTouching && !m_FrontSquashSequence.Active) { m_FrontSquashSequence = ActionMaster.Actions.Sequence(); m_FrontSquashSequence.Scale(m_FrontSquashNode.gameObject, squashScale, duration, new Ease(Ease.Quad.Out)); m_FrontSquashSequence.Scale(m_FrontSquashNode.gameObject, Vector3.one, duration, new Ease(Ease.Quad.In)); } if (backTouching && !m_BackTouching && !m_BackSquashSequence.Active) { m_BackSquashSequence = ActionMaster.Actions.Sequence(); m_BackSquashSequence.Scale(m_BackSquashNode.gameObject, squashScale, duration, new Ease(Ease.Quad.Out)); m_BackSquashSequence.Scale(m_BackSquashNode.gameObject, Vector3.one, duration, new Ease(Ease.Quad.In)); } m_FrontTouching = frontTouching; m_BackTouching = backTouching; }
private static void TestUpdate(StorageInfo origin, Action <StorageInfo, StorageInfo, HintSet> mutator, Action <Difference, ActionSequence> validator, bool useHints) { var s1 = Clone(origin); var s2 = Clone(origin); var hints = new HintSet(s1, s2); mutator.Invoke(s1, s2, hints); if (!useHints) { hints = new HintSet(s1, s2); } TestLog.Info("Update test ({0} hints)", useHints ? "with" : "without"); s1.Dump(); s2.Dump(); s1.Validate(); s2.Validate(); // Comparing different models TestLog.Info("Comparing models:"); var comparer = new Comparer(); var diff = comparer.Compare(s1, s2, hints); TestLog.Info("\r\nDifference:\r\n{0}", diff); var actions = new ActionSequence() { new Upgrader().GetUpgradeSequence(diff, hints, comparer) }; TestLog.Info("\r\nActions:\r\n{0}", actions); if (validator != null) { validator.Invoke(diff, actions); } }
/// <summary> /// Ajoute une nouvelle action dans une séquence (existante ou non) /// </summary> /// <param name="actionSequence">Nouvelle ActionSequence</param> /// <param name="actionId">Id de l'Action à exécuter</param> /// <returns>Message de retour</returns> public async Task <ActionSequence> AddActionSequence(ActionSequence actionSequence, long actionId) { if (actionSequence == null) { throw new WrongParameterException("ActionSequenceDomain.AddAction : ActionSequence is null."); } ENT.Action action = await UnitOfWork.GetDbContext().Action .Where(a => a.Id == actionId) .FirstOrDefaultAsync(); if (action == null) { throw new WrongParameterException($"ActionSequenceDomain.AddAction : Unknown Action with id = {actionId}."); } UnitOfWork.ActionSequenceRepository.PrepareAddForObject(actionSequence); actionSequence.Action = action; int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync(); if (nbr <= 0) { throw new DatabaseException("ActionSequenceDomain.AddAction : impossible to save ActionSequence."); } return(actionSequence); }
private void Flick(AndroidDriver <AppiumWebElement> driver, AppiumWebElement element, UpOrDown direction) { int moveYDirection; if (direction == UpOrDown.Down) { moveYDirection = 600; } else { moveYDirection = -600; } var input = new PointerInputDevice(PointerKind.Touch); ActionSequence FlickUp = new ActionSequence(input); FlickUp.AddAction(input.CreatePointerMove(element, 0, 0, TimeSpan.Zero)); FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left)); FlickUp.AddAction(input.CreatePointerMove(element, 0, moveYDirection, TimeSpan.FromMilliseconds(200))); FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left)); driver.PerformActions(new List <ActionSequence>() { FlickUp }); }
/// <summary> /// Creates a new AsyncSocket. You must call Start() after creating the AsyncSocket /// in order to begin receive data. /// </summary> internal AsyncTcpSocket(Socket socket, IPEndPoint remoteEndpoint, IPEndPoint localEndpoint, Action <byte[], int> onReceive, Action <Exception> onError) { Socket = socket; OnReceive = onReceive; OnError = onError; RemoteEndPoint = remoteEndpoint; LocalEndPoint = localEndpoint; _sendLock = new Lock(); _readLock = new Lock(); _callbackLock = new Lock(); _sendBuffer = new Shared <BufferQueue>(new BufferQueue()); _syncLock = new LockReadWrite(); _receivedBuffer = new Shared <BufferQueue>(new BufferQueue()); _onReceive = new ActionSequence(); _callbacks = new Queue <Teple <int, IAction> >(); _sendSocketArgs = SocketEventArgsCache.AllocateForSend(OnSocketSend); _sendSocketArgs.SendPacketsFlags = TransmitFileOptions.UseKernelApc | TransmitFileOptions.UseSystemThread; _sendSocketArgs.RemoteEndPoint = RemoteEndPoint; _disposing = false; }
public static void DrawCircle(WindowsDriver <WindowsElement> session) { // Draw a circle with radius 300 and 40 (x, y) points const int radius = 300; const int points = 40; // Select the Brushes toolbox to have the Brushes Pane sidebar displayed and ensure that Marker is selected session.FindElementByAccessibilityId("Toolbox").FindElementByAccessibilityId("TopBar_ArtTools").Click(); session.FindElementByAccessibilityId("SidebarWrapper").FindElementByAccessibilityId("Marker3d").Click(); // Locate the drawing surface WindowsElement inkCanvas = session.FindElementByAccessibilityId("InteractorFocusWrapper"); // Draw the circle with a single touch actions OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchContact = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch); ActionSequence touchSequence = new ActionSequence(touchContact, 0); touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, 0, -radius, TimeSpan.Zero)); touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact)); for (double angle = 0; angle <= 2 * Math.PI; angle += 2 * Math.PI / points) { touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, (int)(Math.Sin(angle) * radius), -(int)(Math.Cos(angle) * radius), TimeSpan.Zero)); } touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact)); session.PerformActions(new List <ActionSequence> { touchSequence }); // Verify that the drawing operations took place WindowsElement undoButton = session.FindElementByAccessibilityId("UndoIcon"); }
public void DrawConcentricSquaresWithVaryingDuration() { const int concentricSquareCount = 8; // Paint application only supports up to 10 touch inputs List <ActionSequence> actionSequencesList = new List <ActionSequence>(); // Draw N concentric rectangles with varying speed defined by the duration specified in durationMs for (int i = 0, radius = defaultRadius, durationMs = 1000; i < concentricSquareCount && radius > 0; i++, radius -= radiusOffset) { OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchContact = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch); ActionSequence touchSequence = new ActionSequence(touchContact, 0); touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, -radius, -radius, TimeSpan.Zero)); touchSequence.AddAction(touchContact.CreatePointerDown(PointerButton.TouchContact)); touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, radius, -radius, TimeSpan.FromMilliseconds(durationMs))); touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, radius, radius, TimeSpan.FromMilliseconds(durationMs))); touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, -radius, radius, TimeSpan.FromMilliseconds(durationMs))); touchSequence.AddAction(touchContact.CreatePointerMove(inkCanvas, -radius, -radius, TimeSpan.FromMilliseconds(durationMs))); touchSequence.AddAction(touchContact.CreatePointerUp(PointerButton.TouchContact)); actionSequencesList.Add(touchSequence); durationMs += 300; } ourSession.PerformActions(actionSequencesList); // Verify that the drawing operations took place Assert.IsTrue(undoButton.Displayed); Assert.IsTrue(undoButton.Enabled); }
public static List <EntityActionPair> DayOneMorning() { var actions = new List <EntityActionPair>(); var tolstoy = EntityStateSystem.Instance.GetEntityWithName(NPCS.Tolstoy.Name); var ellie = EntityStateSystem.Instance.GetEntityWithName(NPCS.Ellie.Name); //Ellie var ellieSequence = new ActionSequence("Ellie morning"); ellieSequence.Add(new TeleportAction(Locations.SitDownPoint1())); ellieSequence.Add(new SetReactiveConversationAction(new EllieMorningOne(), ellie)); ellieSequence.Add(CommonActions.SitDownLoop()); ActionManagerSystem.Instance.QueueAction(ellie, ellieSequence); //Tolstoy var tolstoySequence = new ActionSequence("Tolstoy morning"); tolstoySequence.Add(new TeleportAction(Locations.SitDownPoint2())); tolstoySequence.Add(new SetReactiveConversationAction(new TolstoyMorningOne(), tolstoy)); tolstoySequence.Add(new TriggerAnimationAction(Util.AnimationEvent.SittingStartTrigger)); tolstoySequence.Add(CommonActions.WaitForDrink(tolstoy, "None", new DrinkOrders.AlwaysSucceedsDrinkOrder(), 99999)); tolstoySequence.Add(new UpdateMoodAction(Mood.Happy)); tolstoySequence.Add(new ConversationAction(new TolstoyMorningGivenDrink())); tolstoySequence.Add(new SetReactiveConversationAction(new TolstoyMorningAfterDrink())); tolstoySequence.Add(new CallbackAction(() => { StaticStates.Get <PlayerDecisionsState>().GaveTolstoyDrink = true; StaticStates.Get <OutcomeTrackerState>().AddOutcome("Tolstoy's was suprised by your kindness."); })); tolstoySequence.Add(CommonActions.SitDownLoop()); ActionManagerSystem.Instance.QueueAction(tolstoy, tolstoySequence); return(actions); }
public static List <EntityActionPair> DayTwoNight() { var actions = new List <EntityActionPair>(); var tolstoy = EntityStateSystem.Instance.GetEntityWithName(NPCS.Tolstoy.Name); var ellie = EntityStateSystem.Instance.GetEntityWithName(NPCS.Ellie.Name); var tolstoySequence = new ActionSequence("Tolstoy night two"); var ellieSequence = new ActionSequence("Ellie night two"); if (StaticStates.Get <PlayerDecisionsState>().GaveEllieTolstoysDrink) { tolstoySequence.Add(new TeleportAction(Locations.SitDownPoint5())); tolstoySequence.Add(new SetReactiveConversationAction(new TosltoyNightTwoSuccess())); ellieSequence.Add(new TeleportAction(Locations.SitDownPoint6())); ellieSequence.Add(new SetReactiveConversationAction(new EllieNightTwoSuccess())); } else { tolstoySequence.Add(new TeleportAction(Locations.SitDownPoint1())); tolstoySequence.Add(new SetReactiveConversationAction(new TolstoyNightTwoFailure())); ellieSequence.Add(new TeleportAction(Locations.SitDownPoint3())); ellieSequence.Add(new SetReactiveConversationAction(new EllieNightTwoFailure(ellie.GetState <RelationshipState>()), ellie)); } tolstoySequence.Add(new TriggerAnimationAction(Util.AnimationEvent.SittingStartTrigger)); actions.Add(new EntityActionPair(tolstoy, tolstoySequence)); ellieSequence.Add(new TriggerAnimationAction(Util.AnimationEvent.SittingStartTrigger)); ActionManagerSystem.Instance.QueueAction(ellie, ellieSequence); return(actions); }
public static List <EntityActionPair> DayOneNight(Entity[] chosenSeats) { var actions = new List <EntityActionPair>(); var tolstoy = EntityStateSystem.Instance.GetEntityWithName(NPCS.Tolstoy.Name); var ellie = EntityStateSystem.Instance.GetEntityWithName(NPCS.Ellie.Name); //Tolstoy var tolstoySequence = new ActionSequence("Tolstoy night"); tolstoySequence.Add(new TeleportAction(chosenSeats[1].GameObject.transform)); tolstoySequence.Add(new SetReactiveConversationAction(new TolstoyNightOne(), tolstoy)); tolstoySequence.Add(CommonActions.SitDownLoop()); actions.Add(new EntityActionPair(tolstoy, tolstoySequence)); //Ellie var ellieSequence = new ActionSequence("Ellie night"); ellieSequence.Add(new TeleportAction(chosenSeats[2].GameObject.transform)); ellieSequence.Add(new SetReactiveConversationAction(new EllieNightOne(), ellie)); ellieSequence.Add(CommonActions.SitDownLoop()); actions.Add(new EntityActionPair(ellie, ellieSequence)); return(actions); }
//开动作序列 public static ActionSequence GetSequence(Component component) { ActionSequence seq = ActionSequence.GetInstance(component); instance.listSequence.Add(seq); return(seq); }
public override void Awake() { base.Awake(); if (!TargetTransform) { TargetTransform = transform; } if (Additive) { if (LocalScale) { TargetScale.x *= TargetTransform.localScale.x; TargetScale.y *= TargetTransform.localScale.y; TargetScale.z *= TargetTransform.localScale.z; } //else //{ // TargetScale.x *= gameObject.transform.lossyScale.x; // TargetScale.y *= gameObject.transform.lossyScale.y; // TargetScale.z *= gameObject.transform.lossyScale.z; //} } if (ActionMap.ContainsKey(gameObject)) { Seq = ActionMap[gameObject]; } else { Seq = Action.Sequence(Actions); ActionMap.Add(gameObject, Seq); } }
//直接延迟动作 public static ActionSequence Delayer(this Component id, float delay, Action action) { ActionSequence seq = ActionSequenceSystem.GetSequence(id); seq.Interval(delay).Action(action); return(seq); }
static public void QueuePop(ActionSequence sequence, int max) { while(sequence.actions.Count > max) { sequence.actions.RemoveAt(0); } }
private void PostLoad() { // finding objects should only be done when the level is finished loading // otherwise some objects may not be instantiated yet ReferencedSequence = ActionSequence.FindSequence(SequenceName); ReferencedSequence.ReferencedGameObject = gameObject; }
// Public Functions /// <summary> /// Perform the entering animation of the title "Player's Turn" /// </summary> /// <param name="_bIsAnimate"> Determine if the transition should be animated (or snapped into place) </param> public void TransitionEnter(bool _bIsAnimate) { // for: Every title element... for (int i = 0; i < marr_trTitleElement.Length; i++) { // if: Animation is selected if (_bIsAnimate) { // Snap the element into position TransitionExit(false); // Execute an action DelayAction actDelay = new DelayAction(i * m_fNextElementDelay); LocalMoveToAction actMoveEnter = new LocalMoveToAction(marr_trTitleElement[i], Graph.Bobber, marr_vec3DisplayPosition[i], 0.15f); ActionSequence actSequence = new ActionSequence(actDelay, actMoveEnter); // if: The last action completed should activate the next animation if (i == marr_trTitleElement.Length - 1) { actSequence.OnActionFinish += () => { UI_PlayerTurn.Instance.TransitionEnter(true, true); } } ; ActionHandler.RunAction(actSequence); } else { marr_trTitleElement[i].localPosition = marr_vec3DisplayPosition[i]; } } }
void Awake() { m_TileGrid = FindObjectOfType <TileGrid>(); m_CameraController = FindObjectOfType <CameraController>(); m_Transform = GetComponent <Transform>(); m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_EyesController = GetComponent <EyesController>(); m_CheckpointPosition = transform.position; if (m_FacingLeft) { FaceLeft(); } m_Grounded = m_StartGrounded; m_LandingSquashSequence = ActionMaster.Actions.Sequence(); m_FrontSquashSequence = ActionMaster.Actions.Sequence(); m_BackSquashSequence = ActionMaster.Actions.Sequence(); m_DeathSequence = ActionMaster.Actions.Sequence(); m_HopSequence = ActionMaster.Actions.Sequence(); m_HopDefaultY = m_HopNode.localPosition.y; m_PreviousX = transform.position.x; m_DefaultGravity = m_Rigidbody2D.gravityScale; m_DefaultColor = m_BodySpriteRenderer.color; GlobalData.PlayModePreToggle += OnPlayModePreToggle; }
//The timing function, callback function and judgment function are realized through the node. public override void OnInspectorGUI() { base.OnInspectorGUI(); int countAll, countActive; GUILayout.Label("ObjectPool State: Active/All", EditorStyles.boldLabel); ActionNodeAction.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("ActionNode: {0}/{1}", countActive, countAll)); ActionNodeInterval.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("IntervalNode: {0}/{1}", countActive, countAll)); ActionNodeCondition.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("ConditionNode: {0}/{1}", countActive, countAll)); ActionSequence.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("Sequence: {0}/{1}", countActive, countAll)); //Showing ActionSequences in progress ActionSequenceSystem actionSequenceSystem = target as ActionSequenceSystem; GUILayout.Label(string.Format("Sequence Count: {0}", actionSequenceSystem.ListSequence.Count), EditorStyles.boldLabel); for (int i = 0; i < actionSequenceSystem.ListSequence.Count; i++) { if (!actionSequenceSystem.ListSequence[i].isFinshed) { GUILayout.Box(string.Format("{0} id: {1}\n Loop:{2}/{3}", i, actionSequenceSystem.ListSequence[i].id, actionSequenceSystem.ListSequence[i].cycles, actionSequenceSystem.ListSequence[i].loopTime), "TextArea"); } } Repaint(); }
//USE START NOT AWAKE public override void Awake() { base.Awake(); if(!TargetTransform) { TargetTransform = transform; } if(ActionMap.ContainsKey(gameObject)) { Seq = ActionMap[gameObject]; } else { Seq = Action.Sequence(Actions); ActionMap.Add(gameObject, Seq); } if(Additive) { if(LocalPosition) { TargetPosition += TargetTransform.localPosition; } else { TargetPosition += TargetTransform.position; } } }
public void Touch_DragAndDrop() { WindowsElement appNameTitle = FindAppTitleBar(); const int offset = 100; // Save application window original position Point originalPosition = session.Manage().Window.Position; Assert.IsNotNull(originalPosition); // Send touch down, move, and up actions combination to perform a drag and drop // action on the app title bar. These actions reposition the application window. PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch); ActionSequence sequence = new ActionSequence(touchDevice, 0); sequence.AddAction(touchDevice.CreatePointerMove(appNameTitle, 0, 0, TimeSpan.Zero)); sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); sequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Pointer, offset, offset, TimeSpan.FromSeconds(1))); sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); session.PerformActions(new List <ActionSequence> { sequence }); Thread.Sleep(TimeSpan.FromSeconds(1)); // Verify that application window is now re-positioned from the original location Assert.AreNotEqual(originalPosition, session.Manage().Window.Position); Assert.IsTrue(originalPosition.Y < session.Manage().Window.Position.Y); // Restore application window original position session.Manage().Window.Position = originalPosition; Assert.AreEqual(originalPosition, session.Manage().Window.Position); }
public void BaseComparisonTest() { var source = new Server("Source"); var target = srv; target.Validate(); TestLog.Info("Source model:"); // source.Dump(); TestLog.Info("Target model:"); // target.Dump(); var comparer = new Comparer(); var hints = new HintSet(source, target) { new RenameHint("", "") }; Difference diff = comparer.Compare(source, target, hints); TestLog.Info("Difference: \r\n{0}", diff); var actions = new ActionSequence { new Upgrader().GetUpgradeSequence(diff, hints, comparer) }; TestLog.Info("Actions: \r\n{0}", actions); TestLog.Info("Applying actions..."); actions.Apply(source); TestLog.Info("Updated Model 1:"); // source.Dump(); }
public void ExecuteSequence(ActionSequence sequence) { ResetForNewSequence(sequence); if (sequence.sequenceName.Equals("Melee Kill Sequence")) { ExecuteMeleeSequence(); } else if (sequence.sequenceName.Equals("Ranged Kill Sequence")) { ExecuteRangedSequence(); } else if (sequence.sequenceName.Equals("Gather Health Sequence")) { ExecuteHealthGatheringSequence(); } else if (sequence.sequenceName.Equals("Gather Ammo Sequence")) { ExecuteAmmoGatheringSequence(); } else if (sequence.sequenceName.Equals("Escape Sequence")) { ExecuteEscapeSequence(); } ShouldCalculateSequence = true; }
public void Touch_Flick() { // Navigate to add alarm page session.FindElementByAccessibilityId("AddAlarmButton").Click(); session.FindElementByAccessibilityId("AlarmTimePicker").Click(); Thread.Sleep(TimeSpan.FromSeconds(1)); WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector"); WindowsElement minute00 = session.FindElementByName("00"); Assert.IsNotNull(minuteSelector); Assert.IsNotNull(minute00); Assert.IsTrue(minute00.Displayed); // Perform touch flick down action to scroll the minute hiding 00 minutes that was shown PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch); ActionSequence sequence = new ActionSequence(touchDevice, 0); sequence.AddAction(touchDevice.CreatePointerMove(minuteSelector, 0, 0, TimeSpan.Zero)); sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); sequence.AddAction(touchDevice.CreatePointerMove(minuteSelector, 0, 500, TimeSpan.Zero)); sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); session.PerformActions(new List <ActionSequence> { sequence }); Thread.Sleep(TimeSpan.FromSeconds(2)); Assert.IsFalse(minute00.Displayed); }
public void Touch_LongClick() { // Create a new test alarm string alarmName = "LongTapTest"; DeletePreviouslyCreatedAlarmEntry(alarmName); AddAlarmEntry(alarmName); Thread.Sleep(TimeSpan.FromSeconds(3)); var alarmEntries = session.FindElementsByXPath($"//ListItem[starts-with(@Name, \"{alarmName}\")]"); Assert.IsNotNull(alarmEntries); Assert.AreEqual(1, alarmEntries.Count); // Open a the context menu on the alarm entry using long tap (press and hold) action and click delete PointerInputDevice touchDevice = new PointerInputDevice(PointerKind.Touch); ActionSequence sequence = new ActionSequence(touchDevice, 0); sequence.AddAction(touchDevice.CreatePointerMove(alarmEntries[0], 0, 0, TimeSpan.Zero)); sequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); sequence.AddAction(touchDevice.CreatePointerMove(alarmEntries[0], 0, 0, TimeSpan.FromSeconds(3))); sequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); session.PerformActions(new List <ActionSequence> { sequence }); Thread.Sleep(TimeSpan.FromSeconds(1)); session.FindElementByName("Delete").Click(); Thread.Sleep(TimeSpan.FromSeconds(1)); alarmEntries = session.FindElementsByXPath($"//ListItem[starts-with(@Name, \"{alarmName}\")]"); Assert.IsNotNull(alarmEntries); Assert.AreEqual(0, alarmEntries.Count); }
static public void AddJump(GameObject gameObject, ActionSequence sequence) { Jump action = new Jump(); action.source = gameObject; action.force = 5f; action.duration = 0.5f; QueuePop(sequence,3); sequence.actions.Add(action); }
void Reset(ActionSequence seq) { //Then, interpolate this objects position to the point [5, 3, 2] over 2 seconds. Action.Property(seq, transform.GetProperty(val => val.position), new Vector3(5, 3, 2), 2, Ease.QuadInOut); //Then, interpolate this objects position to the point [-5, 3, 2] over 2 seconds. Action.Property(seq, transform.GetProperty(val => val.position), new Vector3(-5, 3, 2), 2, Ease.QuadInOut); //Then call this function again with another sequence, causing a loop. Action.Call(seq, Reset, Action.Sequence(Grp)); }
static public void AddGrab(GameObject gameObject, ActionSequence sequence) { Grab action = new Grab(); action.source = gameObject; action.range = 2.0f; action.duration = 0.2f; QueuePop(sequence,3); sequence.actions.Add(action); }
static public void AddBackDash(GameObject gameObject, ActionSequence sequence) { BackDash action = new BackDash(); action.source = gameObject; action.force = 6f; action.duration = 0.4f; QueuePop(sequence,3); sequence.actions.Add(action); }
static public void AddSwat(GameObject gameObject, ActionSequence sequence) { Swat action = new Swat(); action.source = gameObject; action.range = 2.0f; action.yRange = 1.0f; action.duration = 0.2f; QueuePop(sequence,3); sequence.actions.Add(action); }
void Start() { volDown = new VolumeToAction(gameObject.GetComponent<AudioSource>(), 0.0f, 5.0f); volDown.SetGraph(Graph.Exponential); VolumeToAction volUp = new VolumeToAction(gameObject.GetComponent<AudioSource>(), 1.0f, 5.0f); volUp.SetGraph(Graph.InverseExponential); sequence = new ActionSequence(volDown, volUp); forever = new ActionRepeatForever(sequence); ActionHandler.RunAction(forever); }
public object Clone() { ActionSequence other = new ActionSequence(); other.actions.Clear(); foreach(GameAction action in this.actions) { other.actions.Add(action.Clone() as GameAction); } return other; }
public override void Awake() { base.Awake(); if(!TargetCamera) { TargetCamera = GetComponent<Camera>(); } Seq = Action.Sequence(Actions); }
public override void OnEventFunc(EventData data) { if (Seq.IsCompleted()) { Seq = Action.Sequence(Actions); } Action.Property(Seq, TargetCamera.GetProperty(cam => cam.fieldOfView), TargetFOV, Duration, EasingCurve); EditChecks(Seq); }
static public void AddLeftDash(GameObject gameObject, ActionSequence sequence) { SideDash action = new SideDash(); action.name = "right dash"; action.source = gameObject; action.force = 3f; action.left = true; action.duration = 0.4f; QueuePop(sequence,3); sequence.actions.Add(action); }
public void EditChecks(ActionSequence Seq) { if (DeactivateUntilFinished) { Active = false; Action.Call(Seq, SetActive, true); } if (DispatchOnFinish && DispatchEvents) { Action.Call(Seq, DispatchEvent); } }
public override void OnEventFunc(EventData data) { if (Seq.IsCompleted()) { Seq = Action.Sequence(Actions); } var targetSize = TargetSize; if (Additive) { targetSize = TargetSize + TargetCamera.orthographicSize; } Action.Property(Seq, TargetCamera.GetProperty(cam => cam.orthographicSize), targetSize, Duration, EasingCurve); EditChecks(Seq); }
public override void Awake() { base.Awake(); if(!TargetCamera) { TargetCamera = GetComponent<Camera>(); } Seq = Action.Sequence(Actions); if(Additive) { TargetFOV += TargetCamera.fieldOfView; } }
public override void OnEventFunc(EventData data) { if (Seq.IsCompleted()) { Seq = Action.Sequence(Actions); } if (LocalRotation) { Action.Property(Seq, TargetTransform.GetProperty(o => o.localEulerAngles), TargetRotation, Duration, EasingCurve); } else { Action.Property(Seq, TargetTransform.GetProperty(o => o.eulerAngles), TargetRotation, Duration, EasingCurve); } EditChecks(Seq); }
static void Main(string[] args) { Dictionary<string, string> actions = new Dictionary<string, string>(); actions["raise the roof"] = "raisetheroof"; actions["walk forward"] = "walkforward"; actions["walk left"] = "walkleft"; actions["wave right"] = "waveright"; actions["wave left"] = "waveleft"; string filename = "Z:/dev/kinect-nao/recordings/"; ActionLibrary lib = new ActionLibrary(); foreach (string actionName in actions.Keys) { List<HumanSkeleton> seq = new List<HumanSkeleton>(); using (StreamReader s = new StreamReader(filename + actions[actionName] + "/" + actionName + "1.rec")) { while (!s.EndOfStream) { seq.Add(new HumanSkeleton(s.ReadLine())); } } //List<float[]> naoSeq = new List<float[]>(); ActionSequence<NaoSkeleton> naoSeq = new ActionSequence<NaoSkeleton>(); foreach (HumanSkeleton h in seq) { AngleConverter ac = new AngleConverter(h); naoSeq.append(ac.getNaoSkeleton()); //naoSeq.Add(ac.getAngles()); } lib.appendToCache(naoSeq); lib.setCachedName(actionName); lib.saveCache(); //bool isJointAction = true; // false if is a walking action //ExecuteOnNao(naoSeq, isJointAction); } lib.save(MainController.ACTION_LIB_PATH); }
public ActionLibrary(SerializationInfo info, StreamingContext ctxt) { // field 1: actions // retrieving keys and values separately as dictionary is not serializable String[] keys = (String[])info.GetValue("keys", typeof(String[])); ActionSequence<NaoSkeleton>[] values = (ActionSequence<NaoSkeleton>[])info.GetValue("values", typeof(ActionSequence<NaoSkeleton>[])); // reconstructs the dictionary Dictionary<String, ActionSequence<NaoSkeleton>> actDict = new Dictionary<string, ActionSequence<NaoSkeleton>>(); for (int i = 0; i < keys.Length; i++) { actDict.Add(keys[i], values[i]); } this.actions = actDict; // field 2: cachedStates this.cachedStates = (ActionSequence<NaoSkeleton>)info.GetValue("cachedStates", typeof(ActionSequence<NaoSkeleton>)); // field 3: cachedName; this.cachedName = (String)info.GetValue("cachedName", typeof(String)); }
//USE START NOT AWAKE public override void Awake() { base.Awake(); if (!TargetTransform) { TargetTransform = transform; } if (Additive) { if(LocalRotation) { TargetRotation += TargetTransform.localEulerAngles; } else { TargetRotation += TargetTransform.eulerAngles; } } Seq = Action.Sequence(Actions); }
public override void OnEventFunc(EventData data) { if (ClearActions) { Seq.Clear(); } Seq = Action.Sequence(Actions); ActionMap[gameObject] = Seq; if (LocalScale) { Action.Property(Seq, TargetTransform.GetProperty(o => o.localScale), TargetScale, Duration, EasingCurve); } //else //{ // Debug.Log(transform.GetProperty(o => o.lossyScale)); // Action.Property(Seq, transform.GetProperty(o => o.lossyScale), TargetScale, Duration, EasingCurve); //} EditChecks(Seq); }
public static ActionLibrary load(String path) { /*ActionLibrary al = new ActionLibrary(); Stream stream = File.Open(path, FileMode.Open); BinaryFormatter bformatter = new BinaryFormatter(); al = (ActionLibrary)bformatter.Deserialize(stream); stream.Close(); return al;*/ Dictionary<string, string> actions = new Dictionary<string, string>(); actions["raise the roof"] = "raisetheroof"; actions["walk forward"] = "walkforward"; actions["walk left"] = "walkleft"; actions["walk back"] = "walkbackward"; actions["walk right"] = "walkright"; actions["wave right"] = "waveright"; actions["wave left"] = "waveleft"; string filename = "Z:/dev/kinect-nao/recordings/"; ActionLibrary lib = new ActionLibrary(); foreach (string actionName in actions.Keys) { List<HumanSkeleton> seq = new List<HumanSkeleton>(); using (StreamReader s = new StreamReader(filename + actions[actionName] + "/" + actionName + "1.rec")) { while (!s.EndOfStream) { seq.Add(new HumanSkeleton(s.ReadLine())); } } ActionSequence<NaoSkeleton> naoSeq = new ActionSequence<NaoSkeleton>(); foreach (HumanSkeleton h in seq) { AngleConverter ac = new AngleConverter(h); naoSeq.append(ac.getNaoSkeleton()); } if (actionName.StartsWith("walk")) { NaoSkeleton start = naoSeq.get(0); NaoSkeleton end = naoSeq.get(naoSeq.size() - 1); NaoSkeleton diff = new NaoSkeleton(new NaoPosition(end.Position.X - start.Position.X, end.Position.Y - start.Position.Y, end.Position.Z - start.Position.Z)); naoSeq = new ActionSequence<NaoSkeleton>(); naoSeq.append(diff); } lib.appendToCache(naoSeq); lib.setCachedName(actionName); lib.saveCache(); } return lib; }
public ActionLibrary() { this.actions = new Dictionary<string, ActionSequence<NaoSkeleton>>(); this.cachedStates = new ActionSequence<NaoSkeleton>(); this.cachedName = null; }
public void mapAction(string name, ActionSequence<NaoSkeleton> seq) { this.actions[name] = seq; }
public void GetObjectData(SerializationInfo info, StreamingContext ctxt) { int dictSize = actions.Count; String[] keys = new String[dictSize]; ActionSequence<NaoSkeleton>[] values = new ActionSequence<NaoSkeleton>[dictSize]; // serializing dictionary separately because a dictionary is not serializable int i = 0; foreach (KeyValuePair<String, ActionSequence<NaoSkeleton>> pair in actions) { keys[i] = pair.Key; values[i] = pair.Value; i++; } info.AddValue("keys", keys); info.AddValue("values", values); info.AddValue("cachedStates", cachedStates); info.AddValue("cachedName", cachedName); }
public void clearCache() { this.cachedName = null; this.cachedStates = new ActionSequence<NaoSkeleton>(); }
public void appendToCache(ActionSequence<NaoSkeleton> action) { this.cachedStates.append(action); }