Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        //trail = new GameObject[maxTrail];
        Vector3    _pos = transform.position;
        GameObject _s   = Instantiate(stars, _pos, transform.rotation);

        _s.GetComponent <FollowPlayerJumping>().player = gameObject;
        _pos.y += 9;
        _s      = Instantiate(stars, _pos, transform.rotation);
        _s.GetComponent <FollowPlayerJumping>().player = gameObject;
        energy = GetComponent <Energy>();
        shield = GetComponent <Shield>();

        mm = GetComponent <ManagedMob>();
        for (int _count = 0; _count < Targetting.playerLeadTime; _count++)
        {
            if (showTargettingSolution)
            {
                trail[_count] = Instantiate(trailObject, transform.position, transform.rotation);
            }
        }
        gameScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <Game>();

        currentShip    = Instantiate(shipRenderer[(GGS.levelNumber - 1) % 8], transform);
        spriteRenderer = currentShip.GetComponent <SpriteRenderer>();
        xBar           = GameObject.Find("XBarParent");
        yBar           = GameObject.Find("YBar");
    }
Exemplo n.º 2
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (destroyed)
        {
            return;
        }

        GameObject _other    = collision.gameObject;
        string     _otherTag = _other.tag;

        if (_otherTag == "EnemyShip")
        {
            enemyExplodeSound.Play();
            // add the score manually, as the energy code only does it on 'natural' object destruction;
            GGS.AddScore(2);
            // ship collision with shields off is a bad thing.
            energy.DoDamage(150, 0, true);
            GameObject  _explo        = Instantiate(enemyExplosion, _other.transform.position, _other.transform.rotation);
            Rigidbody2D _explorb      = _explo.GetComponent <Rigidbody2D>();
            ManagedMob  _enemyManager = _other.GetComponent <ManagedMob>();
            _explorb.velocity = _enemyManager.velocity();

            Destroy(_other);
        }

        if (_otherTag == "EnemyBullet")
        {
            hitSound.Play();
            energy.DoDamage(_other.GetComponent <bullet>().payloadEnergy, 0, true);
            Instantiate(bulletDeath, _other.transform.position, _other.transform.rotation);
            Destroy(_other);
        }
    }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     energy              = initialEnergy;
     shield              = GetComponent <Shield>();
     parentMM            = GetComponent <ManagedMob>();
     gameScript          = GameObject.FindGameObjectWithTag("GameController").GetComponent <Game>();
     enemyExplosionSound = GameObject.Find("EnemyExplodeSound").GetComponent <AudioSource>();
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     player    = GameObject.FindGameObjectWithTag("PlayerShip");
     pc        = player.GetComponent <PlayerControl>();
     playerMob = player.GetComponent <ManagedMob>();
     myMM      = GetComponent <ManagedMob>();
     ec        = GetComponent <EnemyController>();
     for (int _count = 0; _count < playerLeadTime; _count++)
     {
         //trail[_count] = Instantiate(trailObject, transform.position, transform.rotation);
     }
 }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        _e  = GetComponent <Energy>();
        _rb = GetComponent <Rigidbody2D>();
        _v  = GetComponent <Visibility>();
        _t  = GetComponent <Targetting>();


        gameScript    = GameObject.FindGameObjectWithTag("GameController").GetComponent <Game>();
        playerMM      = gameScript.player.GetComponent <ManagedMob>();
        playerControl = gameScript.player.GetComponent <PlayerControl>();

        // Shotgun or rifle?
        _t.accuracy = Random.Range(0.6f, 2);

        // Gung-ho with his bullets?
        fireRate = Random.Range(0.05f, 1);

        // Once he's tracking us, how close will he get?
        tooClose = Random.Range(3.0f, 4.0f);

        // a chutzpah <=0 means the captain will happily sit right in the player's firing line
        chutzpah          = Random.Range(-10, 10);
        rendererTransform = transform.Find("Renderer");
        MM        = GetComponent <ManagedMob>();
        crosshair = Instantiate(crosshairObject, transform.position, transform.rotation);

        cloak = GetComponent <Cloak>();
        ChooseNewDestination();

        enemyShootSound  = GameObject.Find("EnemyShootSound").GetComponent <AudioSource>();
        enemyBounceSound = GameObject.Find("EnemyBumpSound").GetComponent <AudioSource>();
        enemyHitSound    = GameObject.Find("EnemyHurtSound").GetComponent <AudioSource>();

        if (Random.Range(0, 100) < bigBulletChance)
        {
            bigBullets = true;
        }
    }