예제 #1
0
 protected override void Awake()
 {
     base.Awake();
     sight        = GetComponent <EnemySight> ();
     weaponSystem = GetComponent <EnemyWeaponSystem> ();
     distraction  = GetComponent <EnemyDistraction>();
     plane        = GetComponent <EnemySightPlane> ();
     player       = GameObject.FindGameObjectWithTag("Player");
 }
예제 #2
0
    protected override void Awake()
    {
        base.Awake();
        GameObject parent = (transform.parent != null) ? transform.parent.gameObject : null;
        GameObject temp   = Instantiate(symbolObject, transform.position + new Vector3(0.0f, 1.25f, 0.0f), Quaternion.identity);

        if (temp)
        {
            symbol        = temp.GetComponent <Symbol>();
            symbol.Target = gameObject;
        }
        sight          = (parent != null) ? parent.GetComponentInChildren <EnemySight> () : GetComponent <EnemySight>();
        movement       = (parent != null) ? parent.GetComponentInChildren <EnemyMovement>() : GetComponent <EnemyMovement>();;
        weaponSystem   = (parent != null) ? parent.GetComponentInChildren <EnemyWeaponSystem>() : GetComponent <EnemyWeaponSystem>();
        distraction    = (parent != null) ? parent.GetComponentInChildren <EnemyDistraction>() : GetComponent <EnemyDistraction>();
        plane          = (parent != null) ? parent.GetComponentInChildren <EnemySightPlane>() : GetComponent <EnemySightPlane>();
        renderer       = GetComponent <MeshRenderer>();
        player         = GameObject.FindGameObjectWithTag("Player");
        playerMovement = player.GetComponent <PlayerMovement>();
        reporter       = GetComponent <KillReporter>();
    }
예제 #3
0
파일: Weapon.cs 프로젝트: IllBond/SpaceShip
    private float _timer;    // Производить выстрел если текущее время больше _timer


    private void OnEnable()
    {
        //Как только класс начнет существовать он передаст в WeaponSystem и станет орудием этого класса
        // FindObjectOfType<WeaponSystem>().AddWeapon(this);

        BaseWeaponSystem wp = GetComponentInChildren <BaseWeaponSystem>();

        if (wp == null)
        {
            wp = GetComponentInParent <BaseWeaponSystem>();
        }

        if (wp is WeaponSystem)
        {
            WeaponSystem weaponSystem = wp as WeaponSystem; // Нисходяшее приведение из высшего порядка в нисший
            weaponSystem.AddWeapon(this);
        }
        else if (wp is EnemyWeaponSystem)
        {
            EnemyWeaponSystem weaponSystem = wp as EnemyWeaponSystem; // Нисходяшее приведение из высшего порядка в нисший
            weaponSystem.AddWeapon(this);
        }
    }