Esempio n. 1
0
    //方法,创建单个飞行金币
    void CreatSingleFlyingCoin()
    {
        //临时的飞行金币
        GameObject tempFlyingCoin;

        //飞行金币的脚本
        FlyingCoin targetFlyingCoin;

        //缓存池中取出一枚飞行金币
        tempFlyingCoin = CoinPool.GetCoin();

        //设定飞行金币的位置
        tempFlyingCoin.GetComponent <RectTransform>().anchoredPosition3D = flyingCoinStartPosition;

        //设定飞行金币的父物体
        tempFlyingCoin.transform.SetParent(coinPool, false);

        //获得飞行金币的脚本组件
        targetFlyingCoin = tempFlyingCoin.GetComponent <FlyingCoin>();

        //金币飞行
        targetFlyingCoin.FlyingCoinMove();

        //播放获得音效
        MyClass.AudioPlay(soundPlayer, Resources.Load <AudioClip>("Audio/GetCoin"), MyClass.soundEnable);
    }
Esempio n. 2
0
 void Awake()
 {
     enemyPoolList    = GameObject.Find("EnemyPool").GetComponent <EnemyPool> ().enemyList;
     showScore        = GameObject.Find("ScoreText").GetComponent <ShowScore> ();
     _spawnController = GameObject.Find("SpawnController").GetComponent <SpawnController> ();
     coinPool         = GameObject.Find("CoinPool").GetComponent <CoinPool> ();
     coinDrop         = GetComponent <CoinDrop> ();
 }
Esempio n. 3
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(this.gameObject); return;
     }
     Instance = this;
 }
Esempio n. 4
0
 private void Start()
 {
     instance = this;
     pool     = new List <Coin>(poolSize);
     for (int i = 0; i < poolSize; i++)
     {
         pool.Add(CreateCoin());
     }
 }
Esempio n. 5
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         PrepareCoins();
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 6
0
    void Awake()
    {
        I = this;
        // Seed the _pool
        _current = 0;
        _pool    = new List <Coin>(poolSize);

        for (int i = 0; i < poolSize; i++)
        {
            Coin c = (Coin)Instantiate(coinPrefab, Vector3.zero, Quaternion.identity);
            c.Finish();
            c.transform.parent = transform;
            c.name             = coinPrefab.name + "_" + i;
            _pool.Add(c);
        }
    }
Esempio n. 7
0
    public void FreeCoins(Transform p_trans)
    {
        //Debug.Log("Inside Free Coin");

        foreach (Transform trans in p_trans)
        {
            if (transform.childCount <= 0)
            {
                continue;
            }

            CoinPool cp = listCoins.Find(x => x.objCoin == transform.GetChild(0).gameObject);
            if (cp != null)
            {
                cp.objCoin.transform.position = Vector3.one * 1000;
                cp.isFree = true;
            }
        }
        //Debug.Log("End of Free Coin");
    }
Esempio n. 8
0
    void GetCoins(Transform p_trans)
    {
        //Debug.Log("Inside Get Coin");

        foreach (Transform trans in p_trans)
        {
            CoinPool cp = listCoins.Find(x => x.isFree);



            cp         = new CoinPool();
            cp.objCoin = Instantiate(prefCoin);
            cp.objCoin.transform.SetParent(trans);
            cp.objCoin.transform.localPosition = Vector3.zero;
            cp.isFree = false;
            listCoins.Add(cp);
        }
        //Debug.Log(listCoins[0]);

        //Debug.Log(listCoins[0].objCoin);
        //Debug.Log("End of Coin");
    }