public void OnMapObjectAssembled() { _healthContainer = GetComponent <IHealthContainer>(); _healthContainer.OnHealthChanged += OnHealthChanged; _healthContainer.OnHealthExhausted += OnHealthExhausted; }
private void Awake() { _healthContainer = GetComponent <IHealthContainer>(); _camera = GetComponent <Camera>(); _healthContainer.OnHealthChanged += OnHealthChanged; }
private void Init() { _mods = new ModContainer(_stats, _events); Instance = this; _health = GetComponent <IHealthContainer>(); _unlocks = GetComponent <IUnlockList>(); _resources = GetComponent <IResourceContainer>(); _inventory = GetComponent <IInventory>(); if (_resources != null) { _resources?.ChangeResource(CreditsResource, 0); } ResourceEarningMultiplier = new Dictionary <string, IStatReference>(); _resourceFractionTrackers = new Dictionary <string, float>(); Resource[] resources = Content.GetAll <Resource>("*/Resources"); foreach (Resource resource in resources) { ResourceEarningMultiplier.Add(resource.Identifier, _stats.AddStat(GenerateStatInfo(resource), 1f)); _resourceFractionTrackers.Add(resource.Identifier, 0f); } OnNewPlayerInstance?.Invoke(this); }
private void PerformSpawn() { if (Time.time > _nextSpawnTime) { if (!_isInfinite) { _spawnCounter++; } _nextSpawnTime = Time.time + _spawnRate; SpawnedPooled spawnedObject = _spawnPool.Get(); IHealthContainer iHealthContainer = spawnedObject.GetComponent <IHealthContainer>(); if (iHealthContainer != null) { iHealthContainer.SetHP(_waveHp); } ISpeedContainer iSpeedContainer = spawnedObject.GetComponent <ISpeedContainer>(); if (iSpeedContainer != null) { iSpeedContainer.SetSpeed(_spawnedSpeed); } spawnedObject.Init(_spawnPool, _spawnedMaxLifeTime); if (_tracker) { spawnedObject.InitTracker(_tracker); } _spawnPool.ActivateObject(spawnedObject.gameObject); spawnedObject.transform.position = transform.position; Vector3 eulerRotaion = new Vector3( spawnedObject.transform.eulerAngles.x, _startYAngle, spawnedObject.transform.eulerAngles.z ); spawnedObject.transform.rotation = Quaternion.Euler(eulerRotaion); } }
private void Start() { _healthContainer = GetComponent <IHealthContainer>(); _healthContainer.OnHealthChanged += OnHealthChanged; OnHealthChanged(0f, _healthContainer.GetCurrentHealth(), _healthContainer.GetCurrentHealth()); }
public void Awake() { _health = GetComponent <IHealthContainer>(); _health.OnHealthExhausted += LooseTheGame; }
public HealthComponent(int initialMaxHealth, IHealthContainer healthContainer) { _maxHealth = initialMaxHealth; _healthContainer = healthContainer ?? throw new ArgumentNullException(nameof(healthContainer)); }