示例#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);
                }
            }
        }
示例#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));
     }
 }
示例#3
0
 public Field(MatchEnvironment env) : this(env, new Vector2Int(10, 44))
 {
 }
示例#4
0
 private void Ready()
 {
     MatchEnv = new MatchEnvironment();
     MatchEnv.SetRotationSystem(0);//todo
     MatchEnv.AddSpinDetector(0);
 }
示例#5
0
 public readonly SpinDetectorDescriptor GetSpinDetector(MatchEnvironment env)
 {
     env.spinDetectorLookup.TryGetValue(kind, out var sys);
     return(sys);
 }
示例#6
0
 public readonly RotationSystemModuleDescriptor GetRotationSystem(MatchEnvironment env)
 {
     env.rotationSystemLookup.TryGetValue(kind, out var sys);
     return(sys);
 }