protected override void MyStart() { _flagChild = GetComponentInChildren <UnitFlagView>(); _unitModel = GetComponent <UnitModelComponent>().Model; var audioSource = GetComponent <AudioSource>(); if (audioSource == null) { Debug.LogWarning("W43 No audio source on unit"); } else { _unitModel.OnStepEvent += () => { audioSource.clip = MoveClip; audioSource.Play(); }; _unitModel.OnAttackEvent += () => { audioSource.clip = AttackClip; audioSource.Play(); }; _unitModel.OnDeathEvent += () => { audioSource.clip = DeathClip; audioSource.Play(); }; } }
private void UpdateView() { if (_flagChild == null) // todo more elegant solution { _flagChild = GetComponentInChildren <UnitFlagView>(); _unitModel = GetComponent <UnitModelComponent>().Model; } if (_flagChild != null) { _flagChild.SetFlagColor(Constants.PlayersFlagColors[_unitModel.Owner]); } }