Esempio n. 1
0
    float delayTime_Cell = 0.01f;    // 0.02f;

    void GenerateBlockBrick(Vector2 startPot, int xCount, int yCount, Vector3 spanPot, float delayTime_Cell, bool useConstantSpeed)
    {
        float xPot, yPot;
        int   count    = 0;
        int   tmpCount = 0;
        float maxTime  = ComputeMaxTime(spanPot);

        for (int i = 0; i < xCount; i++)
        {
            xPot = startPot.x + i * cellSizeX;

            for (int j = 0; j < yCount; j++)
            {
                yPot = startPot.y + j * cellSizeY;
//				if(spanPot.y>=0)
//				else {
//					yPot= startPot.y + (yCount-j-1) * cellSizeY;
//				}

                count++;
                tmpCount = count;
                if (spanPot.y < 0)
                {
                    tmpCount = count - (yCount - j - 1);
                }

                DynamicBrick db = pool.Obtain();
                db.Comming                    = true;
                db.DelayTime                  = tmpCount * delayTime_Cell;
                db.LeastFrame                 = tmpCount;
                db.UseConstantSpeed           = useConstantSpeed;
                db.MaxMoveTime                = maxTime;
                db.BColor                     = BrickColor.GetRandomColor();
                db.TargetPot                  = new Vector3(xPot, yPot, 0);
                db.InitPot                    = db.TargetPot + spanPot;
                db.Go.transform.localPosition = db.InitPot;
                db.Go.GetComponent <Renderer> ().material.color = db.BColor.C;               // new Color (Random.Range (0f, 1f), Random.Range (0f, 1f), Random.Range (0f, 1f));
                db.Go.SetActive(false);

                dynamicBricks.Add(db);
            }
        }

        endPot.x = startPot.x + xCount * cellSizeX;
        endPot.y = startPot.y + yCount * cellSizeY;

        useContanstSpeed = !useContanstSpeed;
    }
Esempio n. 2
0
 public V_Block(Block parent, BlockType type, int bickNum, Vector3 locStartPot, Vector3 locEndPot, int moveDelay, float moveDuration, Vector3[] moveSpan)
     : base(parent, type, locStartPot, locEndPot, moveDelay, moveDuration)
 {
     for (int i = 0; i < bickNum; i++)
     {
         Brick brick = BlockManager.Instance().ObtainBrick();
         brick.M_Parent       = this;
         brick.M_Loc_StartPot = new Vector3(0, i * Brick.HEIGHT, 0);
         brick.M_Loc_EndPot   = brick.M_Loc_StartPot + ((moveSpan == null) ? Vector3.zero : moveSpan [i]);
         brick.M_MoveDelay    = i;
         brick.M_GO.GetComponent <Renderer> ().material.color = BrickColor.GetRandomColor().C;
         brick.M_GO.SetActive(true);
         brick.MoveActiveCondition = this.IsMoveOver;
         brick.M_MoveDuration      = 1f;
         m_Bricks.Add(brick);
     }
 }