public DirectionEnum Solve2(PlayerSessionInfo info, TurnResult turn) { Location currentLocation = info.CurrentLocation; if (turn != null) { currentLocation = turn.Location; } var sosedi = info.NeighbourCells; if (turn != null) { sosedi = turn.VisibleCells; } var checker = new MovementChecker(); var dir = lastDir; while (!checker.CanMove(dir, currentLocation, sosedi, 4)) { dir = dir.Next(); } return(dir); return(DirectionEnum.East); }
// Use this for initialization void Start() { _groundChecker = GetComponent <GroundChecker>(); _movementChecker = GetComponent <MovementChecker>(); _movementChecker.X_PositionChanged += XPositionChanged; _movementChecker.MovementStopped += DetectedStopping; _delayManager = GetComponent <DelayManager>(); _explosiveObject = GetComponent <ExplosiveObject>(); }
private void StopCollider() { if (_groundMover != null) { _groundMover.X_PositionChanged -= GroundMoverOnPositionChanged; } _groundMover = null; _subscribedCollider = null; }
private void DetectedCollider(GameObject gameObject) { var testExplosive = gameObject.GetComponentInParent<ExplosiveObject>(); //print(test); if(testExplosive != null) { var getGroundMover = gameObject.GetComponentInParent<MovementChecker>(); _subscribedCollider = testExplosive; _groundMover = getGroundMover; _groundMover.X_PositionChanged += GroundMoverOnPositionChanged; } }
private void DetectedCollider(GameObject gameObject) { var testExplosive = gameObject.GetComponentInParent <ExplosiveObject>(); //print(test); if (testExplosive != null) { var getGroundMover = gameObject.GetComponentInParent <MovementChecker>(); _subscribedCollider = testExplosive; _groundMover = getGroundMover; _groundMover.X_PositionChanged += GroundMoverOnPositionChanged; } }
private void Awake() { _movementChecker = transform.GetComponentInChildren <MovementChecker>(); if (_movementChecker == null) { Debug.LogError("Movement checker is missing"); } _playerMovement = transform.GetComponent <PlayerMovement>(); if (_playerMovement == null) { Debug.LogError("PlayerMovement is not found"); } _animatorHandler = GetComponentInChildren <PlayerAnimationHandling>(); if (_animatorHandler == null) { Debug.LogError("_animatorHandler is not found"); } }
// Use this for initialization void Start() { _groundChecker = GetComponent<GroundChecker>(); _movementChecker = GetComponent<MovementChecker>(); _movementChecker.X_PositionChanged += XPositionChanged; _movementChecker.MovementStopped += DetectedStopping; _delayManager = GetComponent<DelayManager>(); _explosiveObject = GetComponent<ExplosiveObject>(); }
public (DirectionEnum, int) Solve(PlayerSessionInfo info, TurnResult turn, List <Location> visited) { Location currentLocation = info.CurrentLocation; if (turn != null) { currentLocation = turn.Location; } var sosedi = info.NeighbourCells; if (turn != null) { sosedi = turn.VisibleCells; } var speed = info.CurrentSpeed; var checker = new MovementChecker(); var dict = Compass.GetDirection(currentLocation, info.Finish); var array = dict.ToArray().ToList(); array.Sort((a, b) => { if (a.Value < b.Value) { return(-1); } if (a.Value > b.Value) { return(1); } return(0); }); //go to good dir var dir = array[0]; if (!dir.Key.Equals(lastDir)) { var movementState = checker.CanMoveWithPit(dir.Key, currentLocation, sosedi, speed.Value); if (movementState.IsCanMove) { lastDir = dir.Key.Next().Next().Next(); return(dir.Key, movementState.Acceleration); } } //go snova var dirq = lastDir.Next().Next().Next(); if (!dirq.Equals(lastDir)) { var movementState = checker.CanMoveWithPit(dirq, currentLocation, sosedi, speed.Value); if (movementState.IsCanMove) { lastDir = dirq.Next().Next().Next(); return(dirq, movementState.Acceleration); } } //unvisited foreach (var cur in array.Where(q => { var w = currentLocation.Plus(Constants.Deltas[q.Key]); return(visited.Any(a => a.Equals(w)) == false); })) { if (cur.Key.Equals(lastDir)) { continue; } var movementState = checker.CanMoveWithPit(cur.Key, currentLocation, sosedi, speed.Value); if (movementState.IsCanMove) { lastDir = cur.Key.Next().Next().Next(); return(cur.Key, movementState.Acceleration); } } //go na poher foreach (var cur in array) { if (cur.Key.Equals(lastDir)) { continue; } var movementState = checker.CanMoveWithPit(cur.Key, currentLocation, sosedi, speed.Value); if (movementState.IsCanMove) { lastDir = cur.Key.Next().Next().Next(); return(cur.Key, movementState.Acceleration); } } lastDir = DirectionEnum.West; return(DirectionEnum.East, 0); }