コード例 #1
0
ファイル: GroundCheck.cs プロジェクト: p-buse/break
    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;
        }
    }
コード例 #2
0
 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;
 }
コード例 #3
0
 public ChasePlayer(IMover mover, IFlip flip, IMyAnimations animation, System.Func <bool> isPlayerRightSide)
 {
     _mover             = mover;
     _flip              = flip;
     _animation         = animation;
     _isPlayerRightSide = isPlayerRightSide;
 }
コード例 #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;
        }
    }
コード例 #5
0
 public FollowPathBehaviour(IMover me, Route path, double waypointSeekDistSq, double slowingRadius)
 {
     _me  = me;
     Path = path;
     WaypointSeekDistSq = waypointSeekDistSq;
     SlowingRadius      = slowingRadius;
 }
コード例 #6
0
ファイル: KeyboardInput.cs プロジェクト: scryptan/RogueLite
 private void OnEnable()
 {
     _playerMover  = GetComponent <IMover>();
     _playerAttack = GetComponent <IAttack>();
     _playerCamera = Camera.main;
     _groundPlane  = new Plane(Vector3.up, transform.position);
 }
コード例 #7
0
 private void Start()
 {
     mover  = GetComponent <IMover>();
     wallet = GetComponent <IWallet>();
     named  = GetComponent <INamedRacer>();
     DataHolder.GetGameProcess().AddRacer(this);
 }
コード例 #8
0
 public override void FinishRace(int position)
 {
     _finishedRace = true;
     _mover        = null;
     this.ApplyForce(this.transform.forward * 5f);
     _playerAnimator.WinLose(position <= 0);
 }
コード例 #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);
        }
コード例 #10
0
ファイル: Locomotion.cs プロジェクト: apsgk9/Marianne
    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);
    }
コード例 #11
0
 private void Awake()
 {
     _defendables = new List <IDefendable>();
     _defendables.AddRange(GetComponents <IDefendable>());
     _mover = GetComponent <IMover>();
     field  = GetComponent <MagnetField>();
 }
コード例 #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));
        }
コード例 #13
0
ファイル: EuclideanDistance.cs プロジェクト: svejdo1/astar
        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);
        }
コード例 #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);
        }
コード例 #15
0
        /// <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;
        }
コード例 #16
0
ファイル: Walk.cs プロジェクト: kafkasap/DungeonEscape
 public Walk(IEntityController entityController, IMover mover, IMyAnimations animation, IFlip flip, params Transform[] patrols)
 {
     _mover            = mover;
     _animation        = animation;
     _flip             = flip;
     _patrols          = patrols;
     _entityController = entityController;
 }
コード例 #17
0
 public Figure(IDrawer drawer, IScaler scaler, IUpdater updater, IMover mover, IRotator rotator)
 {
     Updater = updater;
     Scaler  = scaler;
     Drawer  = drawer;
     Mover   = mover;
     Rotator = rotator;
 }
コード例 #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;
 }
コード例 #19
0
        public State CreatNewStateFromMoving(IMover <State> mover)
        {
            State new_state = mover.Move(this);

            new_state.StateEvaluation();
            new_state.ReachGoal();
            return(new_state);
        }
コード例 #20
0
    private void Awake()
    {
        _mover               = new Mover(this);
        _rotator             = new Rotator(this);
        _characterController = GetComponent <CharacterController>();

        PlayerInput.MoveModeTogglePressed += MoveModeTogglePressed;
    }
コード例 #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();
 }
コード例 #22
0
ファイル: PlayerShip.cs プロジェクト: Tobraef/Lost-Boy
 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);
 }
コード例 #23
0
ファイル: Rotator.cs プロジェクト: Eggoorr/TetrisTestWork
 /// <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;
 }
コード例 #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;
 }
コード例 #25
0
ファイル: AStarPathfinder.cs プロジェクト: svejdo1/astar
 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;
 }
コード例 #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));
 }
コード例 #27
0
    private void ListenOnWalk(bool walking)
    {
        if (_finishedRace)
        {
            return;
        }

        _mover = walking ? _walker : _runner;
    }
コード例 #28
0
 private void StartDash()
 {
     if (_canDash)
     {
         _mover = new Dasher(this);
         _playerAnimatorController.Dash();
         _ghostSpawner.StartSpawning();
         _canDash = false;
     }
 }
コード例 #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();
     }
 }
コード例 #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;
    }
コード例 #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;
 }
コード例 #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>();
 }
コード例 #33
0
ファイル: AStarPathfinder.cs プロジェクト: svejdo1/astar
        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);
        }
コード例 #34
0
ファイル: PathUser.cs プロジェクト: J3573R/Programming-1-2017
 public void Init(IMover mover, Path path)
 {
     _sqrArriveDistance = _arriveDistance * _arriveDistance;
     _mover             = mover;
     _path = path;
     if (_path != null)
     {
         CurrentWaypoint = _path.GetClosestWaypoint(Position);
         _isInitialized  = true;
     }
 }
コード例 #35
0
 private void UpdateMovementMethod()
 {
     if (_mover is Mover)
     {
         _mover = new NavmeshMover(this);
     }
     else
     {
         _mover = new Mover(this);
     }
 }
コード例 #36
0
ファイル: GroundCheck.cs プロジェクト: p-buse/break
    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;
    }
コード例 #37
0
ファイル: MapSample.cs プロジェクト: svejdo1/astar
 public float GetCost(IMover mover, PointInt32 source, PointInt32 target)
 {
     return m_Map[target.X][target.Y].Difficulty;
 }
コード例 #38
0
ファイル: MapSample.cs プロジェクト: svejdo1/astar
 public bool IsBlocked(IMover mover, PointInt32 point)
 {
     return m_Map[point.X][point.Y].IsBlocker;
 }
コード例 #39
0
ファイル: EuclideanDistance.cs プロジェクト: svejdo1/astar
 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;
 }
コード例 #40
0
ファイル: ManhattanDistance.cs プロジェクト: svejdo1/astar
 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;
 }
コード例 #41
0
ファイル: DiagonalDistance.cs プロジェクト: svejdo1/astar
 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));
 }
コード例 #42
0
 public RestartCommand(IBasicUIRenderer renderer, string message, IMatrix matrix, IMover moves)
     : base(renderer, message)
 {
     this.Matrix = matrix;
     this.Moves = moves;
 }
コード例 #43
0
ファイル: Unit.cs プロジェクト: Sundem/PacManProject
 protected virtual void Awake()
 {
     mover = GetComponent<IMover>();
     controller = GetComponent<IController>();
 }
コード例 #44
0
ファイル: AStarPathfinder.cs プロジェクト: svejdo1/astar
 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;
 }