Example #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (cam.position.y - 10 > transform.position.y)
        {
            if (notChild)
            {
                EZ_PoolManager.Despawn(transform);
            }
            else
            {
                died = false;
                enemySprite.enabled = true;
            }
        }


        if (HareketliDusman && !died)
        {
            if (transform.localPosition.x > maxX)
            {
                yon = yon * -1;
                transform.localScale = new Vector3(1f, 1f, 1f);
            }
            if (transform.localPosition.x < minX)
            {
                yon = yon * -1;
                transform.localScale = new Vector3(-1f, 1f, 1f);
            }
            transform.Translate(new Vector2(hiz * yon, 0));
        }
    }
Example #2
0
 void FixedUpdate()
 {
     if (cam.position.y - 10 > transform.position.y)
     {
         EZ_PoolManager.Despawn(transform);
     }
 }
Example #3
0
    //COMBOLAR


    void combo1()     // sonsuz sonsuz sonsuz
    {
        float height = platformID / spawnHeight;

        for (int i = 0; i < 10; i++)
        {
            EZ_PoolManager.Spawn(coinPrefab, new Vector3(i - 2, height + 1.5f, 0), Quaternion.identity);
        }

        for (int i = 0; i < 10; i++)
        {
            EZ_PoolManager.Spawn(coinPrefab, new Vector3(i - 2, height + 2.5f, 0), Quaternion.identity);
        }

        SpawnPlatform(0, new Vector3(1, height + 3, 0), true);
        SpawnPlatform(0, new Vector3(-1, height + 3, 0), true);

        SpawnPlatform(0, new Vector3(-1, height + 1, 0), true);
        SpawnPlatform(0, new Vector3(2, height + 1, 0), true);

        SpawnPlatform(0, new Vector3(0, height + 2, 0), true);
        SpawnPlatform(0, new Vector3(-2, height + 2, 0), true);

        platformID += 3;
    }
Example #4
0
 private void DeleteAll()
 {
     foreach (var platform in _platforms)
     {
         EZ_PoolManager.Despawn(platform);
     }
 }
Example #5
0
    public void spawnFriendly()
    {
        platformID++;
        float randX = Random.Range(-randomX, randomX);

        if (Random.Range(0, 100) < 30)
        {
            SpawnPlatform(1, new Vector3(randX, platformID, 0), false);
        }
        else
        {
            SpawnPlatform(0, new Vector3(randX, platformID, 0), false);
        }
        if (Random.Range(0, 100) < 20)
        {
            if (90 > Random.Range(0, 100))
            {
                EZ_PoolManager.Spawn(coinPrefab, new Vector3(randX, platformID + (spawnHeight / 2), 0), Quaternion.identity);
            }
            else
            {
                EZ_PoolManager.Spawn(coinPrefab, new Vector3(randX - 0.2f, platformID + (spawnHeight / 2), 0), Quaternion.identity);
                EZ_PoolManager.Spawn(coinPrefab, new Vector3(randX + 0.2f, platformID + (spawnHeight / 2), 0), Quaternion.identity);
            }
        }
    }
    private Template CreateTemplate(Transform _templateTransform)
    {
        var templateInstance = EZ_PoolManager.Spawn(GetRandomTemplate(), _templateTransform.position, Quaternion.identity).GetComponent <Template>();

        templateInstance.PlayerTransform = _playerTransform;
        return(templateInstance);
    }
Example #7
0
 private void CheckCoin()
 {
     if (_createdCoin != null)
     {
         EZ_PoolManager.Despawn(_createdCoin);
     }
 }
Example #8
0
        private void Update()
        {
            if (!GameManager.Instance.IsGameStart)
            {
                return;
            }

            if (m_timer > 0)
            {
                m_timer -= Time.deltaTime;
            }
            else
            {
                Log.Info("Spawn()");

                m_timer = m_curLvlConfig.level.TimeInterval;

                int randIndex = UnityEngine.Random.Range(0, m_curLvlConfig.level.ListObstacles.Count);

                var objPrefab = m_curLvlConfig.level.ListObstacles[randIndex];

                var objSpawned = EZ_PoolManager.Spawn(objPrefab.transform, m_spawnerPlace.position, m_spawnerPlace.rotation);

                var obstacleCtrl = objSpawned.GetComponent <ObstacleController>();
                obstacleCtrl.SetMovementSpeed(m_curLvlConfig.level.MovementSpeed);
            }
        }
Example #9
0
 private void CheckObstacle()
 {
     if (_createdObstacle != null)
     {
         EZ_PoolManager.Despawn(_createdObstacle);
     }
 }
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 70, 100, 30), "Spawn"))
     {
         EZ_PoolManager.Spawn(prefab, Random.insideUnitSphere, Random.rotation);
     }
 }
Example #11
0
 /// <summary>
 /// Reset this to pool obj again
 /// </summary>
 private void ResetData()
 {
     //Log.Info("OnBecameInvisible()");
     m_isCollided = false;
     m_isRunning  = false;
     EZ_PoolManager.Despawn(this.transform);
 }
Example #12
0
        // OnCollisionEnter2D is called when this collider2D/rigidbody2D has begun touching another rigidbody2D/collider2D (2D physics only)
        private void OnCollisionEnter2D(Collision2D collision)
        {
            var objCol = collision.gameObject;

            // if collide LAND then circle can jump again
            if (objCol.CompareTag(GameTags.LAND))
            {
                m_isJumping = false;
            }

            // if  collide obstacle. This circle 'll explode and die
            else if (objCol.CompareTag(GameTags.OBSTACLE))
            {
                m_isDead = true;

                // get the explode prefab from pool,then show it.
                var spawnedObj = EZ_PoolManager.Spawn(m_explodeObj.transform, transform.position, transform.rotation);

                // deactivate circle
                this.gameObject.SetActive(false);

                // check the score. Get the high score
                if (PlayerData.Instance.Player.Score >= PlayerData.Instance.Player.HighScore)
                {
                    PlayerData.Instance.Player.HighScore = PlayerData.Instance.Player.Score;
                }

                this.PostEvent(EventID.OnPlayerDie);
            }
        }
Example #13
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         Player.magnet = true;
         EZ_PoolManager.Despawn(transform);
     }
 }
Example #14
0
 // Update is called once per frame
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Player" && !GameManager.gameOver && !Player.jetpack)
     {
         col.gameObject.GetComponent <Player>().shieldEnabled();
         EZ_PoolManager.Despawn(transform);
     }
 }
Example #15
0
 void Update()
 {
     if (false && currBlocks.Count > maxBlockCount)
     {
         EZ_PoolManager.Despawn(currBlocks[currBlocks.Count - 1]);
         currBlocks.RemoveAt(currBlocks.Count - 1);
     }
 }
    // Update is called once per frame
    void Update()
    {
        age += Time.deltaTime;

        if (age > TimeToLive)
        {
            EZ_PoolManager.Despawn(this.transform);
        }
    }
Example #17
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         PlayerPrefs.SetInt("reviveKey", PlayerPrefs.GetInt("reviveKey") + 1);
         audi.Play();
         EZ_PoolManager.Despawn(transform);
     }
 }
Example #18
0
    // Update is called once per frame
    void Update()
    {
        // movement
        Rigidbody2D rigidbody = GetComponent <Rigidbody2D>();

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            rigidbody.angularVelocity = 0; // clear any rotation caused by collisions
            rigidbody.rotation       += RotationSpeed;
        }

        if (Input.GetKey(KeyCode.RightArrow))
        {
            rigidbody.angularVelocity = 0; // clear any rotation caused by collisions
            rigidbody.rotation       -= RotationSpeed;
        }

        if (Input.GetKey(KeyCode.UpArrow))
        {
            // apply thrust
            rigidbody.AddForce(transform.up * Acceleration * Time.deltaTime);

            // limit speed
            if (rigidbody.velocity.magnitude > MaxSpeed)
            {
                rigidbody.velocity = rigidbody.velocity.normalized * MaxSpeed;
            }

            // show engine boost particle effect
            transform.Find("RightThrustPE").GetComponent <ParticleSystem>().Play();
            transform.Find("LeftThrustPE").GetComponent <ParticleSystem>().Play();
        }
        else
        {
            // turn off engine particle effect
            transform.Find("RightThrustPE").GetComponent <ParticleSystem>().Stop();
            transform.Find("LeftThrustPE").GetComponent <ParticleSystem>().Stop();
        }

        //shooting
        _timeSinceLastShot += Time.deltaTime;

        if (Input.GetButton("Fire1"))
        {
            if (_timeSinceLastShot > DelayBetweenShots)
            {
                //shoot!
                _timeSinceLastShot = 0f;

                Transform bullet = EZ_PoolManager.Spawn(Bullet, transform.position, transform.rotation);

                Rigidbody2D bulletRigidBody = bullet.GetComponent <Rigidbody2D>();
                bulletRigidBody.velocity = transform.up * ShotSpeed;
            }
        }
    }
Example #19
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 70, 200, 30), "Spawn 20 Prefabs"))
     {
         for (int i = 0; i < 20; ++i)
         {
             EZ_PoolManager.Spawn(prefab, Random.insideUnitSphere * 4, Random.rotation);
         }
     }
 }
Example #20
0
    // Use this for initialization
    void Start()
    {
        EZ_PoolManager.Spawn(platform[0].platformPrefab, new Vector3(Random.Range(-randomX, randomX), -2, 0), Quaternion.identity);

        platformID = -2;
        for (int i = 0; i < 7; i++)
        {
            spawnRandomly();
        }
    }
Example #21
0
 public void CreateCoin()
 {
     CheckCoin();
     if (Random.value < _chance)
     {
         Vector3 presetPosition = _coinPrefab.transform.position;
         Vector3 position       = presetPosition + _parent.transform.position;
         _createdCoin        = EZ_PoolManager.Spawn(_coinPrefab.transform, position, new Quaternion());
         _createdCoin.parent = _parent;
         _createdCoin.transform.localPosition = presetPosition;
     }
 }
Example #22
0
 void deleteEnemy()
 {
     if (notChild)
     {
         EZ_PoolManager.Despawn(transform);
     }
     else
     {
         enemySprite.enabled = false;
         died = true;
     }
 }
Example #23
0
    public IEnumerator DieRoutine()
    {
        EZ_PoolManager.Spawn(DeathParticles.transform, gameObject.transform.position, gameObject.transform.rotation);
        //play anim
        gm.Memory -= MemorySpace;

        GetComponent <BoxCollider2D>().enabled  = false;
        GetComponent <SpriteRenderer>().enabled = false;
        audio.Play();
        yield return(new WaitForSeconds(audio.clip.length));

        Destroy(gameObject);
    }
Example #24
0
    void Update()
    {
        if (spawnerActive)
        {
            _secondsSinceLastSpawn += Time.deltaTime;

            if (_secondsSinceLastSpawn > SecondsBetweenSpawns)
            {
                EZ_PoolManager.Spawn(prefabToSpawn.transform, gameObject.transform.position, gameObject.transform.rotation);
                _secondsSinceLastSpawn = 0f;
                //Debug.Log("FixedRateSpawner.Update(): New enemy spawned");
            }
        }
    }
Example #25
0
    public void Drop(int count, Vector2 from, Transform to, float radius)
    {
        for (int i = 0; i < count; i++)
        {
            Transform drop = EZ_PoolManager.Spawn(dropPrefab, from + radius * Random.insideUnitCircle, Quaternion.identity);

            drop.parent = transform;

            Drop dropScript = drop.GetComponent <Drop>();

            dropScript.target = to;
            dropScript.delay  = i * 0.01f;
        }
    }
Example #26
0
        private void GeneratePlatform()
        {
            Transform platform = EZ_PoolManager.Spawn(_platformPrefab.transform, new Vector3(0f, _currentHeight, 0f), new Quaternion());

            platform.GetComponent <Platform>().Level = _level;
            _level++;
            _platforms.Enqueue(platform);
            _count++;
            _currentHeight += _height;
            if (_count > _generationLimit)
            {
                DeleteFirst();
            }
        }
Example #27
0
    void DespawnUntilAKnob()//Despwabs from the end of the list until there is a knob
    {
        for (int i = currBlocks.Count - 1; i >= 0; i--)
        {
            string blockTag = currBlocks[i].tag;

            EZ_PoolManager.Despawn(currBlocks[i]);
            currBlocks.RemoveAt(i);

            if (blockTag == "Knob")
            {
                break;
            }
        }
    }
Example #28
0
    void spawnRandomly()
    {
        float allProbs   = 0;
        int   selectedID = -2;

        platformID++;
        float height = platformID / spawnHeight;
        float prob   = Random.Range(0, 100);

        for (int i = 0; i < platform.Length; i++)
        {
            allProbs = platform [i].probability[level] + allProbs;
            if (prob < allProbs && platform[i].showedLevel <= level)
            {
                selectedID = i;
                break;
            }
        }

        if (selectedID == 14 & player.jetPack.activeSelf)
        {
            selectedID = 0;
        }

        float randomXpos = Random.Range(-randomX, randomX);

        if (30 > Random.Range(0, 100) && !platform[selectedID].isItem)            // 30% şansla coin spawn edilir
        {
            if (70 > Random.Range(0, 100))
            {
                EZ_PoolManager.Spawn(coinPrefab, new Vector3(randomXpos, height + (spawnHeight / 2), 0), Quaternion.identity);
            }
            else
            {
                EZ_PoolManager.Spawn(coinPrefab, new Vector3(randomXpos - 0.2f, height + (spawnHeight / 2), 0), Quaternion.identity);
                EZ_PoolManager.Spawn(coinPrefab, new Vector3(randomXpos + 0.2f, height + (spawnHeight / 2), 0), Quaternion.identity);
            }
        }

        if (selectedID == -2)
        {
            SpawnPlatform(0, new Vector3(randomXpos, height, 0), false);
        }
        else
        {
            SpawnPlatform(selectedID, new Vector3(randomXpos, height, 0), false);
        }
    }
Example #29
0
 public void CreateObstacle(int level)
 {
     CheckObstacle();
     if (level > 0 && _container.ShouldBeSpawned(level))
     {
         ObstaclePreset preset = _container.GetRandomObstacle(level);
         if (preset != null)
         {
             Vector3 presetPosition = preset.Prefab.transform.position;
             Vector3 position       = presetPosition + _parent.transform.position;
             _createdObstacle        = EZ_PoolManager.Spawn(preset.Prefab.transform, position, new Quaternion());
             _createdObstacle.parent = _parent;
             _createdObstacle.transform.localPosition = presetPosition;
         }
     }
 }
Example #30
0
    void SpawnBlock(Vector3 pos, float angle, bool isKnob, bool isBoost)
    {
        //Damn the spawner code is just soo messy :P
        Transform prefab = isKnob ? knobPrefab : roadPrefab;

        if (isBoost)
        {
            prefab = boostPrefab;
        }

        Transform blockTrans = EZ_PoolManager.Spawn(prefab, pos, Quaternion.Euler(0, angle, 0));

        Transform blockChild = blockTrans.GetChild(0);

        currBlocks.Insert(0, blockTrans);


        if (isBoost)
        {
            currSpawnScore++;
        }
        else if (isKnob)
        {
            Knob knob = blockTrans.GetComponent <Knob>();

            knob.isLeft = M.Flip();//It's like flipping a coin :P

            knob.UpdateDirection();

            currSpawnScore++;

            knob.SetScore(currSpawnScore);

            facedWithAKnob = true;
        }
        else
        {
            //So we move currPos

            //spawnerTrans.Translate(0, 0, roadSpawnOffset, Space.Self);
        }

        spawnerTrans.position    = blockChild.position;
        spawnerTrans.eulerAngles = blockChild.eulerAngles;
    }