Esempio n. 1
0
    private void spawnThis(GameObject toSpawn, bool Enemy)
    {
        if (Enemy)
        {
            GameObject _spawnedRodent = GameObject.Instantiate(toSpawn, _spawnLoc, this.transform.rotation);

            //parent this to keep hierarchy clean
            if (_EnemySpawnDummy)
            {
                _spawnedRodent.transform.SetParent(_EnemySpawnDummy);
            }
            else
            {
                Debug.LogWarning("No Enemy Dummy for Hierarchy");
            }

            // Tag becoming obsolete
            _spawnedRodent.tag = "EnemyRodent";
            // Ensure Sprite is enemy
            Rodent r = _spawnedRodent.GetComponent <Rodent>();
            if (r)
            {
                r.setTeam(2);
                SubjectScript ss = r.GetComponent <SubjectScript>();
                if (ss)
                {
                    ss.setDefender();
                    StartCoroutine(RoyalGuardDelay(ss));
                }
                // Force them to be aggressive and head toward player   //hack
                if (_inPlayerZone)
                {
                    r.setTargetEnemyVersion(GameManager.Instance.getTownCenter().gameObject);
                }
            }
            // Increase some kind of count
            --_EnemyCount;
            if (_EnemyCount == 0)
            {
                _occupied = true;
            }
        }
        else
        {
            _occupied = true;
            GameObject _spawnedRat = GameObject.Instantiate(toSpawn, _spawnLoc, this.transform.rotation);
            //parent this thing to this obj keep hierarchy cleaner? Might end up negatively affecting the subject Script?
            _spawnedRat.transform.SetParent(this.transform);

            // Tag becoming obsolete
            _spawnedRat.tag = "NeutralRodent";
            // Ensure Sprite is Neutral
            _spawnedRat.GetComponent <Rodent>().setTeam(0);
            // Increase some kind of count
        }
    }