Example #1
0
    public Dictionary <string, Queue <GameObject> > poolDict; //A dict so we can spawn a troop based on enemy troop name

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
        }


        poolDict = new Dictionary <string, Queue <GameObject> >();

        foreach (Pool pool in pools)
        {
            Queue <GameObject> objectPool = new Queue <GameObject>();

            for (int i = 0; i < pool.size; i++)
            {
                GameObject obj = Instantiate(pool.prefab);

                if (obj.CompareTag("Bullet"))
                {
                    obj.transform.parent = GameObject.Find("Bullets").transform;
                }

                obj.SetActive(false);
                objectPool.Enqueue(obj);
            }

            poolDict.Add(pool.name, objectPool);
        }
    }
Example #2
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Example #3
0
    public GameObject CallingSpawnEnemy(EnemyType type)
    {
        Vector3     position = getRandomSpawnPosition();
        EnemyPooler pool     = EnemyPooler.Instance;

        return(pool.SpawnFromPool(type, position));
    }
Example #4
0
 private void Start()
 {
     isAlive          = true;
     currentHitPoints = hitPoints;
     rb          = GetComponent <Rigidbody>();
     pooler      = EnemyPooler.Instance;
     player      = FindObjectOfType <PlayerController>();
     dropManager = DropManager.Instance;
 }
Example #5
0
 // Start is called before the first frame update
 void Start()
 {
     locked      = false;
     doors       = gameObject.GetComponent <Tilemap>();
     MainCamera  = GameObject.Find("Camera");
     grid        = MainCamera.GetComponent <GridMap>();
     RoomMap     = GameObject.Find("Camera").GetComponent <Roomsetup>();
     enemyPooler = GameObject.Find("EnemyPooler").GetComponent <EnemyPooler>();
 }
Example #6
0
 private void Start()
 {
     spellMana       = GameObject.Find("RightHand").GetComponent <Spellcasting>();
     enemyPooler     = GameObject.Find("Enemies").GetComponent <EnemyPooler>();
     explosionNoise  = explosionEffect.GetComponent <AudioSource>();
     rb              = this.gameObject.GetComponent <Rigidbody>();
     bridgePuzzleVar = GameObject.Find("BridgeAnchors").GetComponent <bridgePuzzle>();
     gatePuzzle      = GameObject.Find("Fortress Gate").GetComponent <KeyGatePuzzle>();
 }
    void Start()
    {
        // set health to 100
        Health = 100;

        // set numeric health indicator's value to health value
        HealthBarIndicator.GetComponent <TextMesh>().text = Health.ToString();

        //DiamondResourcesCount = 0;
        //GoldResourcesCount = 0;
        //BricksResourcesCount = 0;

        enemyPool = EnemyPooler.Instance;
    }
Example #8
0
    public void SpawnEnemy()
    {
        LevelManager manager = LevelManager.Instance;
        EnemyPooler  pool    = EnemyPooler.Instance;

        foreach (EnemyAmount eAmount in _enemyAmounts)
        {
            for (int i = 0; i < eAmount.Amount; i++)
            {
                Vector3 position = manager.getRandomSpawnPosition();

                pool.SpawnFromPool(eAmount.Type, position);
            }
        }

        gameObject.SetActive(false);
    }
    public void AwakeGeneralGameStatePoolers()
    {
        Data.ObjectPoolersHolder = this;

        BattleUnitPooler.AwakePooler();
        RoadPooler.AwakePooler();
        ObstaclePooler.AwakePooler();
        StoneBlockagePooler.AwakePooler();
        EffectPooler.AwakePooler();
        EventPooler.AwakePooler();
        TrucksFirePointPooler.AwakePooler();
        RoadBlocksFirePointPooler.AwakePooler();
        HelicoptersFirePointPooler.AwakePooler();
        GunsPooler.AwakePooler();
        TrucksPooler.AwakePooler();
        EnemyPooler.AwakePooler();
    }
Example #10
0
    void Start()
    {
        Camera.main.FadeIn(5f, Easing.Type.CircularIn);

        mobPooler = FindObjectOfType <EnemyPooler>();
        health    = GetComponent <Health>();
        modifier  = GetComponentInChildren <MaterialModifier>();

        //Collect all tiles locations from patrol tilemap
        BoundsInt mapBounds = patrolMap.cellBounds;

        foreach (var pos in mapBounds.allPositionsWithin)
        {
            Vector3Int localPlace = new Vector3Int(pos.x, pos.y, pos.z);
            Vector3    place      = patrolMap.CellToWorld(localPlace);
            if (patrolMap.HasTile(localPlace))
            {
                tilemapLocations.Add(place);
            }
        }
    }
Example #11
0
 private void Start()
 {
     enemyPooler = EnemyPooler.instance;
     InvokeRepeating("spawnMob", 0, 0.5f);
 }
Example #12
0
 void Awake()
 {
     SharedInstance = this;
 }
Example #13
0
 private void Start()
 {
     pooler = EnemyPooler.Instance;
 }
Example #14
0
 private void Initialize(EnemyPooler enemyPooler)
 {
     _enemyPooler = enemyPooler;
 }
 void Awake()
 {
     current = this;
 }
Example #16
0
 private void Start()
 {
     enemyPool = EnemyPooler.Instance;
 }
Example #17
0
 void Awake()
 {
     //need this for static NewObjectPoolingScript
     current = this;
 }
 void Awake()
 {
     current = this;
 }
Example #19
0
 private void Awake()
 {
     current = this;
 }
Example #20
0
 private void Awake()
 {
     Instance = this;
 }
Example #21
0
 public void Initialize(EnemyPooler enemyPooler, EnemyWaypoints waypointProvider, Transform target)
 {
     this.enemyPooler      = enemyPooler;
     this.waypointProvider = waypointProvider;
     Target = target;
 }