示例#1
0
 // Use this for initialization
 void Start()
 {
     _IsMenuMode = false;
     rb          = GetComponent <Rigidbody2D>();
     jump        = GetComponent <JumpBehaviour>();
     behaviour   = GetComponent <PlayerBehaviour>();
 }
示例#2
0
 override public void Start()
 {
     base.Start();
     this.animator      = GetComponent <Animator>();
     this.jumpBehaviour = GetComponentInChildren <JumpBehaviour>();
     this.moveBehaviour = GetComponent <LinearMovementBehaviour>();
 }
    private float CalculateJumpPrice(JumpBehaviour jumpBehaviour)
    {
        float moneyToRecover = GameData.jumpBehaviour.GetPrice();
        float moneyToSpend   = jumpBehaviour.GetPrice();

        return(moneyToRecover - moneyToSpend);
    }
示例#4
0
 void Start()
 {
     _jumpBehaviour = GetComponent <JumpBehaviour>();
     _player        = GetComponentInParent <Actor>();
     ani            = GetComponent <Animator>();
     PrimeCombos();
 }
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     rb                       = animator.GetComponent <Rigidbody2D>();
     jumpBehaviour            = animator.GetBehaviour <JumpBehaviour>();
     rb.velocity              = -animator.transform.right * dashSpeed;
     dashCounts              += 1;
     jumpBehaviour.jumpCounts = 0;
 }
示例#6
0
 public ConditionalJump(ValueReference conditional, int dest, JumpBehaviour when)
 {
     if (conditional == null)
     {
         throw new ArgumentNullException(nameof(conditional));
     }
     this.Conditional = conditional;
     this.JumpWhen    = when;
     this.Destination = dest;
 }
示例#7
0
    private void Awake()
    {
        feet             = GetComponentInChildren <PlayerFeetScript>();
        rigid            = GetComponent <Rigidbody2D>();
        playerAttributes = GetComponent <PlayerAttributes>();
        playerRenderer   = GetComponent <SpriteRenderer>();

        jumpBehaviour = GameData.jumpBehaviour;
        GameObject.FindGameObjectWithTag("Upgrade").GetComponent <SpriteRenderer>().enabled = GameData.springUpdate;
    }
示例#8
0
 protected override void StartGame()
 {
     _occupiedAttackPlace = new List <Transform>(_freeAttackPlace.Count);
     _jumpBehaviour       = GetComponent <JumpBehaviour>();
     _spriteRenderer      = GetComponent <SpriteRenderer>();
     //_rigidBody = GetComponent<Rigidbody2D>();
     _fight     = GetComponent <FightingCombo>();
     _transform = transform;
     //_spriteRenderer.receiveShadows = true;
     //_spriteRenderer.shadowCastingMode = ShadowCastingMode.On;
 }
    private void BuyJumpBehaviour(JumpBehaviour newJumpBehaviour)
    {
        if (GameData.jumpBehaviour.GetType() != newJumpBehaviour.GetType())
        {
            float moneyDelta = CalculateJumpPrice(newJumpBehaviour);

            GameData.hp += moneyDelta;
            playerAttributes.HealthChange(moneyDelta);

            GameData.jumpBehaviour = newJumpBehaviour;
            UpdatePriceTexts();
        }
    }
示例#10
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // Update from player
        if (__player != null)
        {
            JumpBehaviour   jumpBehaviour   = __player.GetComponent <JumpBehaviour>();
            PlayerBehaviour playerBehaviour = __player.GetComponent <PlayerBehaviour>();

            Rigidbody2D    rb2D  = __player.GetComponent <Rigidbody2D>();
            SpriteRenderer sr    = __player.GetComponent <SpriteRenderer>();
            Vector2        input = jumpBehaviour.getInput();
            if (jumpBehaviour && playerBehaviour && rb2D)
            {
                hasYMotion = rb2D.velocity.y != 0f;
                //hasXMotion = rb2D.velocity.x != 0f;
                hasXMotion = input.x != 0;
                isMoving   = hasXMotion || hasYMotion;

                // check walking
                isWalking = (jumpBehaviour.IsGrounded()) && hasXMotion && !hasYMotion;

                // check running
                isRunning = (jumpBehaviour.IsGrounded()) && hasXMotion && !hasYMotion && (playerBehaviour.PlayerSpeed >= playerBehaviour.PlayerMaxSpeed);

                isJumping = Input.GetKey(KeyCode.UpArrow);

                // check in air
                isInAir = (!jumpBehaviour.IsGrounded()) && !(jumpBehaviour.AskedForJump) && hasYMotion;

                // Update animator
                animator.SetBool(paramIsJumping, isJumping);
                animator.SetBool(paramIsWalking, isWalking);
                animator.SetBool(paramIsRunning, isRunning);

                animator.SetBool(paramIsInAir, isInAir);
                animator.SetBool(paramDoubleJump, jumpBehaviour.CanDoubleJump);

                // Flip if needed
                if (__spriteIsFacingRight && jumpBehaviour.getInput().x < 0)
                {
                    flip(sr);
                }
                else if ((!__spriteIsFacingRight) && jumpBehaviour.getInput().x > 0)
                {
                    flip(sr);
                }
            }
        }
    }
示例#11
0
    protected virtual void Start()
    {
        _objectPool = ObjectPooler.Instance;

        _rigidBody2D            = GetComponent <Rigidbody2D>();
        _spriteRenderer         = GetComponent <SpriteRenderer>();
        _input                  = GetComponent <Input>();
        _movementBehaviour      = GetComponent <MovementBehaviour>();
        _jumpBehaviour          = GetComponent <JumpBehaviour>();
        _playerCheckBehaviour   = GetComponent <PlayerCheckBehaviour>();
        _dashBehaviour          = GetComponent <DashBehaviour>();
        _damageBehaviour        = GetComponent <DamageBehaviour>();
        _audioBehaviour         = GetComponent <AudioBehaviour>();
        _specialEffectBehaviour = GetComponent <SpecialEffectBehaviour>();
        _scoreBehaviour         = GetComponent <ScoreBehaviour>();
    }
示例#12
0
 void Start()
 {
     anim          = GetComponent <Animator>();
     jumpBehaviour = anim.GetBehaviour <JumpBehaviour>();
 }
示例#13
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     timeValue     = timer;
     jumpBehaviour = animator.GetBehaviour <JumpBehaviour>();
 }