コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: Unit.cs プロジェクト: bjck/AMFU
    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);
    }
コード例 #3
0
 private void SetAllAccessTrackingTo(StateTracker state)
 {
     for (var index = 0; index < partAccessed.Length; index++)
     {
         partAccessed[index] = state;
     }
 }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: FiniteStateMachine.cs プロジェクト: bjck/AMFU
    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());
    }
コード例 #6
0
        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);
        }
コード例 #7
0
 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),
                         }
                     }
                 }
             }
         }
     };
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        public void TakeAttack_Miss()
        {
            IStateTracker stateTracker = new StateTracker();
            string        message      = stateTracker.TakeAttack(1, 1);

            Assert.AreEqual("Miss", message);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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();
        }
コード例 #14
0
    /**
     * @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;
        }
    }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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();
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        public void TakeAttack_Invalid_Range()
        {
            IStateTracker stateTracker = new StateTracker();
            string        message      = stateTracker.TakeAttack(11, 11);

            Assert.AreEqual("Row and Column numbers are invalid", message);
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
ファイル: Blob.cs プロジェクト: tarnas14/AgarIo
        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;
            }
        }
コード例 #24
0
        private void ExceptionalHandler(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = e.ExceptionObject as Exception;

            if (exception != null)
            {
                StateTracker.ReportException(exception);
            }
        }
コード例 #25
0
        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();
            });
        }
コード例 #26
0
        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); };
        }
コード例 #27
0
ファイル: Chase.cs プロジェクト: Wingxvii/GlobalGameJam
 // 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>();
 }
コード例 #28
0
ファイル: Blob.cs プロジェクト: tarnas14/AgarIo
        internal virtual void OnCreate()
        {
            if (_isCreated)
            {
                return;
            }

            StateTracker.AddBlob(this);
            Body       = _physics.CreateBody(this, Radius, Mass, IsStatic);
            _isCreated = true;
        }
コード例 #29
0
        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);
        }
コード例 #30
0
ファイル: Blob.cs プロジェクト: tarnas14/AgarIo
        internal virtual void OnRemove()
        {
            if (!_isCreated)
            {
                return;
            }

            _physics.DestroyBody(Body);
            StateTracker.RemoveBlob(this);
            _isCreated = false;
        }