Ejemplo n.º 1
0
 private void Awake()
 {
     _currentHealth = _healthConfigSO.MaxHealth;
     if (_setHealthBar != null)
     {
         _setHealthBar.RaiseEvent(_currentHealth);
     }
 }
Ejemplo n.º 2
0
    [SerializeField] private GameResultChannelSO _gameResultEvent; //picked up by UI Manager

    private void Start()
    {
        _cc = GetComponent <CharacterController>();
        _playerController   = GetComponent <PlayerController>();
        _animalSoundManager = GetComponent <AnimalSoundsManager>();

        _currentHealth = MAX_HEALTH;
        _changeHealthUIEvent.RaiseEvent(_currentHealth);
        _currentCheckpoint = transform.position;
    }
    public void ButtonClicked()
    {
        int idType = (int)_currentType;

        Debug.Log(idType);
        _buttonClickedEvent.RaiseEvent(idType);
    }
Ejemplo n.º 4
0
 void UseItem(ItemSO itemToUse)
 {
     if (itemToUse.HealthResorationValue > 0)
     {
         _restoreHealth.RaiseEvent(itemToUse.HealthResorationValue);
     }
     _useItemEvent.RaiseEvent(itemToUse);
     UpdateInventory();
 }
Ejemplo n.º 5
0
    public void Init(CameraController controller, Vector3 rebirthVector)
    {
        SetCameraController(controller);
        _abilities.SetRebirthPoint(_rebirthVector = rebirthVector);
        _abilities.RebirthCharacter();

        _inflictDamageEvent.OnEventRaised += ReceiveDamage;
        _inflictHealingEvent.RaiseEvent(3);
    }
Ejemplo n.º 6
0
    public void Attack(Damageable damageableTemp)
    {
        if (CanAttack(_itemStatus.ItemState, damageableTemp))
        {
            //damageable.ReceiveAnAttack(_attackConfigSO.AttackStrength);
            _inflictDamageEvent.RaiseEvent(_attackConfigSO.AttackStrength);

            damageableTemp.ResetGetHit(_attackConfigSO.AttackReloadDuration);
        }
    }
Ejemplo n.º 7
0
    // void Update() {}
    // void FixedUpdate() {}

    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == tagToDetect)
        {
            if (pickupEvent != null)
            {
                pickupEvent.RaiseEvent(gameObject.GetInstanceID());
            }
        }
    }
Ejemplo n.º 8
0
    /// <summary> Resets this hand by clearing card data. Warning! Will set CurrentlySelected to null. </summary>
    public void ResetHand()
    {
        for (int i = 0; i < _cards.Count; i++)
        {
            _cards[i] = null;
        }

        _selected      = _cards[0];
        _selectedIndex = 0;

        // Update the player visuals to reflect equipment changes
        if (PlayerVisuals != null)
        {
            PlayerVisuals.RaiseEvent();
        }
        if (UICurrentCardChange != null)
        {
            UICurrentCardChange.RaiseEvent(_selectedIndex);
        }
    }
Ejemplo n.º 9
0
 public void restoreHealth(int healthToAdd)
 {
     if (IsDead)
     {
         return;
     }
     _currentHealth += healthToAdd;
     if (_restoreHealth != null)
     {
         _restoreHealth.RaiseEvent(healthToAdd);
     }
 }
Ejemplo n.º 10
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.tag == "Collectable")
        {
            collectableCount++;
            _changeScoreUIEvent.RaiseEvent(collectableCount);

            _animalSoundManager.PlayFishPickup();

            Destroy(other.gameObject);
        }
    }
Ejemplo n.º 11
0
    /* --------------------------------------- */
    /* ---------------- Public --------------- */
    /* --------------------------------------- */

    /// <summary> Only used for shooting weapon cards. </summary>
    public void FireProjectile()
    {
        // Cant shoot if player not holding a gun
        if (pHand.CurrentlySelected == null)
        {
            return;
        }

        // If currently selected card is not of type "weapon" don't do anything
        if (pHand.CurrentlySelected.CardType != ItemType.weapon)
        {
            return;
        }

        // Type conversion to WeaponCardSO since not all cards can shoot...
        WeaponCardSO weaponCardRefr = pHand.CurrentlySelected as WeaponCardSO;

        /*
         * Might modify how projectile timing works. This currently allows for "full auto" weapon types
         * without instantiating like hundreds of projectiles in a fraction of a second since this function
         * could theoretically be called every single frame
         */
        if ((Time.time - timeSinceLastAttack) >= weaponCardRefr.ROF)
        {
            // Cache time last fired weapon
            timeSinceLastAttack = Time.time;

            // Spawn the projectile to fire
            ProjectileHandler refr = LeanPool.Spawn <ProjectileHandler>(_projComponentRefr, _projSpawnLocation.position, _projSpawnLocation.rotation, _projParentObject.transform);

            // Set the ProjectileData for the spawned projectile
            refr._projData = weaponCardRefr.ProjectileData;

            if (UpdateProjectileData != null)
            {
                UpdateProjectileData.RaiseEvent(refr.gameObject.GetInstanceID());
            }

            // Activate necessary events
            if (KnockbackEvent != null)
            {
                KnockbackEvent.RaiseEvent();
            }
            if (CameraShakeEvent != null)
            {
                CameraShakeEvent.RaiseEvent(weaponCardRefr._camShakePreset);
            }
        }
    }
Ejemplo n.º 12
0
 public void ReceiveAnAttack(int damage)
 {
     if (IsDead)
     {
         return;
     }
     if (_inflictDamage != null)
     {
         _inflictDamage.RaiseEvent(damage);
     }
     _currentHealth -= damage;
     GetHit          = true;
     if (_currentHealth <= 0)
     {
         IsDead = true;
         if (OnDie != null)
         {
             OnDie.Invoke();
         }
     }
 }
Ejemplo n.º 13
0
    public void CollectableGathered()
    {
        _playerScore++;

        _playerScoreUI.RaiseEvent(_playerScore);
    }
Ejemplo n.º 14
0
 public void Heal(Damageable damageable)
 {
     _inflictHealingEvent.RaiseEvent(_healingConfigSO.HealingStrength);
 }