예제 #1
0
        // -----------------------------------------------------------------
        private void SetMoodFieldColor(CatMood mood)
        {
            string colorString;

            switch (mood)
            {
            case CatMood.BAD:
                colorString = COLOR_RED;
                break;

            case CatMood.GOOD:
                colorString = COLOR_ORANGE;
                break;

            case CatMood.EXCELLENT:
                colorString = COLOR_GREEN;
                break;

            default:
                colorString = COLOR_GREEN;
                break;
            }

            Color moodTextColor;

            if (ColorUtility.TryParseHtmlString(colorString, out moodTextColor))
            {
                textFieldMood.color = moodTextColor;
            }
        }
예제 #2
0
        // -----------------------------------------------------------------
        public void SetMood(CatMood mood)
        {
            textFieldMood.text = CatStrings.GetByMood(mood);
            textFieldMood.RecalculateRectTransform();

            SetMoodFieldColor(mood);
        }
예제 #3
0
 protected CatState(GameManager gameManager, Animator catAnimator, StateSettings settings)
 {
     this.gameManager = gameManager;
     this.settings    = settings;
     this.catAnimator = catAnimator;
     associatedMood   = settings.AssociatedMood;
 }
예제 #4
0
        // -----------------------------------------------------------------
        void Start()
        {
            catActionsTable = new CatActionsTable();
            currentMood     = CatMood.GOOD;

            actionPanel.Init(this);
            infoPanel.SetMood(currentMood);
        }
예제 #5
0
        protected IEnumerator PerformAction(float time, CatMood moodToChangeInto, bool transitionToIdle = true)
        {
            performingAction = true;
            yield return(new WaitForSeconds(time));

            EndAction(transitionToIdle, moodToChangeInto);
            performingAction = false;
        }
예제 #6
0
        // -----------------------------------------------------------------
        public void ProcessAction(CatAction action)
        {
            CatActionReaction reaction = catActionsTable.GetCatActionReaction(new CatActionTableKey(currentMood, action));

            if (reaction.newMood != null)
            {
                currentMood = (CatMood)reaction.newMood;
            }

            infoPanel.SetMood(currentMood);
            infoPanel.SetReaction(reaction.reaction);
        }
예제 #7
0
 protected void EndAction(bool transitionToIdle, CatMood moodToChangeInto)
 {
     if (transitionToIdle)
     {
         catAnimator.SetTrigger(AnimationTrigger.GoToIdle);
     }
     if (moodToChangeInto != CatMood.None)
     {
         gameManager.TransitionToState(moodToChangeInto);
     }
     EventBus.FireEvent <ActionEndedEvent>(new ActionEndedEvent());
 }
예제 #8
0
        // -----------------------------------------------------------------
        public static string GetByMood(CatMood mood)
        {
            switch (mood)
            {
            case CatMood.BAD:
                return("Плохое");

            case CatMood.GOOD:
                return("Хорошее");

            case CatMood.EXCELLENT:
                return("Отличное");

            default:
                throw new Exception("Error: No such CatMood in strings");
            }
        }
예제 #9
0
    IEnumerator AwaitBeforeNewMood(float time)
    {
        onBehaving = true;
        behaviourSlider.minValue = Time.time;
        behaviourSlider.maxValue = time;
        while (Time.time < time)
        {
            Debug.Log("Waiting...");
            behaviourSlider.value = Time.time;
            yield return(null);
        }
        mood      = behaviour.triggerMood;
        behaviour = behaviour.triggerBehaviour;

        moodText.text      = mood.description;
        behaviourText.text = behaviour.description;

        animator.Play(clips.Find(clip => clip.Equals(behaviour.playClip)).name);
        Debug.Log("Finished");
        onBehaving = false;
    }
예제 #10
0
        public readonly CatMood?    newMood; // null if we wont change cat's mood

        // -----------------------------------------------------------------
        public CatActionReaction(CatReaction reaction, CatMood newMood)
        {
            this.reaction = reaction;
            this.newMood  = newMood;
        }
예제 #11
0
 // -----------------------------------------------------------------
 public CatActionTableKey(CatMood mood, CatAction action)
 {
     this.action = action;
     this.mood   = mood;
 }
예제 #12
0
 /// <summary>
 /// Select a behaviour using specific cat mood
 /// </summary>
 /// <param name="mood">Cat mood</param>
 /// <returns></returns>
 public CatBehaviour GetBehaviourByMood(CatMood mood)
 {
     return(triggerBehaviours.Find(behaviour => behaviour.intialMood.Equals(mood)));
 }