Пример #1
0
    void Start()
    {
        gameController     = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController> ();
        activePos          = transform.position;
        inActivePos        = new Vector3(transform.position.x, transform.position.y - 1.5f, transform.position.z);
        transform.position = inActivePos;
        GameObject shObject = GameObject.Find("Spell Handler");

        if (shObject != null)
        {
            spellHandler = shObject.GetComponent <SpellHandler>();
        }
        isReady    = false;
        DescCanvas = GameObject.Find("Description Canvas");
        splitter   = GameObject.FindGameObjectWithTag("Splitter").GetComponent <Splitter_script> ();

        spriteHolder = GameObject.Find("Piece Sprite Holder").GetComponent <Piece_Sprite_Holder> ();
        sprites      = spriteHolder.Get_Sprites();

        imageRenderer = GetComponent <Image> ();

        switch (spellColor)
        {
        case "Red":
            imageRenderer.sprite = sprites[0];
            break;

        case "Orange":
            imageRenderer.sprite = sprites[1];
            break;

        case "Yellow":
            imageRenderer.sprite = sprites[2];
            break;

        case "Green":
            imageRenderer.sprite = sprites[3];
            break;

        case "Blue":
            imageRenderer.sprite = sprites[4];
            break;

        case "Purple":
            imageRenderer.sprite = sprites[5];
            break;

        case "Cyan":
            imageRenderer.sprite = sprites[6];
            break;

        case "White":
            imageRenderer.sprite = sprites[7];
            break;
        }
        wasTouching     = false;
        isTransitioning = false;
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        GameObject BitPoolObject = GameObject.Find("Bit Pool");

        if (BitPoolObject == null)
        {
            Debug.LogError("ScoreBit Error: Cannot find the Bit Pool");
        }
        else
        {
            BitPool = BitPoolObject.GetComponent <Bit_Pool>();
        }
        transform.position = BitPoolObject.transform.position;
        Piece_Sprite_Holder spriteHolder = GameObject.Find("Piece Sprite Holder").GetComponent <Piece_Sprite_Holder> ();

        sprites = spriteHolder.Get_Sprites();
        gameObject.SetActive(false);
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        isBomb     = false;
        isMoving   = false;
        groupValue = 1;
        GameObject gameControllerObject = GameObject.FindWithTag("GameController");

        if (gameControllerObject != null)
        {
            gameController = gameControllerObject.GetComponent <GameController>();
        }
        GameObject splitterObject = GameObject.Find("Splitter");

        if (splitterObject != null)
        {
            splitter = splitterObject.GetComponent <Splitter_script>();
        }
        GameObject spellHandlerObject = GameObject.Find("Spell Handler");

        if (spellHandlerObject != null)
        {
            spellHandler = spellHandlerObject.GetComponent <SpellHandler>();
        }
        //set grid position to -3,-3 until it's locked to prevent accidental cancelling.
        gridPos = new Vector2(-3, -3);

        GameObject BitPoolObject = GameObject.Find("Bit Pool");

        if (BitPoolObject == null)
        {
            Debug.LogError("Piece Error: Cannot find the Bit Pool");
        }
        else
        {
            BitPool = BitPoolObject.GetComponent <Bit_Pool>();
        }

        clacker = GameObject.Find("Clacker");

        //time to set up piece visuals
        spriteHolder = GameObject.Find("Piece Sprite Holder").GetComponent <Piece_Sprite_Holder> ();
        sprites      = spriteHolder.Get_Sprites();
        animations   = spriteHolder.Get_Animations();
        if (animations == null)
        {
            Destroy(gameObject.GetComponent <Animator>());
        }
        switch (pieceColor)
        {
        case "Red":
            colornum = 0;
            break;

        case "Orange":
            colornum = 1;
            break;

        case "Yellow":
            colornum = 2;
            break;

        case "Green":
            colornum = 3;
            break;

        case "Blue":
            colornum = 4;
            break;

        case "Purple":
            colornum = 5;
            break;

        case "Cyan":
            colornum = 6;
            break;

        case "White":
            colornum = 7;
            break;
        }
        gameObject.GetComponent <SpriteRenderer> ().sprite = sprites [colornum];
        if (animations != null)
        {
            gameObject.GetComponent <Animator> ().runtimeAnimatorController = animations[colornum];
        }
        prevColorNum = ((int)Time.time) % 8;
        //multiplier = 1;
        hasPlayedAnim = false;
    }
Пример #4
0
    //updates the color based on what color it is
    public void update_color()
    {
        sprites = spriteHolder.Get_Sprites();
        switch (pieceColor)
        {
        case "Red":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[0];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[0];
            }
            break;

        case "Orange":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[1];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[1];
            }
            break;

        case "Yellow":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[2];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[2];
            }
            break;

        case "Green":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[3];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[3];
            }
            break;

        case "Blue":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[4];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[4];
            }
            break;

        case "Purple":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[5];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[5];
            }
            break;

        case "Cyan":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[6];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[6];
            }
            break;

        case "White":
            if (gameObject.GetComponent <SpriteRenderer>())
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = sprites[7];
            }
            else
            {
                gameObject.GetComponent <Image>().sprite = sprites[7];
            }
            break;
        }
    }