コード例 #1
0
ファイル: Propulsion.cs プロジェクト: jthefang/Pacfisim2D
 // Start is called before the first frame update
 void Start()
 {
     audioSource         = GetComponent <AudioSource>();
     particleSystem      = GetComponent <ParticleSystem>();
     this._isInitialized = true;
     OnScriptInitialized?.Invoke(this);
 }
コード例 #2
0
    void Start()
    {
        tagToPoolObjectDictionary = new Dictionary <string, Pool>();
        objectToTagDictionary     = new Dictionary <GameObject, string>();
        tagToPoolQueueDictionary  = new Dictionary <string, Queue <GameObject> >();

        foreach (Pool pool in pools)
        {
            tagToPoolObjectDictionary[pool.tag] = pool;

            // create a Q for each pool
            Queue <GameObject> objectPool = new Queue <GameObject>();

            // populate Q with `size` objects
            for (int i = 0; i < pool.size; i++)
            {
                GameObject obj = Instantiate(pool.prefab);
                obj.SetActive(false); //not yet in the game
                IPooledObject pooledObj = obj.GetComponent <IPooledObject>();
                if (pooledObj != null)
                {
                    pooledObj.OnObjectInitiate(pool.spriteManager);
                }
                objectPool.Enqueue(obj);
                objectToTagDictionary[obj] = pool.tag;
            }

            tagToPoolQueueDictionary.Add(pool.tag, objectPool);
        }

        this._isInitialized = true;
        OnScriptInitialized?.Invoke(this);
    }
コード例 #3
0
ファイル: CameraRig.cs プロジェクト: jthefang/Pacfisim2D
    // Start is called before the first frame update
    void Start()
    {
        rigTransform             = this.transform.parent;
        gameManager.OnNewPlayer += OnNewPlayer;

        this._isInitialized = true;
        OnScriptInitialized?.Invoke(this);
    }
コード例 #4
0
    public virtual void InitSpriteManager()
    {
        gameManager                 = GameManager.Instance;
        gameManager.OnGameStart    += OnGameStart;
        gameManager.OnGameOver     += OnGameOver;
        gameManager.OnNewPlayer    += OnNewPlayer;
        gameManager.OnNewGameSpeed += OnNewGameSpeed;

        objectPooler = ObjectPooler.Instance;
        sprites      = new List <GameObject>();

        InitSpawnLocations();

        OnScriptInitialized?.Invoke(this);
    }