Example #1
0
    void FixedUpdate()
    {
        Vector3 bottomLeft = transform.position + new Vector3(leftOfColliderX, bottomOfColliderY - distanceDownToCheck, 0f);
        Vector3 bottomRight = transform.position + new Vector3(rightOfColliderX, bottomOfColliderY - distanceDownToCheck, 0f);
        // Cast a line and check if it collides with ground
        int numGround = Physics2D.LinecastNonAlloc (bottomLeft, bottomRight, theGround,	groundAndDefaultLayerMask);
        // If we collided with > 0 "Ground" objects, then we're grounded!
        this.grounded = (numGround > 0);

        if (this.grounded)
        {
            Collider2D collider = theGround [0].collider;
            if (collider.gameObject.tag == "Moving")
            {
                mover = (IMover)collider.gameObject.GetComponent (typeof(IMover));
            }
            else
            {
                mover =  null;
            }
        }
        else
        {
            mover = null;
        }
    }
 public MoveCommand(IMover entity, World <Chunk <Block>, Block> world, IReadOnlyList <Direction> directions, float time)
 {
     this.entity     = entity;
     this.world      = world;
     this.directions = directions;
     this.time       = time;
 }
Example #3
0
 public ChasePlayer(IMover mover, IFlip flip, IMyAnimations animation, System.Func <bool> isPlayerRightSide)
 {
     _mover             = mover;
     _flip              = flip;
     _animation         = animation;
     _isPlayerRightSide = isPlayerRightSide;
 }
Example #4
0
    private void Awake()
    {
        _firingEffectIsNotNull    = FiringEffect != null;
        _collisionEffectIsNotNull = CollisionEffect != null;
        _constantEffectIsNotNull  = ConstantEffect != null;
        _trailIsNotNull           = Trail != null;

        if (_firingEffectIsNotNull)
        {
        }

        Mover          = GetComponent <IMover>();
        Mover.Speed    = Speed;
        _lifeTimeTimer = 0;

        switch (CollideWith)
        {
        case HitLayer.Player:
            LayerMask        = _enemyProjectileMask;
            gameObject.layer = (int)Const.LayerNumbers.EnemyProjectile;
            break;

        case HitLayer.Enemy:
            LayerMask        = _playerProjectileMask;
            gameObject.layer = (int)Const.LayerNumbers.PlayerProjectile;
            break;
        }
    }
Example #5
0
 public FollowPathBehaviour(IMover me, Route path, double waypointSeekDistSq, double slowingRadius)
 {
     _me  = me;
     Path = path;
     WaypointSeekDistSq = waypointSeekDistSq;
     SlowingRadius      = slowingRadius;
 }
Example #6
0
 private void OnEnable()
 {
     _playerMover  = GetComponent <IMover>();
     _playerAttack = GetComponent <IAttack>();
     _playerCamera = Camera.main;
     _groundPlane  = new Plane(Vector3.up, transform.position);
 }
 private void Start()
 {
     mover  = GetComponent <IMover>();
     wallet = GetComponent <IWallet>();
     named  = GetComponent <INamedRacer>();
     DataHolder.GetGameProcess().AddRacer(this);
 }
Example #8
0
 public override void FinishRace(int position)
 {
     _finishedRace = true;
     _mover        = null;
     this.ApplyForce(this.transform.forward * 5f);
     _playerAnimator.WinLose(position <= 0);
 }
Example #9
0
        private void Start()
        {
            Button newButton;

            _configMenu = new ConfigurationMenu("МЕНЮ", _prefabCamera, _prefabCube);
            _configs.Add(new ConfigurationMode1("ПЕРВЫЙ РЕЖИМ", _prefabCamera, _prefabCube));
            _configs.Add(new ConfigurationMode2("ВТОРОЙ РЕЖИМ", _prefabCamera, _prefabCube));

            _map        = _configMenu.CreateMap();
            _generator  = _configMenu.CreateGenerator();
            _factory    = _configMenu.CreateFactoryFigure();
            _mover      = _configMenu.CreateMover();
            _vectorDrop = _configMenu.CreateVectorDrop();
            _delayDrop  = _configMenu.DelayFrameDrop();

            _map.SetCamera(_prefabCamera);

            foreach (var config in _configs)
            {
                newButton = Instantiate(_prefabButton, this.transform).GetComponent <Button>();
                newButton.GetComponentInChildren <Text>().text = config.Name;
                newButton.onClick.AddListener(delegate { NewGame(config); });
                _buttons.Add(newButton);
            }

            newButton = Instantiate(_prefabButton, this.transform).GetComponent <Button>();
            newButton.GetComponentInChildren <Text>().text = "ВЫХОД";
            newButton.onClick.AddListener(ExitGame);
            _buttons.Add(newButton);
        }
Example #10
0
    public Locomotion(GameObject character, float rotationSpeed, float jumpHeight,
                      Transform viewTransform, AnimationCurve movementVectorBlend, AnimationCurve rotationBlend,
                      ICharacterInput characterInput, IMover characterMover)
    {
        _characterGameObject = character;
        _characterMover      = characterMover;
        _viewTransform       = viewTransform;
        _RotationSpeed       = rotationSpeed;
        _jumpHeight          = jumpHeight;
        _MovementVectorBlend = movementVectorBlend;
        _RotationBlend       = rotationBlend;
        _characterInput      = characterInput;


        _RootMotionDelta = _characterGameObject.GetComponentInChildren <RootMotionDelta>();
        _locomotionMode  = LocomotionMode.Idle;
        if (_RootMotionDelta != null)
        {
            _RootMotionDelta.OnRootPositionChange += HandleRootMotion;
        }

        //Rotate Character to Desired Forward called
        _RotateLocomotionEvents = _characterGameObject.GetComponentsInChildren <IRotateDesiredForwardEvent>();
        if (_RotateLocomotionEvents.Length > 0)
        {
            for (int i = 0; i < _RotateLocomotionEvents.Length; i++)
            {
                _RotateLocomotionEvents[i].OnCallDesiredForwardRotationChange += MoveToDesiredForward;
            }
        }
        UseMovementAngleDifference = true;

        OnStateChange?.Invoke(_state);
    }
Example #11
0
 private void Awake()
 {
     _defendables = new List <IDefendable>();
     _defendables.AddRange(GetComponents <IDefendable>());
     _mover = GetComponent <IMover>();
     field  = GetComponent <MagnetField>();
 }
Example #12
0
        public static Vector2D Arrive(Vector2D targetPos, IMover me, double slowingRadius)
        {
            Vector2D toTarget = targetPos - me.Pos;

            if (toTarget.LengthSquared() < 0.1)
            {
                return(new Vector2D());
            }

            //calculate the distance to the target position
            // Calculate the desired velocity
            var desiredVelocity = targetPos - me.Pos;
            var distance        = desiredVelocity.Length();

            // Slows when in slowingradius. Stops if in direct contact with target.
            if (distance < slowingRadius)
            {
                desiredVelocity = desiredVelocity.Truncate(me.MaxSpeed) * (distance / slowingRadius);
            }
            else
            {
                // Outside the slowing area.
                desiredVelocity = desiredVelocity.Truncate(me.MaxSpeed);
            }

            // Set the steering based on this
            return((desiredVelocity - me.Velocity).Truncate(me.MaxForce));
        }
Example #13
0
        public float GetCost(ITileMap map, IMover mover, PointInt32 point, PointInt32 start, PointInt32 target)
        {
            float dx = target.X - point.X;
            float dy = target.Y - point.Y;

            return((float)System.Math.Sqrt((double)((dx * dx) + (dy * dy))) * m_Coefficient);
        }
Example #14
0
        public void Prepare(PICProject project)
        {
            w = project.Relaxation;
            backscattering = project.Backscattering;
            alfa = project.BackscatteringAlfa;
            beta = project.BackscatteringBeta;
            step = project.Step;
            u = project.Voltage;

            particles = new ParticleArrayStorage<Particle>(project.ParticlesCount);
            boundaryConditions = new BoundaryConditions
            {
                Top = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Neumann },
                Bottom = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Neumann },
                Left = new BoundaryCondition { Value = x => 0, Type = BoundaryConditionType.Dirichlet },
                Right = new BoundaryCondition { Value = x => u, Type = BoundaryConditionType.Dirichlet }
            };

            emitter = new Emitter2D(0, project.EmitterBottom, 0, project.EmitterTop, project.ParticlesCount, 0, 0, -0.5 * Constants.ChildLangmuirCurrent(project.Length, u), step);
            mover = new Leapfrog();
            grid = new Grid2D();
            grid.InitializeGrid(project.GridN, project.GridM, 0, project.Length, 0, project.Height);
            mesh = new Mesh2D();
            mesh.InitializeMesh(grid.N * grid.M);
            interpolator = new CloudInCellCurrentLinkage(particles, grid, mesh, false);
            poissonSolver = new Poisson2DFdmSolver(grid, boundaryConditions);
            poissonSolver.FdmMatrix = poissonSolver.BuildMatrix();
            h = step * Constants.LightVelocity;
            Monitor = new PICMonitor(grid, mesh, particles, this);
            density = new double[grid.N * grid.M];
            Trajectories = new List<Tuple<int, double, double>>(particles.Count * 1000);
        }
        /// <summary>
        /// Initializes a new instance of the Game class.
        /// </summary>
        /// <param name="frame">Frame of type IFrame.</param>
        /// <param name="mover">Mover of type IMover.</param>
        public Game(IFrame frame, IMover mover)
        {
            this.Frame = frame;
            this.framePrototype = this.Frame.Clone();

            Validator.ValidateIsNotNull(mover, "mover");
            this.mover = mover;
        }
Example #16
0
 public Walk(IEntityController entityController, IMover mover, IMyAnimations animation, IFlip flip, params Transform[] patrols)
 {
     _mover            = mover;
     _animation        = animation;
     _flip             = flip;
     _patrols          = patrols;
     _entityController = entityController;
 }
 public Figure(IDrawer drawer, IScaler scaler, IUpdater updater, IMover mover, IRotator rotator)
 {
     Updater = updater;
     Scaler  = scaler;
     Drawer  = drawer;
     Mover   = mover;
     Rotator = rotator;
 }
Example #18
0
 /// <summary> Класс представляет кучу фигур, в которой они скапливаются </summary>
 /// <param name="cntClearAreaArg"> Минимальное количество областей которое будет удаляться за раз </param>
 public StackFigures(Vector3Int sizeMapArg, int cntAreaClearArg, IMover moverArg, ICommandObstructionDelete cmdObstructionDeleteArg)
 {
     _figures              = new List <IFigure>();
     _cntAreaClear         = cntAreaClearArg;
     _sizeFillArea         = sizeMapArg.x * sizeMapArg.z;
     _mover                = moverArg;
     _cmdObstructionDelete = cmdObstructionDeleteArg;
 }
        public State CreatNewStateFromMoving(IMover <State> mover)
        {
            State new_state = mover.Move(this);

            new_state.StateEvaluation();
            new_state.ReachGoal();
            return(new_state);
        }
    private void Awake()
    {
        _mover               = new Mover(this);
        _rotator             = new Rotator(this);
        _characterController = GetComponent <CharacterController>();

        PlayerInput.MoveModeTogglePressed += MoveModeTogglePressed;
    }
Example #21
0
 public GameEngine(IBasicIOProvider provider)
 {
     this.provider = provider;
     this.numberOfMoves = new Mover();
     this.stateManager = new StateManager();
     this.settingMatrixSize = new MatrixSizeSetter();
     this.player = new Player();
 }
Example #22
0
 public bool IsHit(IMover projectile)
 {
     return
         (this.Position.X < projectile.Position.X + projectile.Size.X &&
          this.Position.X + this.Size.X > projectile.Position.X &&
          this.Position.Y < projectile.Position.Y + projectile.Size.Y &&
          this.Position.Y + this.Size.Y > projectile.Position.Y);
 }
Example #23
0
 /// <summary>
 /// Осуществляет вращение объектов
 /// </summary>
 /// <param name="moverArg"> Класс для передвижения объектов </param>
 /// <param name="sizeMapArg"> Размер карты </param>
 public Rotator(IMover moverArg, Vector3Int sizeMapArg)
 {
     _sizeMap = sizeMapArg;
     _mover   = moverArg;
     _empty   = new GameObject();
     GameObject.DontDestroyOnLoad(_empty);
     _transform = _empty.transform;
 }
Example #24
0
 private void Awake()
 {
     mover            = new BarMover(bar, movementProperties);
     scaler           = new BarScaler(left, right);
     visibility       = GetComponent <SpriteVisibility>();
     objectVisibility = GetComponent <ObjectVisibility>();
     powerups         = GetComponent <BarPickups>();
     state            = State.Inactive;
 }
Example #25
0
 public IList<PointInt32> FindPath(IMover mover, PointInt32 start, PointInt32 target)
 {
     if (m_Map.IsBlocked(mover, target)) {
     return null;
       }
       m_Nodes.Clear();
       m_Nodes[start].Cost = 0f;
       m_Nodes[start].Depth = 0;
       m_Closed.Clear();
       m_Open.Clear();
       m_Open.Add(m_Nodes[start]);
       m_Nodes[target].Parent = null;
       int maxDepth = 0;
       while ((maxDepth < m_MaxSearchDistance) && (m_Open.Count != 0)) {
     var current = m_Open.First();
     if (current == m_Nodes[target]) {
       break;
     }
     m_Open.Remove(current);
     m_Closed.Add(current);
     for (int x = -1; x < 2; x++) {
       for (int y = -1; y < 2; y++) {
     if (((x != 0) || (y != 0)) && (m_AllowDiagMovement || ((x == 0) || (y == 0)))) {
       var point = new PointInt32(current.Point.X + x, current.Point.Y + y);
       if (IsValidLocation(mover, start, point)) {
         float nextStepCost = current.Cost + m_Map.GetCost(mover, current.Point, point);
         var neighbour = m_Nodes[point];
         m_Map.PathfinderCallback(point);
         if (nextStepCost < neighbour.Cost) {
           if (m_Open.Contains(neighbour)) {
             m_Open.Remove(neighbour);
           }
           if (m_Closed.Contains(neighbour)) {
             m_Closed.Remove(neighbour);
           }
         }
         if (!(m_Open.Contains(neighbour) || m_Closed.Contains(neighbour))) {
           neighbour.Cost = nextStepCost;
           neighbour.Heuristic = m_Heuristic.GetCost(m_Map, mover, point, start, target);
           maxDepth = System.Math.Max(maxDepth, neighbour.SetParent(current));
           m_Open.Add(neighbour);
         }
       }
     }
       }
     }
       }
       if (m_Nodes[target].Parent == null) {
     return null;
       }
       var path = new List<PointInt32>();
       for (var targetNode = m_Nodes[target]; targetNode != m_Nodes[start]; targetNode = targetNode.Parent) {
     path.Insert(0, targetNode.Point);
       }
       path.Insert(0, start);
       return path;
 }
Example #26
0
 public SaveManager(ITileManager manager, PlayerStatus status, BlockConverter converter, Center center, IMover mover)
 {
     Manager    = manager;
     Status     = status;
     Converter  = converter;
     Center     = center;
     Mover      = mover;
     Serializer = new XmlSerializer(typeof(Save));
 }
Example #27
0
    private void ListenOnWalk(bool walking)
    {
        if (_finishedRace)
        {
            return;
        }

        _mover = walking ? _walker : _runner;
    }
Example #28
0
 private void StartDash()
 {
     if (_canDash)
     {
         _mover = new Dasher(this);
         _playerAnimatorController.Dash();
         _ghostSpawner.StartSpawning();
         _canDash = false;
     }
 }
Example #29
0
 public MoveJob(ByteVector2[] path, Context context) : base(context)
 {
     _path  = path;
     _mover = context.OwnerContext() as IMover;
     if (_mover == null)
     {
         Debug.Log("ERROR: MoveJob assigned to non mover");
         context.WorkerContext().ClearJob();
     }
 }
Example #30
0
    protected void Awake()
    {
        _rigidbody      = this.GetComponent <Rigidbody>();
        _powerUpManager = this.GetComponent <RunnerPowerUpManager>();
        _playerAnimator = this.GetComponent <PlayerAnimatorController>();
        _runner         = new Mover(this, _maxRunSpeed);
        _walker         = new Mover(this, _walkingSpeed);

        _mover = _runner;
    }
Example #31
0
 public LeaderFollowingBehaviour(IGrouper me, IMover leader, double slowingRadius, double leaderBehindDist, double groupValue, double followValue = 1, double separationValue = 1)
 {
     _me              = me;
     Leader           = leader;
     SlowingRadius    = slowingRadius;
     LeaderBehindDist = leaderBehindDist;
     GroupValue       = groupValue;
     FollowValue      = followValue;
     SeparationValue  = separationValue;
 }
Example #32
0
 private void Awake()
 {
     _input     = new MobileInput();
     _mover     = new MoverWithVelocity(this, moveSpeed);
     _animation = new CharacterAnimation(GetComponent <Animator>());
     _flip      = new FlipWithTransform(this);
     _onGround  = GetComponent <IOnGround>();
     _jump      = new JumpMulti(GetComponent <Rigidbody2D>(), _onGround);
     _health    = GetComponent <IHealth>();
 }
Example #33
0
        private bool IsValidLocation(IMover mover, PointInt32 start, PointInt32 point)
        {
            bool invalid = (((point.X < 0) || (point.Y < 0)) || (point.X >= m_Map.Width)) || (point.Y >= m_Map.Height);

            if (!(invalid || ((start.X == point.X) && (start.Y == point.Y))))
            {
                invalid = m_Map.IsBlocked(mover, point);
            }
            return(!invalid);
        }
Example #34
0
 public void Init(IMover mover, Path path)
 {
     _sqrArriveDistance = _arriveDistance * _arriveDistance;
     _mover             = mover;
     _path = path;
     if (_path != null)
     {
         CurrentWaypoint = _path.GetClosestWaypoint(Position);
         _isInitialized  = true;
     }
 }
Example #35
0
 private void UpdateMovementMethod()
 {
     if (_mover is Mover)
     {
         _mover = new NavmeshMover(this);
     }
     else
     {
         _mover = new Mover(this);
     }
 }
Example #36
0
    void Awake()
    {
        BoxCollider2D boxCol = GetComponent<BoxCollider2D>();
        this.bottomOfColliderY = boxCol.offset.y - boxCol.size.y / 2;
        this.leftOfColliderX = boxCol.offset.x - boxCol.size.x / 2;
        this.rightOfColliderX = boxCol.offset.x + boxCol.size.x / 2;

        // Create the mask that lets us search for ground and other players below us
        this.groundAndDefaultLayerMask = 1 << LayerMask.NameToLayer("Ground") |
            1 << LayerMask.NameToLayer("Default");

        this.mover = null;
    }
Example #37
0
 public float GetCost(IMover mover, PointInt32 source, PointInt32 target)
 {
     return m_Map[target.X][target.Y].Difficulty;
 }
Example #38
0
 public bool IsBlocked(IMover mover, PointInt32 point)
 {
     return m_Map[point.X][point.Y].IsBlocker;
 }
Example #39
0
 public float GetCost(ITileMap map, IMover mover, PointInt32 point, PointInt32 start, PointInt32 target)
 {
     float dx = target.X - point.X;
       float dy = target.Y - point.Y;
       return (float)System.Math.Sqrt((double)((dx * dx) + (dy * dy))) * m_Coefficient;
 }
Example #40
0
 public float GetCost(ITileMap map, IMover mover, PointInt32 point, PointInt32 start, PointInt32 target)
 {
     return (System.Math.Abs(point.X - target.X) + System.Math.Abs(point.Y - target.Y)) * m_Coefficient;
 }
Example #41
0
 public float GetCost(ITileMap map, IMover mover, PointInt32 point, PointInt32 start, PointInt32 target)
 {
     return System.Math.Max(System.Math.Abs(point.X - target.X), System.Math.Abs(point.Y - target.Y));
 }
 public RestartCommand(IBasicUIRenderer renderer, string message, IMatrix matrix, IMover moves)
     : base(renderer, message)
 {
     this.Matrix = matrix;
     this.Moves = moves;
 }
Example #43
0
 protected virtual void Awake()
 {
     mover = GetComponent<IMover>();
     controller = GetComponent<IController>();
 }
Example #44
0
 private bool IsValidLocation(IMover mover, PointInt32 start, PointInt32 point)
 {
     bool invalid = (((point.X < 0) || (point.Y < 0)) || (point.X >= m_Map.Width)) || (point.Y >= m_Map.Height);
       if (!(invalid || ((start.X == point.X) && (start.Y == point.Y)))) {
     invalid = m_Map.IsBlocked(mover, point);
       }
       return !invalid;
 }