Exemplo n.º 1
0
 IEnumerator changeBeatState()
 {
     while(true) {
         beatAccum = 0f;
         heartState = HeartState.contractSamll;
         SoundManager.getInstance().playHeartUpBeat();
         yield return null;
         beatAccum = 0f;
         heartState = HeartState.pulseWait;
         yield return null;
         beatAccum = 0f;
         heartState = HeartState.expandFromSmall;
         yield return null;
         beatAccum = 0f;
         heartState = HeartState.pulseWait;
         yield return null;
         beatAccum = 0f;
         SoundManager.getInstance().playHeartDownBeat();
         heartState = HeartState.contractLarge;
         yield return null;
         beatAccum = 0f;
         heartState = HeartState.pulseWait;
         yield return null;
         beatAccum = 0f;
         heartState = HeartState.expandFromLarge;
         yield return null;
         beatAccum = 0f;
         heartState = HeartState.periodWait;
         yield return null;
     }
 }
Exemplo n.º 2
0
        private void AddHearts(HeartState heartState, uint count = 1)
        {
            string imageName = string.Empty;

            if (heartState == HeartState.Empty)
            {
                imageName = "ui_heart_empty";
            }
            else if (heartState == HeartState.Half)
            {
                imageName = "ui_heart_half";
            }
            else if (heartState == HeartState.Full)
            {
                imageName = "ui_heart_full";
            }

            Vector2u imageSize = ImageManager.Get(imageName).Size;

            for (int i = 0; i < count; i++)
            {
                Vector2f heartPosition = new Vector2f(Position.X + (imageSize.X * Config.TextureScale.X * hearts.Count), Position.Y);
                hearts.Add(new DisplayComponent(imageName, heartPosition));
            }
        }
Exemplo n.º 3
0
    public void SetHeart(HeartState state)
    {
        switch (state)
        {
        case HeartState.Full:
            fullHeart.SetActive(true);
            halfHeart.SetActive(false);
            EmptyHeart.SetActive(false);
            currentState = HeartState.Full;
            PlayFillAnimation();
            prevState = HeartState.Full;
            break;

        case HeartState.Half:
            halfHeart.SetActive(true);
            fullHeart.SetActive(false);
            EmptyHeart.SetActive(false);
            currentState = HeartState.Half;
            PlayFillAnimation();
            prevState = HeartState.Half;
            break;

        case HeartState.Empty:
            EmptyHeart.SetActive(true);
            fullHeart.SetActive(false);
            halfHeart.SetActive(false);
            currentState = HeartState.Empty;
            prevState    = HeartState.Empty;
            break;
        }
    }
Exemplo n.º 4
0
		public async void StartHeartbeat()
		{
			if (_heartState == HeartState.Collapsed) {
				await heartImage.ScaleTo (1.1, 700, Easing.BounceOut);
				_heartState = HeartState.Expanded;
			} else {
				await heartImage.ScaleTo (1.0, 700);
				_heartState = HeartState.Collapsed;
			}

			StartHeartbeat ();
		}
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        eventDispatcher = EventDispatcher.Instance;

        BeatEvent = new UnityEvent();
        BeatEvent.AddListener(OnBeat);
        eventDispatcher.RegisterBeatListener(ref BeatEvent);

        PreBeatEvent = new UnityEvent();
        PreBeatEvent.AddListener(OnPreBeat);
        eventDispatcher.RegisterBeatListener(ref PreBeatEvent);
        state = HeartState.still;
    }
Exemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     if (state == HeartState.expanding)
     {
         transform.localScale = new Vector3(transform.localScale.x + animSpeed, transform.localScale.y + animSpeed, 1);
         if (transform.localScale.y >= maxScale)
         {
             state = HeartState.retracting;
         }
     }
     if (state == HeartState.retracting)
     {
         transform.localScale = new Vector3(transform.localScale.x - animSpeed, transform.localScale.y - animSpeed, 1);
         if (transform.localScale.y <= minScale)
         {
             state = HeartState.still;
         }
     }
 }
Exemplo n.º 7
0
 public void FillHeart(Heart anotherHeart)
 {
     this.HeartId           = anotherHeart.HeartId;
     this.CreationDate      = anotherHeart.CreationDate;
     this.RelativeUrl       = anotherHeart.RelativeUrl;
     this.ParentHeartId     = anotherHeart.ParentHeartId;
     this.BreadcrumbsTitle  = anotherHeart.BreadcrumbsTitle;
     this.Noindex           = anotherHeart.Noindex;
     this.Title             = anotherHeart.Title;
     this.MetaDescription   = anotherHeart.MetaDescription;
     this.MetaKeywords      = anotherHeart.MetaKeywords;
     this.Styles            = anotherHeart.Styles;
     this.Scripts           = anotherHeart.Scripts;
     this.Layout            = anotherHeart.Layout;
     this.AdditionalHeaders = anotherHeart.AdditionalHeaders;
     this.CanonicalUrl      = anotherHeart.CanonicalUrl;
     this.Type    = anotherHeart.Type;
     this.Options = anotherHeart.Options.ToDictionary(x => x.Key, x => x.Value);
     this.State   = anotherHeart.State;
 }
Exemplo n.º 8
0
    /// <summary>
    /// Switches the sprite for the selected heart to the given state
    /// </summary>
    /// <param name="heart">GameObject to switch sprite on</param>
    /// <param name="state">The state; either full;half;empty</param>
    private void switchHeartSprite(GameObject heart, HeartState state)
    {
        try {
            Image currentSprite = heart.GetComponent <Image>();
            switch (state)
            {
            case HeartState.Full:
                if (currentSprite != null && currentSprite.sprite != spriteHeartFull)
                {
                    currentSprite.sprite = spriteHeartFull;
                }
                break;

            case HeartState.Half:
                if (currentSprite != null && currentSprite.sprite != spriteHeartHalf)
                {
                    currentSprite.sprite = spriteHeartHalf;
                }

                break;

            case HeartState.Empty:
                if (currentSprite != null && currentSprite.sprite != spriteHeartEmpty)
                {
                    currentSprite.sprite = spriteHeartEmpty;
                }

                break;

            default:
                Debug.Log("Invalid state entered");
                break;
            }
        }
        catch (Exception e) {
            Console.WriteLine("Unable to update sprite");
            throw;
        }
    }
Exemplo n.º 9
0
 void OnPreBeat()
 {
     state = HeartState.expanding;
     transform.localScale = new Vector3(minScale, minScale, 1);
 }
Exemplo n.º 10
0
 void OnBeat()
 {
     state = HeartState.retracting;
     //transform.localPosition = new Vector3(0, maxHeight, -5);
 }
Exemplo n.º 11
0
 public void SetState(HeartState state)
 {
     this.state = state;
 }
Exemplo n.º 12
0
    public void lifeUpdate(HeartState heartState)
    {
        this.heartState = heartState;

        lifeUpdate();
    }
Exemplo n.º 13
0
 private void newGame()
 {
     heartState = HeartState.FULL;
 }