Esempio n. 1
0
    private void ActivateSprite(Vector2 position)
    {
        if (BoardAgent.GetSpriteEnabled(position))
        {
            return;
        }

        BoardAgent.SetSpriteImage(position, SpriteAgent.GetCurrentSprite());

        Color color = ColorAgent.GetCurrentColorPack().foregroundColor;

        if (color == ColorAgent.RainbowColor)
        {
            BoardAgent.SetSpriteColor(position, Utilities.ColorFromHSV(((position.y / (float)BoardAgent.BoardHeight) * 360f + colorOffset) % 360f, 1f, 1f));
        }
        else if (color == ColorAgent.RandomColor)
        {
            BoardAgent.SetSpriteColor(position, Utilities.ColorFromHSV(Random.Range(0f, 360f), 1f, 1f));
        }
        else
        {
            BoardAgent.SetSpriteColor(position, color);
        }

        BoardAgent.SetSpriteScale(position, new Vector3(BoardAgent.CellSize * (Random.value < 0.5f ? 1f : -1f), BoardAgent.CellSize * (Random.value < 0.5f ? 1f : -1f), 1f));
        BoardAgent.SetSpriteEnabled(position, true);
    }
    private void OnTouchUp(int fingerIndex, Vector2 fingerPos, float timeHeldDown)
    {
        if (!gameObject.activeInHierarchy || (ignoreOnPopUp && RatingAgent.GetPopUpEnabled()))
        {
            return;
        }

        if (colorController)
        {
            colorController.SetColor(ColorAgent.GetCurrentColorPack().TypeToColor(colorController.colorType));
        }

        if (GameAgent.GetWasHolding())
        {
            return;
        }

        if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, fingerPos, null))
        {
            if (OnAreaTouch != null)
            {
                OnAreaTouch();
            }

            if (OnAreaTouchWithCallback != null)
            {
                OnAreaTouchWithCallback(this);
            }

            AudioAgent.PlaySoundEffect(AudioAgent.SoundEffectType.ButtonTap);
        }
    }
Esempio n. 3
0
    void Awake()
    {
        if (mInstance != null)
        {
            Debug.LogError("Only one instance of ColorAgent allowed. Destroying " + gameObject + " and leaving " + mInstance.gameObject);
            Destroy(gameObject);
            return;
        }

        mInstance = this;

        colorPacks = new ColorPack[Enum.GetNames(typeof(ColorPackType)).Length - 1];

        colorPacks[(int)ColorPackType.Classic]    = new ColorPack(Color.white, new Color(0f, 0.5f, 0.75f));
        colorPacks[(int)ColorPackType.Beige]      = new ColorPack(new Color(0.3f, 0.29f, 0.26f), new Color(0.85f, 0.83f, 0.73f));
        colorPacks[(int)ColorPackType.Monochrome] = new ColorPack(Color.black, Color.white);
        colorPacks[(int)ColorPackType.Rainbow]    = new ColorPack(RainbowColor, Color.black);
        colorPacks[(int)ColorPackType.Sprinkles]  = new ColorPack(RandomColor, new Color(0.06f, 0.1f, 0.14f));


        currentColors    = new Color[Enum.GetNames(typeof(ColorType)).Length - 1];
        colorControllers = new List <ColorController> [Enum.GetNames(typeof(ColorType)).Length - 1];

        for (int i = 0; i < colorControllers.Length; i++)
        {
            colorControllers[i] = new List <ColorController>();
        }

        /*
         * if( PlayerPrefs.HasKey( colorPackIndexString ) )
         *      colorPackIndex = PlayerPrefs.GetInt( colorPackIndexString );
         * else
         *      colorPackIndex = 0;
         */
    }
    private void OnTouchDown(int fingerIndex, Vector2 fingerPos)
    {
        if (!gameObject.activeInHierarchy || (ignoreOnPopUp && RatingAgent.GetPopUpEnabled()))
        {
            return;
        }

        if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, fingerPos, null) && !GameAgent.GetWasHolding())
        {
            colorController.SetColor(ColorAgent.GetCurrentColorPack().midColor);
        }
    }
Esempio n. 5
0
    public void SetColor(Color color)
    {
        if (colorType == ColorAgent.ColorType.Foreground && (color == ColorAgent.RainbowColor || color == ColorAgent.RandomColor))
        {
            color = (ColorAgent.GetCurrentColorPack().backgroundColor == Color.white ? Color.black : Color.white);
        }

        switch (uiType)
        {
        case UIType.UIImage: GetComponent <Image>().color = new Color(color.r, color.g, color.b, GetComponent <Image>().color.a); break;

        case UIType.UIText: GetComponent <Text>().color = new Color(color.r, color.g, color.b, GetComponent <Text>().color.a); break;

        case UIType.UICamera: GetComponent <Camera>().backgroundColor = new Color(color.r, color.g, color.b, GetComponent <Camera>().backgroundColor.a); break;
        }
    }
Esempio n. 6
0
    private void internalChangeState(State newState)
    {
        if (currentState == newState)
        {
            return;
        }

        currentState = newState;

        switch (currentState)
        {
        case State.Ready:
        {
            showUI = true;
            SetUIEnabled(false);
            TipAgent.ShowFirstTip();
            UpdateNavigationHighlight(true);

            ColorAgent.AdvanceColorPack();

            SpriteAgent.ClearSpriteNames();

            BoardAgent.ResetBoard();
            ShuffleDeck();
            colorOffset = Random.Range(0f, 360f);
            SpriteAgent.Randomize();

            index = 0;
        } break;

        case State.Printing:
        {
            SetUIEnabled(false);

            speed = (float)BoardAgent.BoardSize / fillTime;

            SpriteAgent.LogSpriteName();

            AudioAgent.PlaySoundEffect(AudioAgent.SoundEffectType.Print, fillTime);
            AudioAgent.PitchSoundEffect(AudioAgent.SoundEffectType.Print, 1f);

            if (index == 0)
            {
                StartCoroutine("DoPrint");
            }
        } break;

        case State.Paused:
        {
            TipAgent.ShowNextTip();
            SetUIEnabled(true);

            speed = 0f;

            AudioAgent.PauseSoundEffect(AudioAgent.SoundEffectType.Print);
        } break;

        case State.FastForwarding:
        {
            SetUIEnabled(false);

            speed = (float)BoardAgent.BoardSize / fillTime * 5f;

            AudioAgent.PitchSoundEffect(AudioAgent.SoundEffectType.Print, 2f);

            wasFastForwarding = true;
        } break;

        case State.Finished:
        {
            showUI = true;
            TipAgent.ShowNextTip();
            SetUIEnabled(true);
        } break;

        case State.Advertising:
        {
            SetUIEnabled(false);
            RatingAgent.CheckForPrompt();
            //AdAgent.ShowInterstitialImage();
        } break;
        }
    }
Esempio n. 7
0
 void OnDisable()
 {
     ColorAgent.UnregisterColorController(this);
 }
Esempio n. 8
0
 void OnEnable()
 {
     ColorAgent.RegisterColorController(this);
     SetColor(ColorAgent.GetCurrentColorPack().TypeToColor(colorType));
 }