void Awake()
 {
     //getting all the required components
     _rigidbody = GetComponent<Rigidbody2D>();
     _touchDetector = GetComponent<TouchDetector2D>();
     _playerInput = GetComponent<PlayerInput>();
 }
示例#2
0
    void Awake()
    {
        _touchDetector = gameObject.AddComponent<TouchDetector2D>();

        _touchDetector.TouchStarted += OnTouchStarted;
        _touchDetector.OnTouch += OnTouchStay;
        _touchDetector.TouchEnded += OnTouchExit;

        _objectPool = GameObject.FindGameObjectWithTag(Tags.GAMECONTROLLER).GetComponent<ObjectPool>();
    }
示例#3
0
    void Awake()
    {
        //adding all the player components
        _touchDetector = gameObject.AddComponent<TouchDetector2D>();
        gameObject.AddComponent<PlayerInput>();
        gameObject.AddComponent<Movement>();

        //getting components
        _rigidbody = GetComponent<Rigidbody2D>();
        _objectPool = GameObject.FindGameObjectWithTag(Tags.GAMECONTROLLER).GetComponent<ObjectPool>();
    }
示例#4
0
    public PlatformerMovement2D(Transform transformObject, Collider2D colliderObject, Rigidbody2D rigidbodyObject, TouchDetector2D touchDetector = null)
    {
        this.transformObject = transformObject;
        touchDetector2D      = (touchDetector != null) ? touchDetector : transformObject.gameObject.AddComponent <TouchDetector2D>();
        touchDetector2D.MarginBordersVertical   = 0.04f;
        touchDetector2D.MarginBordersHorizontal = 0.2f;
        touchDetector2D.ChecksPerSide           = 5;
        rbody2D = rigidbodyObject;
        coll2D  = colliderObject;
        touchDetector2D.RunOn(coll2D);

        touchDetector2D.HitEvent    += OnHitEvent;
        touchDetector2D.HitEndEvent += OnHitEndEvent;
    }
    void Start()
    {
        touch = gameObject.GetComponent<TouchDetector2D> ();
        touch.TouchStarted += TouchDetectionStart;
        touch.OnTouch += InTouch;
        touch.TouchEnded += TouchDetectionEnd;

        _oldGravityScale = _rigidbody.gravityScale;
    }
    // Use this for initialization
    void Start()
    {
        touchDetector = gameObject.GetComponent<TouchDetector2D> ();
        rigidBody = gameObject.GetComponent<Rigidbody2D> ();
        touchDetector.OnTouch += OnTouch;
        _player = gameObject.GetComponent<Player> ();

        _inAttackTimer = gameObject.AddComponent<ComTimer> ();
        _inAttackTimer.TimerEnded += EndTimer;
    }
 // Use this for initialization
 void Start()
 {
     _player = GetComponent<Player> ();
     _touchDetector = GetComponent<TouchDetector2D> ();
     _touchDetector.TouchStarted += OnTouch;
 }