Beispiel #1
0
    public void CreatingOneDing()
    {
        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, checkRadius, checkLayers);

        if (colliders.Length > 0)
        {
            return;
        }

        int randomDing  = Random.Range(0, _dingPerfab.Count);
        int randomSpawn = Random.Range(0, _dingSpawner.Count);

        GameObject ding = Instantiate(_dingPerfab[randomDing], _dingSpawner[randomSpawn].transform.position, Quaternion.identity);

        if (ding == null)
        {
            return;
        }
        DistoryThisAfterAWhile dis = ding.AddComponent <DistoryThisAfterAWhile>();

        if (dis == null)
        {
            return;
        }
        dis.SetTime(120);
    }
Beispiel #2
0
    public void CreateOneMonster()
    {
        if (_monsterPerfab != null)
        {
            int randomMonster = Random.Range(0, _monsterPerfab.Count);
            int randomSpawn   = Random.Range(0, _monsterSpawner.Count);

            GameObject monsterObj = Instantiate(_monsterPerfab[randomMonster], _monsterSpawner[randomSpawn].transform.position, Quaternion.identity);
            if (monsterObj == null)
            {
                Debug.LogError("Create monster error");
            }

            DistoryThisAfterAWhile dis = monsterObj.AddComponent <DistoryThisAfterAWhile>();
            if (dis == null)
            {
                return;
            }
            dis.SetTime(180);
        }
    }