Exemple #1
0
 void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     Instance = this;
     // Furthermore we make sure that we don't destroy between scenes (this is optional)
     DontDestroyOnLoad(gameObject);
 }
Exemple #2
0
	void Awake()
	{
		if (Instance != null && Instance != this)
		{
			Destroy(gameObject);
		}
		Instance = this;
		// Furthermore we make sure that we don't destroy between scenes (this is optional)
		DontDestroyOnLoad(gameObject);
	}
Exemple #3
0
    private GemCell ConvertToGemCell(SpawnItem spawn)
    {
        int     gem        = GemConverter.GetGemInt(spawn.GemName);
        GemCell newGemCell = GemCellPool.Instance.GetOneGemCell(gem);

        newGemCell.InitGem();
        var thisGem = newGemCell.Gem;

        if (thisGem.AllowBG)
        {
            int bg = GemBGConverter.GetGemInt(spawn.BgName);
            newGemCell.InitBgGem(bg);
        }
        if (thisGem.AllowFG)
        {
            int fg = GemFGConverter.GetGemInt(spawn.FgName);
            newGemCell.InitFgGem(fg);
        }
        return(newGemCell);
    }
Exemple #4
0
 public void RemoveOneGemBg(GemBg gem)
 {
     gem.OnDeActivate();
     if (usePool == true)
     {
         var id       = GemBGConverter.GetGemInt(gem.Id);
         var poolItem = GemPoolItems.Find(pool => pool.GemId == id);
         if (poolItem == null)
         {
             poolItem = new GemPoolItem {
                 GemId = id, Gems = new List <GameObject>()
             };
             GemPoolItems.Add(poolItem);
         }
         gem.gameObject.transform.parent        = transform;
         gem.gameObject.transform.localPosition = offPos;                    // Vector3.zero;
         gem.gameObject.SetActive(false);
         poolItem.Gems.Add(gem.gameObject);
     }
     else
     {
         Destroy(gem.gameObject);
     }
 }
Exemple #5
0
    public GemBg GetOneGemBg(int id)
    {
        GemBg gemObject = null;
        var   poolItem  = GemPoolItems.Find(pool => pool.GemId == id);

        if (usePool == true && poolItem != null && poolItem.Gems.Count > 0)
        {
            var gem = poolItem.Gems[0];
            gemObject = gem.GetComponent <GemBg>();
            gem.gameObject.transform.parent        = null;
            gem.gameObject.transform.localPosition = Vector3.zero;
            poolItem.Gems.RemoveAt(0);
            gem.gameObject.SetActive(true);
        }
        else
        {
            var name       = GemBGConverter.GetGemName(id);
            var prefabItem = GemPrefabList.Find(a => a.Name.Equals(name));
            var gObject    = Instantiate(prefabItem.Prefab) as GameObject;
            gemObject = gObject.GetComponent <GemBg>();
        }
        gemObject.OnActivate();
        return(gemObject);
    }
Exemple #6
0
 public void Init()
 {
     Type = GemBGConverter.GetGemInt(Id);
 }