public override void Initialize() { base.Initialize(); _logger = Game.Instance.LoggerFactory("PopupDisplay"); _logger.Assert(_weightText != null, "WeightText not found. Drag and drop it to game object."); _logger.Assert(_cakesText != null, "CakesText not found. Drag and drop it to game object."); _logger.Assert(_teasText != null, "TeasText not found. Drag and drop it to game object."); _logger.Assert(_timerBackground != null, "TimerBackground not found. Drag and drop it to game object."); _logger.Assert(_timerText != null, "TimerText not found. Drag and drop it to game object."); Game.Instance.RegisterOnResetEvent(this); Game.Instance.Locale.OnLanguageUpdated += UpdateTexts; _model = Game.Instance.PrincessCake.Model; _model.OnConsumeCake += UpdateWeightDisplay; _model.OnConsumeCake += UpdateCakesDisplay; _model.OnConsumeTea += UpdateWeightDisplay; _model.OnConsumeTea += UpdateTeaDisplay; DeactivateTimer(); UpdateTexts(); }
private void Awake() { Model = new PrincessCakeModel(name, Settings); _characterCtrl = this.GetOrAddComponent <CharacterController>(); _characterCtrlDefaultRadius = _characterCtrl.radius; _fpsCtrl = this.GetOrAddComponent <FirstPersonController>(); _audio = this.GetOrAddComponent <AudioSource>(); Model.OnConsumeCake += () => { if (Model.IsAtMinWeight) { _audio.TryPlaySFX(_onConsumeCake); } else if (Model.IsAtMaxWeight) { _audio.TryPlaySFX(_onConsumeCakeChubby); } else { _audio.TryPlaySFX(_onConsumeCakeFat); } StartCoroutine( TryPlaySFXAfterSeconds(_gainWeightSFXDelayAfterEatInSeconds, _onGainWeight) ); UpdateCharacterCtrlRadius(); Game.Instance.UI.Popup.TryDisplayCakeConsumedTip(); if (Model.IsAtMediumWeight) { Game.Instance.UI.Popup.TryDisplayReachedMaxWeightTip(); } }; Model.OnConsumeTea += () => { _audio.TryPlaySFX(_onConsumeTea); StartCoroutine( TryPlaySFXAfterSeconds(_gainWeightSFXDelayAfterEatInSeconds, _onLoseWeight) ); UpdateCharacterCtrlRadius(); Game.Instance.UI.Popup.TryDisplayTeaConsumedTip(); }; _lastCheckpoint = transform.position; _lastCheckpointState = new PrincessCakeModel(Model); }
public bool CanMoveBy(PrincessCakeModel princessCake) { return(princessCake.CanMove(this)); }
public void CopyStats(PrincessCakeModel other) { _weight = other.Weight; _cakesEaten = other.CakesEaten; _teasDrunk = other.TeasDrunk; }
public PrincessCakeModel(PrincessCakeModel other) : this(other.Name, other._settings) { CopyStats(other); }