Skip to content
Snippets Groups Projects
Commit c8ccd2a6 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Merge branch 'master' into 'main'

Bug fix

See merge request !64
parents f6cab334 c34dda00
No related branches found
No related tags found
2 merge requests!75Main,!64Bug fix
...@@ -18,7 +18,7 @@ namespace BigSock { ...@@ -18,7 +18,7 @@ namespace BigSock {
public float AttackSpeed => Stats.AttackSpeed; public float AttackSpeed => Stats.AttackSpeed;
public float baseAttackSpeed = 1; public float baseAttackSpeed = 1;
public AudioSource[] source; public List<AudioSource> source = new List<AudioSource>();
public AudioClip TakeDamageAudio; public AudioClip TakeDamageAudio;
/* /*
...@@ -101,8 +101,7 @@ namespace BigSock { ...@@ -101,8 +101,7 @@ namespace BigSock {
*/ */
public ICharacterStats Stats { get; protected set; } = new CharacterStats(); public ICharacterStats Stats { get; protected set; } = new CharacterStats();
public Character() public Character() {
{
Inventory = new Inventory(this); Inventory = new Inventory(this);
Inventory.BackpackCap = 5; Inventory.BackpackCap = 5;
} }
...@@ -131,8 +130,14 @@ namespace BigSock { ...@@ -131,8 +130,14 @@ namespace BigSock {
Accuracy = 1, Accuracy = 1,
}; };
source = Camera.main.gameObject.GetComponents<AudioSource>(); // Add audio sources.
foreach(var s in Camera.main.gameObject.GetComponents<AudioSource>())
if(s != null)
source.Add(s);
var src = GetComponent<AudioSource>();
if(src != null) source.Add(src);
UpdateModifiers(); UpdateModifiers();
......
using System.Collections; using System.Collections;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
...@@ -60,7 +61,7 @@ namespace BigSock { ...@@ -60,7 +61,7 @@ namespace BigSock {
bulletScript.Direction = (target.Value - (Vector2) actor.transform.position).normalized; bulletScript.Direction = (target.Value - (Vector2) actor.transform.position).normalized;
// Play sound effect // Play sound effect
var source = actor.source[0]; var source = actor.source.FirstOrDefault();
var audioClip = AudioService.SINGLETON.Get(AUDIO_PATH); var audioClip = AudioService.SINGLETON.Get(AUDIO_PATH);
if (source != null && audioClip != null) { if (source != null && audioClip != null) {
source.clip = audioClip; source.clip = audioClip;
......
using System.Collections; using System.Collections;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
...@@ -74,7 +75,7 @@ namespace BigSock { ...@@ -74,7 +75,7 @@ namespace BigSock {
bulletScript.Direction = (target.Value - (Vector2) actor.transform.position).normalized; bulletScript.Direction = (target.Value - (Vector2) actor.transform.position).normalized;
// Play sound effect // Play sound effect
var source = actor.source; var source = actor.source.FirstOrDefault();
var audioClip = AudioService.SINGLETON.Get(AUDIO_PATH); var audioClip = AudioService.SINGLETON.Get(AUDIO_PATH);
if (source != null && audioClip != null) { if (source != null && audioClip != null) {
source.clip = audioClip; source.clip = audioClip;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment