Ejemplo n.º 1
0
        private UI CreateOneGem(int i, int j, GemType[] excudeGemTypes)
        {
            GemType random = GemType.FIRE;

            switch (excudeGemTypes.Length)
            {
            case 0:
                random = BattleMapFactory.GetRandomGemType(BattleMapFactory.gemTypes);
                break;

            case 1:
                random = BattleMapFactory.GetRandomGemTypeExcude(excudeGemTypes[0]);
                break;

            case 2:
                random = BattleMapFactory.GetRandomGemTypeExcude(excudeGemTypes[0], excudeGemTypes[1]);
                break;
            }
            GameObject obj = GameObject.Instantiate(items[random], map.gameObject.transform);
            Vector2Int key = new Vector2Int(i, j);
            Vector2Int rawPos;
            Vector3    pos = Game.Scene.GetComponent <StaticGridComponent>().GetPosInGrid(key, out rawPos);
            UI         gem = ComponentFactory.Create <UI, GameObject>(obj);

            gem.gameObject.GetComponent <RectTransform>().anchoredPosition = pos;
            GemComponent gemComp = gem.AddComponent <GemComponent, GemData, GemType>(new GemData(), random);

            gemComp.SetGridPosition(rawPos);
            gems.Add(key, gem);
            return(gem);
        }
Ejemplo n.º 2
0
        public UI CreateOneGemObject(int col, int depth = 1)
        {
            GemType    random = BattleMapFactory.GetRandomGemType(BattleMapFactory.gemTypes);
            GameObject obj    = GameObject.Instantiate(items[random], map.gameObject.transform);
            Vector2Int rawPos = Vector2Int.Zero;

            obj.gameObject.GetComponent <RectTransform>().anchoredPosition = Game.Scene.GetComponent <StaticGridComponent>().GetSpawPos(col, depth, out rawPos);
            UI           gem     = ComponentFactory.Create <UI, GameObject>(obj);
            GemComponent gemComp = gem.AddComponent <GemComponent, GemData, GemType>(new GemData(), random);

            gemComp.SetGridPosition(rawPos);
            return(gem);
        }