// Use this for initialization
 void Start()
 {
     _deadZone = 0.01f;
     _checker = GetComponentInChildren<GroundChecker>();
     _jumpSpeedLimit = Physics2D.gravity.y/10;
     //cache and deactivate pogo stick
     _pogoStick = transform.Find("PogoStick");
     _pogoStick.gameObject.SetActive(false);
 }
Exemple #2
0
    public Jumper(float jumpForce, int maxSequentJumps, GroundChecker groundChecker, UnityAction onJumpPerformed, UnityAction onGround)
    {
        this.jumpForce       = jumpForce;
        this.maxSequentJumps = maxSequentJumps;
        this.groundChecker   = groundChecker;

        this.onJumpPerformed = new UnityEvent();
        this.onJumpPerformed.AddListener(onJumpPerformed);
        this.onGround = new UnityEvent();
        this.onGround.AddListener(onGround);

        isJumping      = false;
        remainingJumps = 0;
    }
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        animator       = GetComponent <Animator>();
        rb2d           = GetComponent <Rigidbody2D>();
        spriteRenderer = GetComponent <SpriteRenderer>();
        groundChecker  = groundCheckBox.GetComponent <GroundChecker>();
        rightChecker   = rightCheckerBox.GetComponent <SideCheckerRight>();
        leftChecker    = leftCheckerBox.GetComponent <SideCheckerLeft>();

        currentHealth = maxHealth;
        SetHealth(currentHealth, maxHealth);

        lastPos = rb2d.velocity;
    }
Exemple #4
0
        private void MapGroundCheckers()
        {
            var groundCheckers = GetComponentsInChildren <GroundChecker>();

            foreach (var checker in groundCheckers)
            {
                if (checker.name.ToLower().Contains("sensor"))
                {
                    turnChecker = checker;
                }
                else
                {
                    jumpCheck = checker;
                }
            }
        }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        if (jumpType == JumpType.Charge)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                _jumpTimer.Start();
            }

            if (Input.GetKeyUp(KeyCode.Space))
            {
                if (GroundChecker.Check(groundCheck))
                {
                    _jumpTimer.Stop();
                    _jump = true;
                }
                else
                {
                    _jumpTimer.Stop();
                    _jumpVelocity = 0;
                }
            }
        }

        if (jumpType == JumpType.Flat)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                _jump = true;
            }
        }

        if (jumpType == JumpType.Hold)
        {
            if (GroundChecker.Check(groundCheck) && Input.GetKeyDown(KeyCode.Space))
            {
                _jump           = true;
                jumpTimeCounter = jumpTime;
            }
        }

        if (Input.GetKeyUp(KeyCode.Space))
        {
            jumpTimeCounter = 0;
            _jump           = false;
        }
    }
Exemple #6
0
    private void Move()
    {
        if (GroundChecker.Check(groundCheck))
        {
            _speed = Input.GetKey(KeyCode.LeftShift) ?
                     _player.speed * sprintSpeedMultiplier :
                     _player.speed;
        }
        Vector3 targetVelocity =
            new Vector2((_movement * _speed) * 10f * Time.fixedDeltaTime, _rb.velocity.y);

        _rb.velocity = Vector3.SmoothDamp(
            _rb.velocity,
            targetVelocity,
            ref _velocity,
            movementSmoothing);
    }
    void Start()
    {
        cheatmode = FindObjectOfType <HotAirBalloon>();

        viewer = FindObjectOfType <CameraMovement>().transform;

        sidewaysSpeed = new AxisSpeed("X", 1, SpeedBuildup, SpeedFalloff);
        forwardSpeed  = new AxisSpeed("Y", 1, SpeedBuildup, SpeedFalloff);

        directions = new List <AxisSpeed>();
        directions.Add(sidewaysSpeed);
        directions.Add(forwardSpeed);

        rb = GetComponent <Rigidbody>();
        c  = GetComponent <Climber>();
        g  = GetComponentInChildren <GroundChecker>();
    }
Exemple #8
0
        private void Start()
        {
            rb               = GetComponent <Rigidbody2D>();
            fallChecker      = GetComponent <FallChecker>();
            itemCollectable  = GetComponent <ItemCollectable>();
            parentConstraint = GetComponent <ParentConstraint>();

            var groundCheckers = GetComponentsInChildren <GroundChecker>();

            side1Check = groundCheckers[0];
            side2Check = groundCheckers[1];

            rb.gravityScale = 0;
            spawnLocation   = transform.position;

            itemCollectable.Collected  += () => Collected();
            itemCollectable.Dropped    += () => Dropped();
            itemCollectable.StateReset += () => Reset();
        }
    // Start is called before the first frame update
    void Start()
    {
        direction            = (transform.localScale.x > 0.0f) ? 1 : -1; // tada
        defaultScaleX        = transform.localScale.x * direction;
        transform.localScale = new Vector3(
            defaultScaleX, transform.localScale.y, transform.localScale.z);

        rb            = GetComponent <Rigidbody2D>();
        box           = GetComponent <BoxCollider2D>();
        groundChecker = GetComponentInChildren <GroundChecker>();
        animator      = GetComponent <Animator>(); // tada
        actionInput   = ActionInput.Instatnce;
        audioSource   = GetComponent <AudioSource>();
        GameObject tmpObj = GameObject.Find("Wind");

        if (tmpObj != null)
        {
            wind = tmpObj.GetComponent <WindPatericle>();
        }
        defaultGravity = gravity;
    }
        private void Start()
        {
            transform.position = rhinoTrainBase.transform.position;
            rb       = GetComponent <Rigidbody>();
            animator = GetComponent <Animator>();
            source   = GetComponent <AudioSource>();

            groundChecker = GetComponentInChildren <GroundChecker>();
            sM            = new RhinoTrainStateMachine(this);
            rhinoTrainBase.OnSoundHeard += CatchActivation;
            //SendMessage("GetFSM", sM);

            if (rhinoTrainBase.target.x > rhinoTrainBase.transform.position.x)
            {
                transform.eulerAngles = new Vector3(0, 90, 0);
                MoveDirectionIsRight  = true;
            }
            else
            {
                transform.eulerAngles = new Vector3(0, -90, 0);
                MoveDirectionIsRight  = false;
            }
        }
Exemple #11
0
 // Use this for initialization
 void Start()
 {
     _rb             = GetComponent <Rigidbody2D> ();
     _ground_checker = GetComponentInChildren <GroundChecker> ();
     SetGravity();
 }
Exemple #12
0
 new void Awake()
 {
     base.Awake();
     efd = GetComponent <GroundChecker>();
 }
Exemple #13
0
 new void Awake()
 {
     base.Awake();
     currentSpeed = speed;
     efd          = GetComponent <GroundChecker>();
 }
 public void Start()
 {
     ground  = FindObjectOfType <GroundChecker>();
     climber = FindObjectOfType <Climber>();
 }
Exemple #15
0
 private void groundStateChanged(GroundChecker grounder)
 {
     //Show when in the air
     showClouds(!airSliceAbility.canReset(grounder));
 }
Exemple #16
0
 private void Awake()
 {
     _rigidbody2D   = GetComponent <Rigidbody2D>();
     _groundChecker = GetComponent <GroundChecker>();
     _jumpImpulse   = Mathf.Sqrt(2 * (-Physics2D.gravity.y) * _jumpHeight) * _rigidbody2D.mass;
 }
Exemple #17
0
    //private void OnDrawGizmos()
    //{
    //    Handles.color = GizmosColor;

    //    Handles.DrawWireDisc(transform.position + Offset,
    //                         Vector3.forward, Radius);
    //}

    private void Awake()
    {
        GetAnimator   = GetComponent <Animator>();
        Rigid         = GetComponent <Rigidbody2D>();
        groundChecker = GetComponent <GroundChecker>();
    }
Exemple #18
0
 // Start is called before the first frame update
 private void Start()
 {
     _velocity = Vector3.zero;
     _GChecker = GetComponent <GroundChecker>();
 }
    void Start()
    {
        // Set up all the things!
        _animator = GetComponent<Animator>();
        _rigidBody = GetComponent<Rigidbody>();
        groundCheck = GetComponentInChildren<GroundChecker>();

        moveDirection = new Vector3(0.0f, 0.0f, 0.0f);

        jumpTrigger = false;
        maxSpeed = baseMaxSpeed;
    }
Exemple #20
0
 // Start is called before the first frame update
 void Start()
 {
     FactorVector = Vector3.one;
     _GChecker    = GetComponent <GroundChecker>();
     _cGrav       = GetComponent <CharacterGravity>();
 }
Exemple #21
0
    // Use this for initialization
    protected override void OnStart()
    {
        animator = (Animator)GetComponent ("Animator");
        //pAction = (PlayerAction)GetComponent("PlayerAction");
        eManager = (EntityStateManager)GetComponent ("EntityStateManager");
        pGroundChecker = (GroundChecker)GetComponent ("GroundChecker");
        //eManager = pAction.eManager;

        //pGroundChecker = pAction.pGroundChecker;
    }
Exemple #22
0
 private void Awake()
 {
     _mover         = GetComponent <Mover>();
     _groundChecker = GetComponent <GroundChecker>();
     _rigidbody     = GetComponent <Rigidbody2D>();
 }
Exemple #23
0
 void Start()
 {
     mainCamera    = Camera.main.transform.parent;
     animator      = GetComponentInChildren <Animator>();
     groundChecker = GetComponentInChildren <GroundChecker>();
 }
Exemple #24
0
 //public float[] fiveangles;
 void Awake()
 {
     // Get component on the same GameObject
     angle = GetComponent <GroundChecker>();
     //Debug.Log("Runningavgscript did not find an angle.");
 }
Exemple #25
0
 private void Start()
 {
     _ball        = GetComponent <Rigidbody2D>();
     _jumpChecker = GetComponent <GroundChecker>();
 }
 // Use this for initialization
 void Start()
 {
     _groundChecker = GetComponent<GroundChecker>();
     _movementChecker = GetComponent<MovementChecker>();
     _movementChecker.X_PositionChanged += XPositionChanged;
     _movementChecker.MovementStopped += DetectedStopping;
     _delayManager = GetComponent<DelayManager>();
     _explosiveObject = GetComponent<ExplosiveObject>();
 }
 private void Awake()
 {
     groundChecker = GetComponent <GroundChecker>();
     fpsAnimator   = GetComponent <FpsAnimator>();
 }
Exemple #28
0
 public PlayerVerticalMovement(CharacterController characterController, float gravity)
 {
     GroundChecker = new GroundChecker(characterController);
     Gravity       = gravity;
 }
Exemple #29
0
 private void Awake()
 {
     rb = GetComponent <Rigidbody2D>();
     movementFromInput = GetComponent <MovementFromInput>();
     groundChecker     = GetComponent <GroundChecker>();
 }
 void Start()
 {
     _rigidbody     = GetComponent <Rigidbody2D>();
     _groundChecker = GetComponent <GroundChecker>();
     _animator      = GetComponent <Animator>();
 }
 // Use this for initialization
 void Start()
 {
     groundChecker   = GetComponent <GroundChecker> ();
     rigidBody       = GetComponent <Rigidbody> ();
     jumpTimeCounter = jumptimer;
 }
Exemple #32
0
 private void Awake()
 {
     rb2d          = GetComponent <Rigidbody2D>();
     anim          = GetComponent <Animator>();
     groundChecker = GetComponentInChildren <GroundChecker>();
 }
Exemple #33
0
 private void Start()
 {
     _rigidbody     = GetComponent <Rigidbody>();
     _groundChecker = GetComponent <GroundChecker>();
 }
Exemple #34
0
 private void Awake()
 {
     _GChecker      = GetComponent <GroundChecker>();
     FactorVector   = Vector3.one;
     MovementVector = Vector3.zero;
 }