Ejemplo 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);
    }
Ejemplo n.º 2
0
    void Awake()
    {
        if (mInstance != null)
        {
            Debug.LogError("Only one instance of SpriteAgent allowed. Destroying " + gameObject + " and leaving " + mInstance.gameObject);
            Destroy(gameObject);
            return;
        }

        mInstance = this;

        spritesUnlocked       = new Dictionary <string, bool>();
        unlockedSpriteIndices = new List <int>();
        spritesUsed           = new List <string>();

        for (int i = 0; i < sprites.Length; i++)
        {
            string spriteName = sprites[i].name;

            if (!PlayerPrefs.HasKey(spriteName))
            {
                PlayerPrefs.SetInt(spriteName, (System.Array.IndexOf(freeSprites, sprites[i].name) != -1 ? 1 : 0));
            }

            bool spriteUnlocked = (PlayerPrefs.GetInt(spriteName) == 1);

            spritesUnlocked.Add(spriteName, spriteUnlocked);

            if (i < storeSpriteControllers.Length)
            {
                storeSpriteControllers[i].sprite.sprite = sprites[i];

                storeSpriteControllers[i].outline.rectTransform.offsetMin = Vector2.one * outlineWidth * -1f;
                storeSpriteControllers[i].outline.rectTransform.offsetMax = Vector2.one * outlineWidth;

                if (!spritesUnlocked[spriteName])
                {
                    storeSpriteControllers[i].sprite.color     = new Color(storeSpriteControllers[i].sprite.color.r, storeSpriteControllers[i].sprite.color.g, storeSpriteControllers[i].sprite.color.b, 0.5f);
                    storeSpriteControllers[i].background.color = new Color(storeSpriteControllers[i].background.color.r, storeSpriteControllers[i].background.color.g, storeSpriteControllers[i].background.color.b, 0.5f);
                    storeSpriteControllers[i].outline.color    = new Color(storeSpriteControllers[i].outline.color.r, storeSpriteControllers[i].outline.color.g, storeSpriteControllers[i].outline.color.b, 0.5f);
                }
                else
                {
                    unlockedSpriteIndices.Add(i);
                }
            }
        }

        CheckAllSpritesUnlocked();

        if (!PlayerPrefs.HasKey(spriteIndexString))
        {
            PlayerPrefs.SetInt(spriteIndexString, 0);
        }

        SetSpriteIndex(PlayerPrefs.GetInt(spriteIndexString));

        UnlockAllSprites();
    }
Ejemplo n.º 3
0
		public override void OnEnter ()
		{
			if (mTarget == null) {
				mTarget = owner.GetValue(target);
			}
			agent = ownerDefault.GetComponent<SpriteAgent> ();
			facingRight = ownerDefault.transform.localScale.x > 0;
		}
Ejemplo n.º 4
0
 public override void OnEnter()
 {
     if (mTarget == null)
     {
         mTarget = owner.GetValue(target);
     }
     agent       = ownerDefault.GetComponent <SpriteAgent> ();
     facingRight = ownerDefault.transform.localScale.x > 0;
 }
    private void OnTriggerEnter2D(Collider2D other)
    {
        SpriteAgent agent = other.GetComponent <SpriteAgent> ();

        if (agent != null)
        {
            Vector2 dir = new Vector2(end.position.x, end.position.y) - agent.position;
            if (agent.transform.localScale.x > 0 && dir.x > 0 || agent.transform.localScale.x < 0 && dir.x < 0)
            {
                agent.currentJumpLink = this;
                agent.isOnJumpLink    = true;
            }
        }
    }
Ejemplo n.º 6
0
		public override void OnAwake ()
		{
			agent = owner.GetComponent<SpriteAgent> ();
		}
Ejemplo n.º 7
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;
        }
    }
Ejemplo n.º 8
0
		public override void OnAwake ()
		{
			agent = owner.GetComponent<SpriteAgent> ();
			rigidbody2D = owner.GetComponent<Rigidbody2D> ();
			animator = owner.GetComponent<Animator> ();
		}
 private void OnEnable()
 {
     agent = (SpriteAgent)target;
 }
Ejemplo n.º 10
0
 public override void OnAwake()
 {
     agent       = owner.GetComponent <SpriteAgent> ();
     rigidbody2D = owner.GetComponent <Rigidbody2D> ();
     animator    = owner.GetComponent <Animator> ();
 }
	private void OnEnable(){
		agent = (SpriteAgent)target;
	}
Ejemplo n.º 12
0
 public override void OnAwake()
 {
     agent = owner.GetComponent <SpriteAgent> ();
 }