Пример #1
0
    private void SpawnPirate()
    {
        // Spawn at a random x,z vector
        Vector3         spawn  = Helpers.RandNormalXZ().normalized *m_spawnDistance;
        PirateBehaviour pirate = Instantiate(m_piratePrefab, transform);

        pirate.transform.localPosition = spawn;
    }
Пример #2
0
    private void OnPirateDestroyed(PirateBehaviour behaviour)
    {
        m_activePirates.Remove(behaviour);

        if (m_activePirates.Count == 0)
        {
            SpawnNextWave();
        }
    }
Пример #3
0
    private void OnCollisionEnter(Collision collision)
    {
        PirateBehaviour pirate = collision.gameObject?.GetComponent <PirateBehaviour>();

        if (pirate != null)
        {
            // Inform the pirate ship that it needs to sink
            pirate.Sink();

            // .. then destroy our own gameObject!
            Destroy(gameObject);
        }
    }
    private void OnPirateReachedGold(PirateBehaviour pirate)
    {
        if (m_remainingLives < 0)
        {
            return;
        }

        m_remainingLives--;
        if (m_remainingLives == 0)
        {
            // Game is lost! All ye abandon all hope.
            Debug.Log("The game is over.");
            GameLost?.Invoke();
            m_chestExplosion.Play();
            StartCoroutine(DoGameOverSequence());
        }

        // Pivot the chest open, change the bar sprite

        float life_t = 1.0f - ((float)m_remainingLives / (float)NumLives);

        m_chestPivot.localRotation = Quaternion.Euler(Vector3.Lerp(Vector3.zero, m_openChestRotation, life_t));
        m_barImg.sprite            = m_stateSprites[m_remainingLives];
    }
Пример #5
0
 private void OnPirateSpawned(PirateBehaviour behaviour)
 {
     m_activePirates.Add(behaviour);
 }
Пример #6
0
    void OnTriggerEnter(Collider other)
    {
        //on colliding destroy rocks after its life time
        Destroy(gameObject, rockLifeTime);

        if (other.gameObject.tag.Equals("Destructible"))
        //if (other.tag == "Enemy")
        {
            //play on hit sound
            FindObjectOfType <PlayerSFX>().PlayOnHit();

            dest = other.GetComponent <DestructibleSpawn>();
            dest.spawnRandomItem();
            Destroy(other.gameObject);
        }
        else if (other.gameObject.tag.Equals("Goblin"))//goblin should play death animation
        {
            //play on hit sound
            FindObjectOfType <PlayerSFX>().PlayOnHit();

            goblin = other.gameObject.GetComponent <GoblinBehaviour>();
            goblin.IncrementHits(rockStrength);           //2 hits to kill goblin
            GetComponent <BoxCollider>().enabled = false; //Removing hit collider so it only hits target once.
        }
        else if (other.gameObject.tag.Equals("Pirate"))
        {
            //play on hit sound
            FindObjectOfType <PlayerSFX>().PlayOnHit();

            pirate = other.gameObject.GetComponent <PirateBehaviour>();
            pirate.IncrementHits(rockStrength);//3 hits to kill pirate
            GetComponent <BoxCollider>().enabled = false;
        }
        else if (other.gameObject.tag.Equals("Parrot"))
        {
            //play on hit sound
            FindObjectOfType <PlayerSFX>().PlayOnHit();

            parrot = other.gameObject.GetComponent <ParrotBehaviour>();
            parrot.IncrementHits(rockStrength);//1 hit to kill parrot
            GetComponent <BoxCollider>().enabled = false;
        }
        else if (other.gameObject.tag.Equals("Bat"))
        {
            //play on hit sound
            FindObjectOfType <PlayerSFX>().PlayOnHit();

            bat = other.gameObject.GetComponent <BatBehaviour>();
            bat.IncrementHits(rockStrength);//1 hit to kill bat
            GetComponent <BoxCollider>().enabled = false;
        }
        else if (other.gameObject.tag.Equals("Kraken"))
        {
            other.gameObject.GetComponent <KrakenBehaviour>().IncrementHits(rockStrength);
            GetComponent <BoxCollider>().enabled = false;
        }
        else if (other.gameObject.tag == "Bomb")
        {
            Destroy(other.gameObject);
        }
        //need to check for hits in goblin/ specific enemy instead - as following line disables above behaviors (eg. no longer destroy enemy on hit)
        //GetComponent<BoxCollider>().enabled = false; //Removing hit collider so it only hits target once.
    }
 private void OnPirateDeath(PirateBehaviour pirate)
 {
     m_killCount++;
 }