// ----------------------------------------------------------------- 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; } }
// ----------------------------------------------------------------- public void SetMood(CatMood mood) { textFieldMood.text = CatStrings.GetByMood(mood); textFieldMood.RecalculateRectTransform(); SetMoodFieldColor(mood); }
protected CatState(GameManager gameManager, Animator catAnimator, StateSettings settings) { this.gameManager = gameManager; this.settings = settings; this.catAnimator = catAnimator; associatedMood = settings.AssociatedMood; }
// ----------------------------------------------------------------- void Start() { catActionsTable = new CatActionsTable(); currentMood = CatMood.GOOD; actionPanel.Init(this); infoPanel.SetMood(currentMood); }
protected IEnumerator PerformAction(float time, CatMood moodToChangeInto, bool transitionToIdle = true) { performingAction = true; yield return(new WaitForSeconds(time)); EndAction(transitionToIdle, moodToChangeInto); performingAction = false; }
// ----------------------------------------------------------------- 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); }
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()); }
// ----------------------------------------------------------------- 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"); } }
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; }
public readonly CatMood? newMood; // null if we wont change cat's mood // ----------------------------------------------------------------- public CatActionReaction(CatReaction reaction, CatMood newMood) { this.reaction = reaction; this.newMood = newMood; }
// ----------------------------------------------------------------- public CatActionTableKey(CatMood mood, CatAction action) { this.action = action; this.mood = mood; }
/// <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))); }