Esempio n. 1
0
    public void Healing(int healAmount, int manaCost)
    {
        if (ManaCounter.Number >= manaCost)
        {
            PlayerHealth.AddNumber(healAmount);

            ManaCounter.SubNumber(manaCost);
        }
    }
    /// <summary>
    /// regisztrálja a beérkezett sebzéseket, halál esetén "ragdoll"-t csinál az ellenfélből és félig randomizált irányba fellöki.
    /// </summary>
    /// <param name="damage"></param>
    public void TakeDamage(int damage)
    {
        health -= damage;
        if (health <= 0 && IsDead == false)
        {
            EnemyNumber.SubNumber();

            ManaCounter.AddNumber(manaWorth);

            CurrencyCounter.AddNumber(currencyWorth);


            Vector2 flightDirection = new Vector2(Random.Range(-0.5f, 0.5f), Random.Range(0.75f, 1.0f));
            GetComponent <EnemyMove>().enabled = false;
            rb2DAsset.constraints = RigidbodyConstraints2D.None;
            GetComponent <CircleCollider2D>().enabled = false;
            rb2DAsset.AddForce(flightDirection * thrust);
            rb2DAsset.gravityScale = 0.5f;
            IsDead = true;
            GetComponent <SpriteRenderer>().color = DeathColor;

            StartCoroutine(DeathBounce());
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Enemy Prefabot instantiate-el adott időközönként, adott helyekre (amennyiben azok "nyitva" vannak).
    /// </summary>
    /// <returns></returns>
    IEnumerator Spawn()
    {
        yield return(new WaitForSeconds(spawnTime));

        for (int i = 0; i < Spawnpoints.Length; i++)
        {
            if (Spawnpoints[i].gameObject.activeInHierarchy == true)
            {
                if (EnemyTypeCounter >= Collection.EnemyVariations[WaveCounter.WaveNumber - 1].EnemyArrayHolder[EnemyIndex].NumberOfEnemiesInWave)
                {
                    break;
                }
                GameObject go = Instantiate(Collection.EnemyVariations[WaveCounter.WaveNumber - 1].EnemyArrayHolder[EnemyIndex].Enemy.Prefab, Spawnpoints[i].transform.position, transform.rotation);
                go.GetComponent <EnemyMove>().target           = Player.transform;
                go.GetComponent <EnemyMainScript>().EnemyIndex = EnemyIndex;
                go.GetComponent <EnemyMove>().EnemyIndex       = EnemyIndex;
                EnemyCounter.AddNumber();
                WaveCounter.AddNumber();
                EnemyCount++;
                EnemyTypeCounter++;
            }
        }
        SpawnPoint();
    }