コード例 #1
0
    private Template CreateTemplate(Transform _templateTransform)
    {
        var templateInstance = EZ_PoolManager.Spawn(GetRandomTemplate(), _templateTransform.position, Quaternion.identity).GetComponent <Template>();

        templateInstance.PlayerTransform = _playerTransform;
        return(templateInstance);
    }
コード例 #2
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    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);
            }
        }
    }
コード例 #3
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);
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 70, 100, 30), "Spawn"))
     {
         EZ_PoolManager.Spawn(prefab, Random.insideUnitSphere, Random.rotation);
     }
 }
コード例 #6
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    //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;
    }
コード例 #7
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;
            }
        }
    }
コード例 #8
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    // 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();
        }
    }
コード例 #9
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);
         }
     }
 }
コード例 #10
0
ファイル: CoinSetup.cs プロジェクト: Iv4nKek/FlexBird
 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;
     }
 }
コード例 #11
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);
    }
コード例 #12
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;
        }
    }
コード例 #13
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");
            }
        }
    }
コード例 #14
0
ファイル: LevelGenerator.cs プロジェクト: Iv4nKek/FlexBird
        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();
            }
        }
コード例 #15
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    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);
        }
    }
コード例 #16
0
ファイル: ObstacleSetup.cs プロジェクト: Iv4nKek/FlexBird
 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;
         }
     }
 }
コード例 #17
0
ファイル: LevelSpawner.cs プロジェクト: ytkimirti/sling-drift
    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;
    }
コード例 #18
0
ファイル: BaseEnemy.cs プロジェクト: AllenOliver/LD42
    public virtual IEnumerator DieRoutine()
    {
        EZ_PoolManager.Spawn(DeathParticles.transform, gameObject.transform.position, gameObject.transform.rotation);
        //play anim
        gm.Memory -= MemorySpace;
        int randomChance = UnityEngine.Random.Range(0, 100);

        if (randomChance > 85 && ItemsToDrop.Count > 0)
        {
            Instantiate(ItemsToDrop[UnityEngine.Random.Range(0, ItemsToDrop.Count)], gameObject.transform.position, Quaternion.identity);
        }
        GetComponent <CircleCollider2D>().enabled = false;
        GetComponent <SpriteRenderer>().enabled   = false;
        audio.Play();
        yield return(new WaitForSeconds(audio.clip.length));

        EZ_PoolManager.Despawn(gameObject.transform);
    }
コード例 #19
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 70, 100, 30), "Spawn prefab 1"))
     {
         EZ_PoolManager.Spawn(prefabs[0], Random.insideUnitSphere * 4, Random.rotation);
     }
     if (GUI.Button(new Rect(10, 100, 100, 30), "Spawn prefab 2"))
     {
         EZ_PoolManager.Spawn(prefabs[1], Random.insideUnitSphere * 4, Random.rotation);
     }
     if (GUI.Button(new Rect(10, 130, 100, 30), "Spawn prefab 3"))
     {
         EZ_PoolManager.Spawn(prefabs[2], Random.insideUnitSphere * 4, Random.rotation);
     }
     if (GUI.Button(new Rect(10, 160, 100, 30), "Spawn prefab 4"))
     {
         EZ_PoolManager.Spawn(prefabs[3], Random.insideUnitSphere * 4, Random.rotation);
     }
 }
コード例 #20
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    void combo4()
    {
        for (int j = 0; j < Random.Range(5, 8); j++)
        {
            platformID += 2;

            float randomPos = Random.Range(-randomX, randomX);
            for (int i = 0; i < 3; i++)
            {
                EZ_PoolManager.Spawn(boostPrefab, new Vector3(randomPos, platformID, 0), Quaternion.identity);
                platformID++;
            }
        }
        int memLevel = level;

        level = 1;
        spawnRandomly();
        spawnRandomly();
        spawnRandomly();
        spawnRandomly();
        spawnRandomly();
        level = memLevel;
    }
コード例 #21
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    void combo5()
    {
        platformID += 2;
        float rand = Random.Range(-1, 1);

        EZ_PoolManager.Spawn(boostPrefab, new Vector3(rand * 2, platformID + 1f, 0), Quaternion.identity);

        if (rand == 0)
        {
            EZ_PoolManager.Spawn(boostPrefab, new Vector3(-2, platformID, 0), new Quaternion(0, 0, 180, 1));
            EZ_PoolManager.Spawn(boostPrefab, new Vector3(2, platformID, 0), new Quaternion(0, 0, 180, 1));
        }
        else if (rand == 1)
        {
            EZ_PoolManager.Spawn(boostPrefab, new Vector3(-2, platformID, 0), new Quaternion(0, 0, 180, 1));
            EZ_PoolManager.Spawn(boostPrefab, new Vector3(0, platformID, 0), new Quaternion(0, 0, 180, 1));
        }
        else
        {
            EZ_PoolManager.Spawn(boostPrefab, new Vector3(2, platformID, 0), new Quaternion(0, 0, 180, 1));
            EZ_PoolManager.Spawn(boostPrefab, new Vector3(0, platformID, 0), new Quaternion(0, 0, 180, 1));
        }
        platformID += 2;
    }
コード例 #22
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    void combo3()
    {
        platformID++;

        float height = platformID / spawnHeight;

        EZ_PoolManager.Spawn(jetpackCoinCombo, new Vector3(0, height, 0), Quaternion.identity);

        platformID++;

        float xPlus = 0;

        for (int i = 0; i < 70; i++)
        {
            platformID++;

            xPlus = xPlus + (Random.Range(-1, 1) / 5f);
            if (xPlus > 2 || xPlus < -2)
            {
                xPlus = 1;
            }
            EZ_PoolManager.Spawn(coinPrefab, new Vector3(xPlus, platformID / spawnHeight, 0), Quaternion.identity);
        }
    }
コード例 #23
0
 void Auto()
 {
     EZ_PoolManager.Spawn(prefab, Random.insideUnitSphere, Random.rotation);
 }
コード例 #24
0
 public void Die()
 {
     EZ_PoolManager.Spawn(DeathParticles.transform, gameObject.transform.position, gameObject.transform.rotation);
     StartCoroutine(OpenDoor());
     StartCoroutine(DieRoutine());
 }
コード例 #25
0
 void Shoot()
 {
     Transform currentBullet = EZ_PoolManager.Spawn(bulletPrefab.transform, bulletSpawn.position, bulletSpawn.rotation);
 }
コード例 #26
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
 void combo9()
 {
     platformID++;
     EZ_PoolManager.Spawn(trambolineCombo, new Vector3(0, platformID, 0), Quaternion.identity);
     platformID += 38;
 }
コード例 #27
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
 void combo8()
 {
     platformID++;
     EZ_PoolManager.Spawn(roundPlatform, new Vector3(0, platformID, 0), Quaternion.identity);
     platformID += 7;
 }
コード例 #28
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
 void combo7()
 {
     platformID += 2;
     EZ_PoolManager.Spawn(boostComboRight, new Vector3(2.5f, platformID, 0), Quaternion.identity);
     platformID += 17;
 }
コード例 #29
0
ファイル: spawner.cs プロジェクト: freedom764/jumpgame-master
    void SpawnPlatform(int spawnedID, Vector3 pos, bool isCombo)
    {
        Transform pref = null;

        if (isCombo)
        {
            pref = comboPlatforms[spawnedID];
        }
        else
        {
            pref = platform[spawnedID].platformPrefab;
        }

        if (platform[spawnedID].isItem)
        {
            EZ_PoolManager.Spawn(platform [0].platformPrefab, pos, Quaternion.identity);
        }

        if (pref == null)
        {
            pref = platform [0].platformPrefab;
            Debug.LogError("Bunu debug ile yaptım. Spawn kodunda seçilen platform listede yok!");
        }

        if (!isCombo && platform [spawnedID].dontRepeat && lastIsEnemy && !platform [spawnedID].isItem)
        {
            /*
             * float prob = Random.Range(0,100);
             * float allProbs = 0;
             *
             * for (int i = 0; i < platform.Length; i++) {
             *      allProbs = platform [i].probability[level] + allProbs;
             *      if (prob < allProbs && platform[i].showedLevel <= level) {
             *              pref = platform[i].platformPrefab;
             *              Debug.LogError (pref);
             *              SpawnPlatform (i,pos,isCombo);
             *
             *              break;
             *      }
             * }
             */
            spawnedID = 0;
            pref      = platform [0].platformPrefab;

            EZ_PoolManager.Spawn(pref, pos, Quaternion.identity);
            lastIsEnemy = false;
        }
        else
        {
            if (platform [spawnedID].isItem)
            {
                pos = new Vector3(pos.x, pos.y + 0.5f, pos.z);
            }

            EZ_PoolManager.Spawn(pref, pos, Quaternion.identity);
            lastIsEnemy = platform [spawnedID].dontRepeat;
            //if (pos.y < cam.transform.position.y + 4) {
            //	spawnRandomly ();
            //}
        }
    }