public void ReplaceAsset(AssetsEnum newValue)
    {
        var index     = GameComponentsLookup.Asset;
        var component = CreateComponent <AssetComponent>(index);

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Exemple #2
0
 private void AddAditionalEntityComponents(AssetsEnum selectedAsset, GameObject gameObject, GameEntity entity)
 {
     switch (selectedAsset)
     {
     case AssetsEnum.Tank:
         entity.AddTankView(gameObject.GetComponent <TankView>());
         break;
     }
 }
Exemple #3
0
    public GameObject GetPrefab(AssetsEnum asset)
    {
        switch (asset)
        {
        case AssetsEnum.Tank:
            return(TankPrefab);

        case AssetsEnum.Projectile:
            return(ProjectilePrefab);
        }

        throw new Exception("Asset " + asset.ToString() + " not found.");
    }
Exemple #4
0
    private GameObject GetGameObject(AssetsEnum selectedAsset)
    {
        switch (selectedAsset)
        {
        case AssetsEnum.Tank:
            return(GameObject.Instantiate(_contexts.game.globals.value.GetPrefab(selectedAsset)));

        case AssetsEnum.Projectile:
            return(_contexts.game.projectilePool.value.GetProjectile());
        }

        return(null);
    }
Exemple #5
0
    protected override void Execute(System.Collections.Generic.List <GameEntity> entities)
    {
        foreach (var entity in entities)
        {
            AssetsEnum selectedAsset = entity.asset.value;
            GameObject gameObject    = GetGameObject(selectedAsset);

            if (gameObject != null)
            {
                AttachGameObjectToEntity(gameObject, entity);
                AddAditionalEntityComponents(selectedAsset, gameObject, entity);
            }
        }
    }