Exemplo n.º 1
0
        public void SetOverwriteType(Piece piece)
        {
            content = piece;
            var descriptor = MatchEnvironment.GetBlockFromPiece(piece.kind);
            var positions  = piece.GetPositions().ToList(); //TODO reduce allocation

            while (blocks.Count < positions.Count)
            {
                blocks.Add(Instantiate(blockPrefab, transform));
            }

            foreach (var block in blocks)
            {
                block.SetType(descriptor);
            }

            for (var i = 0; i < blocks.Count; i++)
            {
                if (i < positions.Count)
                {
                    blocks[i].gameObject.SetActive(true);
                    blocks[i].transform.localPosition = (Vector2)positions[i];
                }
                else
                {
                    blocks[i].gameObject.SetActive(false);
                }
            }
        }
Exemplo n.º 2
0
 public Field(MatchEnvironment env, Vector2Int fieldSize)
 {
     environment    = env;
     this.fieldSize = fieldSize;
     for (var y = 0; y < fieldSize.y; y++)
     {
         Rows.Add(new ColoredRow(fieldSize.x));
     }
 }
Exemplo n.º 3
0
 public Field(MatchEnvironment env) : this(env, new Vector2Int(10, 44))
 {
 }
Exemplo n.º 4
0
 private void Ready()
 {
     MatchEnv = new MatchEnvironment();
     MatchEnv.SetRotationSystem(0);//todo
     MatchEnv.AddSpinDetector(0);
 }
Exemplo n.º 5
0
 public readonly SpinDetectorDescriptor GetSpinDetector(MatchEnvironment env)
 {
     env.spinDetectorLookup.TryGetValue(kind, out var sys);
     return(sys);
 }
Exemplo n.º 6
0
 public readonly RotationSystemModuleDescriptor GetRotationSystem(MatchEnvironment env)
 {
     env.rotationSystemLookup.TryGetValue(kind, out var sys);
     return(sys);
 }