protected override bool GetRealPositionTarget(int id, out Vector3 pos, out StateTracker state) { pos = _game_targets[id].transform.position; //TODO Pos limits by camera state = StateTracker.Live; return(true); }
bool Hit(float damage) { if (UnityEngine.Random.Range(0, 100) > (_guarding ? _baseDodgeChance * 2 : _baseDodgeChance)) { _currentHealth -= damage; if (_currentHealth <= 0) { _currentHealth = 0; _alive = false; StateTracker.WriteHistory(gameObject); rigidbody.useGravity = true; rigidbody.constraints = RigidbodyConstraints.None; this.transform.Rotate(Vector3.forward, 1.5f); Steering.SetSteeringActive(this.transform, false); if (Team == Teams.Team1) { TurnManager.OnTeam1 -= NewTurn; } if (Team == Teams.Team2) { TurnManager.OnTeam2 -= NewTurn; } } return(true); } return(false); }
private void SetAllAccessTrackingTo(StateTracker state) { for (var index = 0; index < partAccessed.Length; index++) { partAccessed[index] = state; } }
public void TakeAttack_All_Ships_Sunk() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(3, 3, new Carrier(), Direction.Vertical); message = stateTracker.AddShip(1, 5, new Battleship(), Direction.Horizontal); message = stateTracker.AddShip(1, 2, new Cruiser(), Direction.Vertical); message = stateTracker.AddShip(6, 6, new Submarine(), Direction.Horizontal); message = stateTracker.AddShip(4, 7, new Destroyer(), Direction.Vertical); message = stateTracker.TakeAttack(1, 2); message = stateTracker.TakeAttack(2, 2); message = stateTracker.TakeAttack(3, 2); message = stateTracker.TakeAttack(1, 5); message = stateTracker.TakeAttack(1, 6); message = stateTracker.TakeAttack(1, 7); message = stateTracker.TakeAttack(1, 8); message = stateTracker.TakeAttack(3, 3); message = stateTracker.TakeAttack(4, 3); message = stateTracker.TakeAttack(5, 3); message = stateTracker.TakeAttack(6, 3); message = stateTracker.TakeAttack(7, 3); message = stateTracker.TakeAttack(6, 6); message = stateTracker.TakeAttack(6, 7); message = stateTracker.TakeAttack(6, 8); message = stateTracker.TakeAttack(4, 7); message = stateTracker.TakeAttack(5, 7); Assert.AreEqual("Hit. All ships sunk", message); }
public List <IAction> UpdateState() { TriggeredTransition = null; foreach (ITransition t in CurrentState.GetTransition()) { if (t.IsTriggered()) { TriggeredTransition = t; Debug.Log("triggered"); break; } } if (TriggeredTransition != null) { TargetState = TriggeredTransition.GetTargetState(); ActionList.AddRange(CurrentState.GetExitActionList()); ActionList.AddRange(CurrentState.GetActionList()); ActionList.AddRange(TargetState.GetEntryActionList()); //Adding transition to the tracker StateTracker.AddTransition((State)CurrentState, (State)TargetState, actor); CurrentState = TargetState; return(ActionList); } return(CurrentState.GetActionList()); }
public void Destroyer_510_Horizontal_Failure() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(5, 10, new Destroyer(), Direction.Horizontal); Assert.AreEqual("Destroyer couldn't placed successfully since not enough squares on the board", message); }
public TestSceneMouseStates() { Child = new Container { FillMode = FillMode.Fit, FillAspectRatio = 1, RelativeSizeAxes = Axes.Both, Size = new Vector2(0.75f), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(1, 1, 1, 0.2f), }, s1 = new StateTracker(1), new Container { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { outerMarginBox = new Box { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(0.9f), Colour = Color4.SkyBlue.Opacity(0.1f), }, actionContainer = new Container { RelativeSizeAxes = Axes.Both, Size = new Vector2(0.6f), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(1, 1, 1, 0.2f), }, marginBox = new Box { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(0.8f), Colour = Color4.SkyBlue.Opacity(0.1f), }, s2 = new DraggableStateTracker(2), } } } } } }; }
public void Destroyer_55_Vertical_Success() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(5, 5, new Destroyer(), Direction.Vertical); Assert.AreEqual("Destroyer placed successfully", message); }
public void TakeAttack_Miss() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.TakeAttack(1, 1); Assert.AreEqual("Miss", message); }
public MissionItemViewModel(Mission mission, StateTracker state) { var stationObservable = state.Location; Mission = mission; stationObservable .Select(location => Mission.IsFilled && (location.IsDocked ? location.Station == mission.Station : location.System == mission.System)) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.ShouldHighlight); Observable.Return(1L).Merge( Observable.Interval(TimeSpan.FromSeconds(10)) ) .Select(_ => { Mission.Expiry.Subtract(TimeSpan.Zero); return(mission.Expiry - DateTime.UtcNow); }) .Select(time => $"Expires in: {time.Days}D {time.Hours}H {time.Minutes}M") .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.ExpiresIn); }
public void Carrier_75_Vertical_Failure() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(7, 5, new Carrier(), Direction.Vertical); Assert.AreEqual("Carrier couldn't placed successfully since not enough squares on the board", message); }
public void Battleship_58_Horizontal_Failure() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(5, 8, new Battleship(), Direction.Horizontal); Assert.AreEqual("Battleship couldn't placed successfully since not enough squares on the board", message); }
public CharacterJoint3D(IWorld world, IBody3D body1, IBody3D body2, TSVector position, TSVector hingeAxis) : base((World)world) { RigidBody rigid1 = (RigidBody)body1; RigidBody rigid2 = (RigidBody)body2; fixedAngle = new FixedAngle(rigid1, rigid2); pointOnLine = new PointOnLine(rigid1, rigid2, rigid1.position, rigid2.position); firstBody = body1; secondBody = body2; hingeA = hingeAxis; worldPointConstraint = new PointOnPoint[2]; hingeAxis *= FP.Half; TSVector anchor = position; TSVector.Add(ref anchor, ref hingeAxis, out anchor); TSVector anchor2 = position; TSVector.Subtract(ref anchor2, ref hingeAxis, out anchor2); worldPointConstraint[0] = new PointOnPoint((RigidBody)body1, (RigidBody)body2, anchor); worldPointConstraint[1] = new PointOnPoint((RigidBody)body2, (RigidBody)body1, anchor2); StateTracker.AddTracking(worldPointConstraint[0]); StateTracker.AddTracking(worldPointConstraint[1]); //UnityEngine.CharacterJoint; Activate(); }
/** * @brief Initial setup when game is started. **/ public override void OnSyncedStart() { StateTracker.AddTracking(this); paddleCountText = (Instantiate(paddleCountPrefab) as GameObject).GetComponent <Text>(); paddleCountText.transform.SetParent(GameObject.Find("Canvas").transform, false); tsRigidBody = GetComponent <TSRigidBody2D>(); // If paddle's owner is the first player then place it on top side if (owner.Id == 1) { Material redMatter = Resources.Load("RedMatter", typeof(Material)) as Material; GetComponent <MeshRenderer>().material = redMatter; tsRigidBody.position = new TSVector2(0, 8); // Adds this PaddleController in the {@link #paddlesBySide} dictionary with key being true (top size) paddlesBySide[true] = this; } else { tsRigidBody.position = new TSVector2(0, -8); // Adds this PaddleController in the {@link #paddlesBySide} dictionary with key being false (bottom size) paddlesBySide[false] = this; } }
public void Submarine_58_Vertical_Success() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(5, 8, new Submarine(), Direction.Vertical); Assert.AreEqual("Submarine placed successfully", message); }
public void Battleship_55_Vertical_Success() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(5, 5, new Battleship(), Direction.Vertical); Assert.AreEqual("Battleship placed successfully", message); }
public BasicJoint3D(IWorld world, IBody3D body1, IBody3D body2, TSVector anchorPosition, TSVector anchorPosition2) : base((World)world) { firstBody = body1; secondBody = body2; //hingeA = hingeAxis; worldPointConstraint = new FixedPoint[2]; ///hingeAxis *= FP.Half; TSVector anchor = anchorPosition; //TSVector.Add(ref anchor, ref hingeAxis, out anchor); TSVector anchor2 = anchorPosition2; //TSVector.Subtract(ref anchor2, ref hingeAxis, out anchor2); //pointLock = new PointPointDistance((RigidBody)body1, (RigidBody)body2, position, position); //pointLock.Distance = 0; //pointLock.Behavior = PointPointDistance.DistanceBehavior.LimitMaximumDistance; worldPointConstraint[0] = new FixedPoint((RigidBody)body1, (RigidBody)body2, anchor, anchor); worldPointConstraint[1] = new FixedPoint((RigidBody)body2, (RigidBody)body1, anchor, anchor); StateTracker.AddTracking(worldPointConstraint[0]); //StateTracker.AddTracking(worldPointConstraint[1]); Activate(); }
public void Carrier_55_Horizontal_Success() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(5, 5, new Carrier(), Direction.Horizontal); Assert.AreEqual("Carrier placed successfully", message); }
public void Add_Ship_Invalid_Range() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(11, 11, new Carrier(), Direction.Horizontal); Assert.AreEqual("Row and Column numbers are invalid", message); }
public void TakeAttack_Invalid_Range() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.TakeAttack(11, 11); Assert.AreEqual("Row and Column numbers are invalid", message); }
public void TakeAttack_Hit() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(1, 2, new Cruiser(), Direction.Vertical); message = stateTracker.TakeAttack(1, 2); Assert.AreEqual("Hit", message); }
public void Add_Ships_Failure_Overlap_2() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(3, 3, new Carrier(), Direction.Vertical); message = stateTracker.AddShip(4, 2, new Battleship(), Direction.Horizontal); Assert.AreEqual("Battleship couldn't be placed successfully since there is an overlap with another ship", message); }
public void SyncWithPhysics(bool overrideAll) { if (_radiusOverride || overrideAll) { _body.Radius = _radius; _radiusOverride = false; } else { if (_radius != _body.Radius) { StateTracker.UpdateBlob(this); } _radius = _body.Radius; } if (_positionOverride || overrideAll) { _body.Position = _position; _positionOverride = false; } else { if (_position != _body.Position) { StateTracker.UpdateBlob(this); } _position = _body.Position; } if (_body.IsStatic) { return; } if (_velocityOverride || overrideAll) { _body.LinearVelocity = _velocity; _velocityOverride = false; } else { _velocity = _body.LinearVelocity; } if (_massOverride || overrideAll) { _body.Mass = _mass; _massOverride = false; } else { _mass = _body.Mass; } }
private void ExceptionalHandler(object sender, UnhandledExceptionEventArgs e) { var exception = e.ExceptionObject as Exception; if (exception != null) { StateTracker.ReportException(exception); } }
public MainWindowViewModel(IEliteDangerousApi api, MissionCatchUp missionCatchUp, MissionTargetManager missionTargetManager, StateTracker tracker) { Router = new RoutingState(); Activator = new ViewModelActivator(); api.Events().OnCatchedUp .Select(_ => true) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.DoneLoading); // Change what is showing this.WhenActivated(disposables => { var filledMissionCountChanged = missionTargetManager .Connect() .Where(m => m.IsFilled) .ObserveOn(RxApp.MainThreadScheduler) .Bind(out var stationMissions) .DisposeMany(); api.Events().OnStart .Select(_ => new LocationUpdate(false, "", "")) .Merge(tracker.Location) .CombineLatest(filledMissionCountChanged.Select(_ => 0).Prepend(0), (dockedLocation, _) => dockedLocation) .CombineLatest(api.Events().OnCatchedUp.Delay(TimeSpan.FromMilliseconds(50)), (location, _) => location) // .Where(_ => DoneLoading) .ObserveOn(RxApp.MainThreadScheduler) .Select(e => { var showTurnIn = e.IsDocked ? stationMissions.Any(m => m.Station == e.Station) : stationMissions.Any(m => m.System == e.System); return(showTurnIn // true ? (IRoutableViewModel)((App)Application.Current).Services .GetService <TurnInViewModel>() ! : (IRoutableViewModel)((App)Application.Current).Services .GetService <MissionStatsViewModel>() !); } ) .Do(vm => Router.Navigate.Execute(vm)) .Subscribe(_ => { }) .DisposeWith(disposables); }); Task.Run(() => { missionCatchUp.CatchUp(); api.StartAsync(); }); }
public void Start() { eventID = 0; randomTimeGenerator = Generator.UniformRandomFloat().Select(x => x * 5); loadingMessage.SetActive(false); stateTracker = new StateTracker <int>(); stateTracker.OnStateActive += () => { loadingMessage.SetActive(true); }; stateTracker.OnStateInactive += () => { loadingMessage.SetActive(false); }; }
// Start is called before the first frame update void Start() { stopTimeActual = (int)Random.Range(0, stopTime); dir = new Vector2(Random.value, Random.value); dir.Normalize(); monsterRigid = this.GetComponent <Rigidbody2D>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); monster = this.GetComponent <Transform>(); playerState = GameObject.FindGameObjectWithTag("Player").GetComponent <StateTracker>(); source = GameObject.FindGameObjectWithTag("mon").GetComponent <AudioSource>(); }
internal virtual void OnCreate() { if (_isCreated) { return; } StateTracker.AddBlob(this); Body = _physics.CreateBody(this, Radius, Mass, IsStatic); _isCreated = true; }
public void Add_All_Ships_Success() { IStateTracker stateTracker = new StateTracker(); string message = stateTracker.AddShip(3, 3, new Carrier(), Direction.Vertical); message = stateTracker.AddShip(1, 5, new Battleship(), Direction.Horizontal); message = stateTracker.AddShip(1, 2, new Cruiser(), Direction.Vertical); message = stateTracker.AddShip(6, 6, new Submarine(), Direction.Horizontal); message = stateTracker.AddShip(4, 7, new Destroyer(), Direction.Vertical); Assert.AreEqual("Destroyer placed successfully", message); }
internal virtual void OnRemove() { if (!_isCreated) { return; } _physics.DestroyBody(Body); StateTracker.RemoveBlob(this); _isCreated = false; }