Beispiel #1
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            GameObject    bullet          = m_ScriptablePool.Rent(true);
            BulletExample bulletComponent = bullet.GetComponent <BulletExample>();
            bullet.transform.position = transform.position;
            bulletComponent.Reset();
            bulletComponent.Push();


            //BulletExample bulletComponent = _bulletComponentPool.Rent(false);
            //bulletComponent.transform.position = transform.position;
            //bulletComponent.Reset();
            //bulletComponent.GetComponent<Renderer>().material.color = Random.ColorHSV(0.8f, 1.0f);
            //bulletComponent.gameObject.SetActive(true);
            //bulletComponent.Push();

            //GameObject bullet = _bulletPool.Rent(false);
            //BulletExample bulletComponent = bullet.GetComponent<BulletExample>();
            //bullet.transform.position = transform.position;
            //bulletComponent.Reset();
            //bullet.GetComponent<Renderer>().material.color = Random.ColorHSV(0.8f, 1.0f);
            //bullet.SetActive(true);
            //bulletComponent.Push();
        }
    }
Beispiel #2
0
    private IEnumerator Spawn(int smallEnemyAmout, int bigEnemyAmout)
    {
        if (m_StandardEnemyPool != null && m_BigEnemeyPool != null)
        {
            for (int i = 0; i < smallEnemyAmout; i++)
            {
                m_StandardEnemyPool.Rent(true);
                yield return(new WaitForSeconds(m_QuequeTimeOfStandardEnemy));
            }

            for (int i = 0; i < bigEnemyAmout; i++)
            {
                m_BigEnemeyPool.Rent(true);
                yield return(new WaitForSeconds(m_QuequeTimeofBigEnemy));
            }

            yield return(new WaitForSeconds(m_IntervalBetweenEachWaves));

            m_SpawnWaveCounter++;
            m_SpawnCompleted = true;

            if (m_SpawnWaveCounter == m_TotalSpawnWave && m_SpawnCompleted)
            {
                if (m_GameManager != null)
                {
                    m_GameManager.Win();
                }
            }
            else
            {
                GetSpawnData(m_SpawnWaveCounter);
            }
        }
    }
 /// <summary>
 ///     Spawn explosion particles and explosion radius at impact position.
 /// </summary>
 public void OnTriggerEnter()
 {
     if (m_ExplosionScriptablePool != null && m_ExplosionRadiusScriptablePool != null)
     {
         m_ExplosionScriptablePool.Rent(true).transform.position       = transform.position;
         m_ExplosionRadiusScriptablePool.Rent(true).transform.position = transform.position;
     }
 }
Beispiel #4
0
    /// <summary> Shoots towards a direction.</summary>
    /// <param name="direction"> Direction to shoot at.</param>
    public void Shoot(Vector3 direction)
    {
        GameObject bullet          = m_BombBulletScriptablePool.Rent(true);
        Bullet     bulletComponent = bullet.GetComponent <Bullet>();

        bulletComponent.ResetVelocity();
        bulletComponent.transform.position = transform.position;
        bulletComponent.Shoot(direction);
    }
Beispiel #5
0
    private void SpawnBoxymon(BoxymonType boxymonType)
    {
        Boxymon instance = m_EnemyPool.Rent(true).GetComponent <Boxymon>();

        instance.transform.position = transform.position;
        instance.Init(boxymonType, m_MapData, true);
        instance.OnBoxymonDeath += BoxymonDied;
        m_AliveBoxymons.Add(instance);
    }
Beispiel #6
0
 public override void Shoot()
 {
     if (m_SnowBallPool != null)
     {
         GameObject bulletType = m_SnowBallPool.Rent(false);
         if (bulletType != null)
         {
             BulletBase bullet = bulletType.GetComponent <BulletBase>();
             bullet.SetPosition(SpawnPoint);
             bullet.gameObject.SetActive(true);
             bullet.Shoot();
         }
     }
 }
 private void GenerateMap()
 {
     Setup();
     ReadMap();
     GeneratePath();
     CalculateWalkPoints();
     if (m_MapData.MapLayout != null && m_MapData.MapLayout.Count > 0)
     {
         foreach (KeyValuePair <Vector3, GameObject> objectPosition in m_MapData.MapLayout)
         {
             SelectScriptablePool(objectPosition.Value.tag);
             m_CurrentScriptablePool.Rent(true).transform.position = objectPosition.Key;
         }
     }
 }
    private GameObject RentGameObjectByTileType(TileType type)
    {
        switch (type)
        {
        case TileType.Path:
            return(m_PathTilePool.Rent(true));

        case TileType.Obstacle:
            return(m_ObstacleTilePool.Rent(true));

        case TileType.TowerOne:
            GameObject towerOneInstance = m_TowerTilePool.Rent(true);
            towerOneInstance.GetComponent <Tower>().Init(TowerType.CannonTower);
            return(towerOneInstance);

        case TileType.TowerTwo:
            GameObject towerTwoInstance = m_TowerTilePool.Rent(true);
            towerTwoInstance.GetComponent <Tower>().Init(TowerType.FreezeTower);
            return(towerTwoInstance);

        case TileType.Start:
            EnemyBase enemyBaseInstance = m_EnemyBasePool.Rent(true).GetComponent <EnemyBase>();
            enemyBaseInstance.Init(m_CurrentMapData, m_EnemyPool);
            OnEnemyBaseLoaded.Invoke(enemyBaseInstance);
            return(enemyBaseInstance.gameObject);

        case TileType.End:
            PlayerBase playerBaseInstance = m_PlayerBasePool.Rent(true).GetComponent <PlayerBase>();
            playerBaseInstance.Init();
            OnPlayerBaseLoaded.Invoke(playerBaseInstance);
            return(playerBaseInstance.gameObject);

        default:
            return(null);
        }
    }
Beispiel #9
0
    private void AreaDamage(Vector3 position)
    {
        if (m_ExposionScriptablePool != null)
        {
            GameObject exposion = m_ExposionScriptablePool.Rent(false);
            if (exposion != null)
            {
                exposion.transform.position = position;
                exposion.SetActive(true);
            }
        }

        Collider[] colliders = Physics.OverlapSphere(transform.position, m_DamageRadius);
        foreach (Collider nearbyObject in colliders)
        {
            HealthObserverable healthObserverable = nearbyObject.gameObject.GetComponent <HealthObserverable>();
            if (healthObserverable != null)
            {
                healthObserverable.TakeDamage(m_Damage);
            }
        }
    }