예제 #1
0
    void ChasingBehaviour()
    {
        if (!CheckInDistance())
        {
            ChangeBehaviour(GroundEnemyBehaviour.Idle); return;
        }

        this.CalculatePath(player.transform.position);

        this.CheckWaypointDistance();

        this.myMotor.ReceiveInput(this.DirToPath);
        this.visionModule.SetFacingDir(new Vector2(1, 0) * (this.DirToPath.x < 0 ? -1 : 1));

        if (this.jumpModule != null)
        {
            bool tooHigh = this.PathPos.y > this.transform.position.y + this.waypointMinDistance;
            bool edgeWay = this.collisionModule.WillFall(this.visionModule.FacingDir.x);

            if (tooHigh || edgeWay)
            {
                jumpModule.Execute();
            }
        }
    }
예제 #2
0
        public void DoNotPutCatOnAirWithAirForce()
        {
            var cat       = ACat(withStatus: Grounded);
            var inGameCat = AnInGameCat(withCat: cat);
            var jump      = new Jump(inGameCat);
            var airForce  = new Vector3(0, 0, 0);

            jump.Execute(airForce);

            var expectedCat = ACat(withStatus: Grounded, withAirForce: airForce);
            var actualCat   = inGameCat.Get();

            Assert.AreEqual(expectedCat, actualCat);
        }
예제 #3
0
        public void DoNotAddAirForceWhenAlreadyJumping()
        {
            var initAirForce = new Vector3(0, 2, 0);
            var cat          = ACat(withStatus: Jumping, withAirForce: initAirForce);
            var inGameCat    = AnInGameCat(withCat: cat);
            var jump         = new Jump(inGameCat);
            var airForce     = new Vector3(0, 4, 0);

            jump.Execute(airForce);

            var expectedCat = ACat(withStatus: Jumping, withAirForce: initAirForce);
            var actualCat   = inGameCat.Get();

            Assert.AreEqual(expectedCat, actualCat);
        }
예제 #4
0
        public void ExecuteMovement(MovementType movementType, Rigidbody2D rb, float moveSpeed, float jumpVelocity)
        {
            bool isGrounded = IsGrounded();

            if (movementType == MovementType.Jump && isGrounded)
            {
                rb.velocity = Jump.Execute(new JumpInput {
                    RigidBody = rb, JumpVelocity = jumpVelocity
                });
            }
            else if (movementType == MovementType.Stay)
            {
                // pressing no keys
            }
        }
            public void Should_jump_backwards_relative_it_self_given_a_negative_parameter(int pc, int parameter)
            {
                var cpu = new CPU
                {
                    ProgramCounter = pc
                };
                var jmp = new Jump
                {
                    Arguments = new[] { parameter }
                };

                jmp.Execute(cpu);

                Assert.Equal(cpu.ProgramCounter, pc + parameter);
            }
예제 #6
0
        private void Update()
        {
            var h = Input.GetAxis("Horizontal");
            var v = Input.GetAxis("Vertical");

            if (Input.GetKeyDown(KeyCode.Space))
            {
                _jump.Execute(_airForce);
                _catView.MakeJump(_inGameCat.Get());
            }


            if (!(Math.Abs(h) > 0.1f) && !(Math.Abs(v) > 0.1f))
            {
                return;
            }
            _moveCatCat.Execute(new Vector3(h, 0, v), Time.deltaTime);
            _catView.UpdatePosition(_inGameCat.Get());
        }
예제 #7
0
    private void FixedUpdate()
    {
        FlyAnimator.enabled = false;

        if (GroundCheck.Evaluate())
        {
            FlyAnimator.Restart();
            SR.sprite = JumpSprite;
            Jump.Execute();
            SR.sprite = JumpSprite;
        }
        else if (Fly.Execute())
        {
            FlyAnimator.enabled = true;
        }
        else if (RB.velocity.y > 0f)
        {
            SR.sprite = JumpSprite;
        }
        else
        {
            SR.sprite = GlideSprite;
        }
    }
예제 #8
0
파일: Pop.cs 프로젝트: project-aone/cangone
 void ExecuteJump(float force)
 {
     jump.Execute(rb, force);
     AudioManager.Instance.PlaySoundOnce(caller: this, sound: jumpAudioSource);
     timeInStandBy = 0;
 }