// Use this for initialization
 void Start()
 {
     GameObject go = GameObject.FindWithTag("Piece Queue");
     if(go)
         pieceQueue = go.GetComponent<PieceQueue>();
     savedPositions = new Stack<Vector2>();
     animator = GetComponent<Animator>();
 }
    // Use this for initialization
    void Start()
    {
        GameObject go = GameObject.FindWithTag("Piece Queue");

        if (go)
        {
            pieceQueue = go.GetComponent <PieceQueue>();
        }
        savedPositions = new Stack <Vector2>();
        animator       = GetComponent <Animator>();
    }
    // Use this for initialization
    void Awake()
    {
        creator = GameObject.FindWithTag("Piece Queue").GetComponent<PieceQueue>();
        rigidbody2D.isKinematic = true;

        childColliders = new List<CollisionCheck>();

        InvokeRepeating("UpdateHeight", 0.75f, 1.0f);

        for(int i = 0; i < transform.childCount; i++){
            GameObject child = transform.GetChild(i).gameObject;
            childColliders.Add((CollisionCheck)	child.AddComponent("CollisionCheck"));
        }
    }
    // Use this for initialization
    void Awake()
    {
        creator = GameObject.FindWithTag("Piece Queue").GetComponent <PieceQueue>();
        rigidbody2D.isKinematic = true;

        childColliders = new List <CollisionCheck>();

        InvokeRepeating("UpdateHeight", 0.75f, 1.0f);

        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject child = transform.GetChild(i).gameObject;
            childColliders.Add((CollisionCheck)child.AddComponent("CollisionCheck"));
        }
    }
Exemple #5
0
        public void Draw(RenderWindow window, PieceQueue pieceQueue)
        {
            float yHeightModifier = 0;

            foreach (PieceType pieceType in pieceQueue.Get())
            {
                float xOffset = pieceType == PieceType.I ? 1.5f : pieceType == PieceType.O ? 1.5f : 2.0f;
                float yOffset = pieceType == PieceType.I ? 3.0f : 2.5f;

                foreach (Vector2i position in PieceTypeUtils.GetPieceTypeBlocks(pieceType))
                {
                    Sprite sprite = new Sprite();
                    sprite.Texture  = AssetPool.blockTextures[(int)pieceType];
                    sprite.Position = new Vector2f(
                        AssetPool.queueSprite.Position.X + AssetPool.blockSize.X * (position.X + xOffset),
                        AssetPool.queueSprite.Position.Y + AssetPool.blockSize.Y * (position.Y + yOffset) + yHeightModifier);

                    window.Draw(sprite);
                }

                yHeightModifier += AssetPool.blockSize.Y * 3;
            }
        }