public void TestActionActor2() { TestLauncherActor.Test( () => { ConcurrentDictionary <int, string> dico = new ConcurrentDictionary <int, string>(); var future = new Future <int, string>(); var act = new ActionActor(); act.SendAction(() => { var tst = new ActionActor <int, string>(); tst.SendAction((i, t) => dico[i] = t, 1, "test1"); tst.SendAction((i, t) => dico[i] = t, 2, "test2"); tst.SendAction((i, t) => dico[i] = t, 3, "test3"); tst.SendAction(() => { var s = string.Concat(dico.Values); future.SendMessage(dico.Count, s); }); }); var result = future.Result(); Assert.AreEqual(3, result.Item1); Assert.AreEqual("test1test2test3", result.Item2); } ); }
public void TestActionActor() { TestLauncherActor.Test( () => { ConcurrentQueue <string> queue = new ConcurrentQueue <string>(); var act = new ActionActor(); var future = new Future <int>(); act.SendAction(() => { var tst = new ActionActor <string>(); tst.SendAction((t) => { queue.Enqueue(t); }, "test1"); tst.SendAction((t) => { queue.Enqueue(t); }, "test2"); tst.SendAction((t) => { queue.Enqueue(t); }, "test3"); tst.SendAction(() => { future.SendMessage(queue.Count); }); }); Assert.AreEqual(3, future.Result()); } ); }
public void FixedUpdate() { if (!_follower.Alive || _follower.IsKnockOut || _follower.Stunned || _follower.waiting) { return; } if (_following == null || !_following.Alive) { _following = LevelManager.GetRandomPlayerAtScene(); } else { Vector3 direction = (_following.transform.position - _follower.transform.position).normalized; if (direction.x < 0) { direction = (_following.transform.position - _follower.transform.position + _distance).normalized; } else if (direction.x > 0) { direction = (_following.transform.position - _follower.transform.position - _distance).normalized; } _follower.Rigidbody2D.velocity = direction * _follower.moveVelocity * Time.deltaTime; } }
private void CalculateRandomMove() { int randomX = Random.Range(0, 3); if (randomX == 2) { randomX = -1; } int randomY = Random.Range(0, 3); if (randomY == 2) { randomY = -1; } Vector3 direction = new Vector3( randomX, randomY, 0); _follower.Rigidbody2D.velocity = direction * _follower.moveVelocity * Time.deltaTime; _following = null; timeRandomMove = 0; }
public void BehaviorAndInterfaceTest() { IBehavior bhv = new Behavior <BaseActor>( a => { }); IActor iBaseActor = new BaseActor(); Assert.IsTrue(bhv.StandardPattern(iBaseActor)); BaseActor baseActor = new BaseActor(); Assert.IsTrue(bhv.StandardPattern(baseActor)); ActionActor actionActor = new ActionActor(); Assert.IsTrue(bhv.StandardPattern(actionActor)); IFuture future = new Future <string>(); Assert.IsTrue(bhv.StandardPattern(future)); IBehavior <IActor, IActor> bhv2 = new Behavior <IActor, IActor>((a1, a2) => { }); Assert.IsTrue(bhv2.StandardPattern(new MessageParam <IActor, IActor>(new BaseActor(), new Future <string>()))); }
public async Task ActionActor_Should_Stop_When_Cancelled() { var actor = new ActionActor(async cancellationToken => { await Task.Delay(Timeout.Infinite, cancellationToken); }); actor.Start(); try { await actor.CancelAsync(); } catch (OperationCanceledException) {} Assert.True(actor.Completion.IsCompleted); }
public static CardSlot GetCardSlotByID(int ID) { ActionActor a = GetActorByID(ID); if (a is CardSlot) { return((CardSlot)a); } else { Debug.LogError("ID " + ID + " does not correspond to a CardSlot!"); return(null); } }
/// Perform this action public void Perform(GameManager gm) { Card c; CardSlot cs; switch ((Act)actionID) { case Act.EndTurn: gm.turnManager.EndTurn(); status = ActionStatus.Acted; break; case Act.RevealCard: c = ActionActor.GetCardByID(actorID); c.Reveal(new CardID(parameter)); status = ActionStatus.Acted; break; case Act.PlayCard: c = ActionActor.GetCardByID(actorID); cs = ActionActor.GetCardSlotByID(targetID); c.AddToCardSlot(cs); status = ActionStatus.Acted; break; case Act.ChargePolicyCard: c = ActionActor.GetCardByID(actorID); c.ChargePolicy(); status = ActionStatus.Acted; break; case Act.ChargeOperativeCard: c = ActionActor.GetCardByID(actorID); c.ChargeOperativeUntargeted(); status = ActionStatus.Acted; break; // don't forget ActionStatus.Acted! default: Debug.LogError("Invalid actionID " + actionID); break; } }
public void SetFollow(ActionActor actor) { _following = actor; }
public IaRangedFollowActor(ActionActor follower, Vector3 distance) { _follower = follower; _distance = distance; }
public IaRandomMove(ActionActor follower) { _follower = follower; }
private void Start() { actor = gameObject.GetComponentInParent <ActionActor>(); }
public IaFollowActor(ActionActor follower) { _follower = follower; }