Example #1
0
        public Cell Cell(CellDescription description)
        {
            var prefabs = CellPrefabs.Where(c => c.GetComponent<Cell>().Type == description.Type).ToArray();

            /*
            if (type == CellTypes.Block)
            {
            prefab = prefabs[(Math.Abs(x) + Math.Abs(y))%2].CellPrefab;
            }
            */
            var prefab = prefabs.First();
            var cellGO = Instantiate(prefab) as GameObject;
            var cell = cellGO.GetComponent<Cell>();
            cell.Init(description);

            if (cell.CreationType == CreationType.Place)
            {
                GameObject place = NGUITools.AddChild(cellGO, PlacePrefab);
                place.transform.localPosition = Vector3.zero;
                cell.PlaceSpite = place;
                cell.IsPlace = true;
            }

            if (!Gamefield)
            {
                Gamefield = FindObjectOfType<Gamefield>();
            }

            cellGO.transform.parent = Gamefield.transform;

            return cell;
        }
Example #2
0
 public void Init(CellDescription description)
 {
     Description = description;
     Position = GamefieldUtility.ConvertXYToPosition(X, Y, Chuzzle.Scale);
     CreationType = description.CreationType;
     transform.position = Position;
 }