コード例 #1
0
        void Start()
        {
            powerUpsByGuid     = new Dictionary <Guid, GameObject>();
            powerUpIconsByGuid = new Dictionary <Guid, Sprite>();
            IDictionary <Type, PowerUpData> powerUpDataByType = dataLoader.LoadPowerUpData();

            foreach (KeyValuePair <Type, PowerUpData> kvp in powerUpDataByType)
            {
                // Instatiate PowerUp and initialize it with args loaded from Json
                GameObject powerUpPrefab = new GameObject();
                IPowerUp   powerUp       = powerUpPrefab.AddComponent(kvp.Key) as IPowerUp;
                powerUp.Initialize(kvp.Value.initArgs);

                powerUpsByGuid[powerUp.Id]     = powerUpPrefab;
                powerUpIconsByGuid[powerUp.Id] = ResourceLoader.GetSpriteForPowerUp(powerUp.GetType());
            }
        }