Example #1
0
    void Start()
    {
        _enemyFinder = GetComponent <EnemyFinder>();
        if (_enemyFinder == null)
        {
            gameObject.AddComponent <EnemyFinder>();
            _enemyFinder = GetComponent <EnemyFinder>();
        }

        _playerHealth = GetComponent <Health>();
        if (_playerHealth == null)
        {
            gameObject.AddComponent <Health>();
            _playerHealth = GetComponent <Health>();
        }

        _playerShoot = GetComponent <PlayerShoot>();
        if (_playerShoot == null)
        {
            gameObject.AddComponent <PlayerShoot>();
            _playerShoot = GetComponent <PlayerShoot>();
        }


        rb              = GetComponent <Rigidbody2D>();
        _animator       = GetComponent <Animator>();
        _playerMovement = GetComponent <PlayerMovement>();
        _arduinoInput   = GameObject.FindWithTag(Values.ArduinoInputManager).GetComponent <ArduinoInput>();

        _playerShoot.wantsToShoot.AddListener(SetTargetForShooting);
        OnPlayerDeathEvent.AddListener(OnDeath);
    }
Example #2
0
 public void Awake()
 {
     enemiesInSight           = new List <Enemy>();
     enemyFinder              = GetComponentInChildren <EnemyFinder>();
     enemyFinder.onEnemyEnter = OnEnemyEnter;
     enemyFinder.onEnemyExit  = OnEnemyExit;
     enemyFinder.SetRadius(range);
 }
Example #3
0
    //this can be childed to the gameobject because it has no trigger colliders

    void CreateFinder()
    {
        myTracker = new GameObject();
        myTracker.transform.parent        = gameObject.transform;
        myTracker.transform.localScale    = new Vector3(1, 1, 1);
        myTracker.transform.localPosition = new Vector3(0, 0, (lockOnDistance / 2));
        myTracker.transform.localRotation = Quaternion.Euler(90, 0, 0);
        myTracker.name = "Finder";

        EnemyFinder myFinder = myTracker.AddComponent <EnemyFinder>();

        myFinder.AttachPlayer(gameObject);
        myFinder.RequiredData(useTargetingSystem);

        CapsuleCollider myCollider = myTracker.AddComponent <CapsuleCollider>();

        myCollider.isTrigger = true;
        myCollider.radius    = 1;
        myCollider.height    = lockOnDistance;
    }
Example #4
0
 private void Awake()
 {
     instance = this;
 }