Beispiel #1
0
        public override void Tick()
        {
            base.Tick();

            Debug.Log("Moving creature in tick...", "MOVEMENT");
            MovementStrategy.Move();

            CheckReproduction();
            CheckFood();
            CheckDeath();
        }
    public void Move(int hInput, int vInput, bool jumpStartInput, bool jumpContInput, float deltaTime)
    {
        Func <Func <MovementStrategy.Context, MovementStrategy> > move =
            () => _currentStrategy.Move(hInput, vInput, jumpStartInput, jumpContInput, deltaTime);

        var maxStrategyChanges = 5;
        Func <MovementStrategy.Context, MovementStrategy> instNewStrategy;

        if ((instNewStrategy = move()) != null)
        {
            if (maxStrategyChanges-- == 0)
            {
                throw new ApplicationException("Too many strategy changes");
            }

            SetStrategy(instNewStrategy);
        }

        if (_ctx.rb.velocity != Vector2.zero)
        {
            PreventCollisions(deltaTime);
        }
    }
 public void Move()
 {
     movementStrategy.Move();
 }
Beispiel #4
0
 protected void Move() => movementStrategy.Move(transform, movementDirection * speed, centerPoint);