fixed Rocket
This commit is contained in:
parent
0503421766
commit
020dbc4be6
@ -13,7 +13,7 @@ MonoBehaviour:
|
||||
m_Name: GlobalSerializationConfig
|
||||
m_EditorClassIdentifier:
|
||||
HideSerializationCautionaryMessage: 1
|
||||
HidePrefabCautionaryMessage: 0
|
||||
HidePrefabCautionaryMessage: 1
|
||||
HideOdinSerializeAttributeWarningMessages: 0
|
||||
HideNonSerializedShowInInspectorWarningMessages: 0
|
||||
buildSerializationFormat: 0
|
||||
|
@ -25,8 +25,8 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 662838864788327244}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalRotation: {x: 0, y: 0.9985128, z: 0, w: 0.054518197}
|
||||
m_LocalPosition: {x: 20.317627, y: 0, z: 57.78}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 8618016098659616984}
|
||||
@ -136,8 +136,8 @@ MonoBehaviour:
|
||||
Entry: 8
|
||||
Data:
|
||||
_unit: {fileID: 0}
|
||||
_color: 0
|
||||
speed: 0.1
|
||||
_color: 3
|
||||
speed: 0.3
|
||||
--- !u!136 &7385595456525671967
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -280,7 +280,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7418914791400950115, guid: 13431d38aaa99b8409a3e1ef301152d7, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 13431d38aaa99b8409a3e1ef301152d7, type: 3}
|
||||
|
@ -130526,7 +130526,7 @@ MonoBehaviour:
|
||||
attackText: {fileID: 1033038899}
|
||||
reloadText: {fileID: 985521934}
|
||||
chosenWeaponDataPath: ChosenWeapon.json
|
||||
_data: {fileID: 0}
|
||||
_data: {fileID: 11400000, guid: 933ff56c36f8e2048ac179b755c821f7, type: 2}
|
||||
--- !u!1 &1550290323
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AI;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using HexFiled;
|
||||
using Sirenix.OdinInspector;
|
||||
@ -23,11 +24,22 @@ namespace Items.ItemViews
|
||||
{
|
||||
_unit = unit.Instance;
|
||||
_color = unit.Color;
|
||||
Rockets[_color].SetActive(true);
|
||||
GetNearestUnit();
|
||||
MoveToTarget();
|
||||
|
||||
}
|
||||
|
||||
private void MoveToTarget()
|
||||
{
|
||||
transform.DOKill();
|
||||
transform.LookAt(listUnits.First().transform);
|
||||
transform.DOMove(listUnits.First().transform.position,
|
||||
speed * Vector3.Distance(transform.position, listUnits.First().transform.position)).OnUpdate(
|
||||
MoveToTarget);
|
||||
}
|
||||
private void GetNearestUnit()
|
||||
{
|
||||
Rockets[_color].SetActive(true);
|
||||
listUnits = new List<GameObject>();
|
||||
listUnits.AddRange(HexManager.UnitCurrentCell.Where(x => x.Key != _color).ToList()
|
||||
.Select(x => x.Value.unit.Instance));
|
||||
@ -36,17 +48,6 @@ namespace Items.ItemViews
|
||||
Vector3.Distance(y.transform.position, _unit.transform.position)));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_unit != null)
|
||||
{
|
||||
GetNearestUnit();
|
||||
transform.DOKill();
|
||||
transform.LookAt(listUnits.First().transform);
|
||||
transform.DOMove(listUnits.First().transform.position,
|
||||
Vector3.Distance(listUnits.First().transform.position, _unit.transform.position) * speed)
|
||||
.SetEase(Ease.Linear);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -46,12 +46,12 @@ namespace Items
|
||||
|
||||
container.Unit.RotateUnit(container.Direction);
|
||||
_weapon.SetModifiedDamage(0);
|
||||
_weapon.objectToThrow.GetComponent<ISetUp>().SetUp(container.Unit);
|
||||
container.DeAim();
|
||||
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
{
|
||||
var ball = _weapon.Fire(container.Unit.Instance.transform, container.Direction, container.Unit);
|
||||
var ball = _weapon.Fire(container.Unit.Instance.transform, container.Direction, container.Unit, false);
|
||||
ball.GetComponent<ISetUp>().SetUp(container.Unit);
|
||||
if (isLifeByTime)
|
||||
{
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
|
@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Data;
|
||||
@ -8,25 +5,28 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using Weapons;
|
||||
|
||||
public class ChosenWeapon : MonoBehaviour
|
||||
namespace MainMenu
|
||||
{
|
||||
[SerializeField] private TMP_Text attackText;
|
||||
[SerializeField] private TMP_Text reloadText;
|
||||
[SerializeField] private string chosenWeaponDataPath;
|
||||
[SerializeField] private WeaponsData _data;
|
||||
|
||||
private Weapon Weapon =>
|
||||
_data.WeaponsList[int.Parse(File.ReadAllText(Application.persistentDataPath + "/" + chosenWeaponDataPath))];
|
||||
|
||||
private void Start()
|
||||
public class ChosenWeapon : MonoBehaviour
|
||||
{
|
||||
attackText.text = Weapon.damage.ToString();
|
||||
reloadText.text = Weapon.reloadTime.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
[SerializeField] private TMP_Text attackText;
|
||||
[SerializeField] private TMP_Text reloadText;
|
||||
[SerializeField] private string chosenWeaponDataPath;
|
||||
[SerializeField] private WeaponsData _data;
|
||||
|
||||
public void ChangeChosenWeapon(Weapon weapon)
|
||||
{
|
||||
attackText.text = weapon.damage.ToString();
|
||||
reloadText.text = weapon.reloadTime.ToString(CultureInfo.CurrentCulture);
|
||||
private Weapon Weapon =>
|
||||
_data.WeaponsList[int.Parse(File.ReadAllText(Application.persistentDataPath + "/" + chosenWeaponDataPath))];
|
||||
|
||||
private void Start()
|
||||
{
|
||||
attackText.text = Weapon.damage.ToString();
|
||||
reloadText.text = Weapon.reloadTime.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
public void ChangeChosenWeapon(Weapon weapon)
|
||||
{
|
||||
attackText.text = weapon.damage.ToString();
|
||||
reloadText.text = weapon.reloadTime.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FadeIn : MonoBehaviour
|
||||
namespace MainMenu
|
||||
{
|
||||
[SerializeField] private float duration;
|
||||
|
||||
|
||||
private void Start()
|
||||
public class FadeIn : MonoBehaviour
|
||||
{
|
||||
var back = GetComponent<Image>();
|
||||
back.DOFade(0, duration).OnComplete(() => gameObject.SetActive(false));
|
||||
[SerializeField] private float duration;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var back = GetComponent<Image>();
|
||||
back.DOFade(0, duration).OnComplete(() => gameObject.SetActive(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HighLightButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject highLighter;
|
||||
[SerializeField] private List<Button> _buttons;
|
||||
|
||||
[SerializeField] private float _duration;
|
||||
[SerializeField] private Ease _ease;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
List<Transform> buttonTransforms = new List<Transform>();
|
||||
foreach (var button in _buttons)
|
||||
{
|
||||
buttonTransforms.Add(button.transform);
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
buttonTransforms.ForEach(x => { _buttons[i++].onClick.AddListener(() => Highlight(x)); });
|
||||
i = 0;
|
||||
}
|
||||
|
||||
private void Highlight(Transform buttonTransform)
|
||||
{
|
||||
highLighter.transform
|
||||
.DOMove(new Vector3(buttonTransform.position.x, highLighter.transform.position.y, 0), _duration)
|
||||
.SetEase(_ease);
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d617def8d366147408d8fa6b815a1135
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,18 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Scene = UnityEngine.SceneManagement.Scene;
|
||||
[CreateAssetMenu(fileName = "LevelData", menuName = "Data/LevelData", order = 0)]
|
||||
public class LevelData : ScriptableObject
|
||||
|
||||
namespace MainMenu
|
||||
{
|
||||
[Serializable]
|
||||
public struct Level
|
||||
[CreateAssetMenu(fileName = "LevelData", menuName = "Data/LevelData", order = 0)]
|
||||
public class LevelData : ScriptableObject
|
||||
{
|
||||
public string sceneName;
|
||||
public Sprite levelSprite;
|
||||
[Serializable]
|
||||
public struct Level
|
||||
{
|
||||
public string sceneName;
|
||||
public Sprite levelSprite;
|
||||
}
|
||||
|
||||
[SerializeField] private List<Level> levels;
|
||||
|
||||
public List<Level> Levels => levels;
|
||||
}
|
||||
|
||||
[SerializeField] private List<Level> levels;
|
||||
|
||||
public List<Level> Levels => levels;
|
||||
}
|
||||
|
@ -1,33 +1,41 @@
|
||||
using System.IO;
|
||||
using DefaultNamespace;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using AudioSettings = MainMenu.AudioSettings;
|
||||
|
||||
public class SettingsController : MonoBehaviour
|
||||
namespace MainMenu
|
||||
{
|
||||
[SerializeField] private AudioSource menuMusSrc;
|
||||
[SerializeField] private string dataFilePath;
|
||||
[SerializeField] private Slider musicSlider;
|
||||
[SerializeField] private Slider sfxSlider;
|
||||
[SerializeField] private Image musicImage;
|
||||
[SerializeField] private Sprite musicOnSprite;
|
||||
[SerializeField] private Sprite musicOffSprite;
|
||||
|
||||
[SerializeField] private Image sfxImage;
|
||||
[SerializeField] private Sprite sfxOnSprite;
|
||||
[SerializeField] private Sprite sfxOffSprite;
|
||||
|
||||
private AudioSettings _audioSettings;
|
||||
|
||||
private void Start()
|
||||
public class SettingsController : MonoBehaviour
|
||||
{
|
||||
dataFilePath = Application.persistentDataPath + "/" + dataFilePath;
|
||||
if (File.Exists(dataFilePath))
|
||||
[SerializeField] private AudioSource menuMusSrc;
|
||||
[SerializeField] private string dataFilePath;
|
||||
[SerializeField] private Slider musicSlider;
|
||||
[SerializeField] private Slider sfxSlider;
|
||||
[SerializeField] private Image musicImage;
|
||||
[SerializeField] private Sprite musicOnSprite;
|
||||
[SerializeField] private Sprite musicOffSprite;
|
||||
|
||||
[SerializeField] private Image sfxImage;
|
||||
[SerializeField] private Sprite sfxOnSprite;
|
||||
[SerializeField] private Sprite sfxOffSprite;
|
||||
|
||||
private AudioSettings _audioSettings;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_audioSettings = JsonUtility.FromJson<AudioSettings>(File.ReadAllText(dataFilePath));
|
||||
if (_audioSettings == null)
|
||||
dataFilePath = Application.persistentDataPath + "/" + dataFilePath;
|
||||
if (File.Exists(dataFilePath))
|
||||
{
|
||||
_audioSettings = JsonUtility.FromJson<AudioSettings>(File.ReadAllText(dataFilePath));
|
||||
if (_audioSettings == null)
|
||||
{
|
||||
_audioSettings = new AudioSettings(1f, 1f);
|
||||
FileStream stream = new FileStream(dataFilePath, FileMode.Create);
|
||||
using StreamWriter writer = new StreamWriter(stream);
|
||||
writer.Write(JsonUtility.ToJson(_audioSettings));
|
||||
writer.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_audioSettings = new AudioSettings(1f, 1f);
|
||||
FileStream stream = new FileStream(dataFilePath, FileMode.Create);
|
||||
@ -35,51 +43,43 @@ public class SettingsController : MonoBehaviour
|
||||
writer.Write(JsonUtility.ToJson(_audioSettings));
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
musicSlider.value = _audioSettings.musicVolume;
|
||||
sfxSlider.value = _audioSettings.sfxVolume;
|
||||
|
||||
musicSlider.onValueChanged.AddListener(x => OnMusicSliderValueChanged());
|
||||
sfxSlider.onValueChanged.AddListener(x => OnSFXSliderValueChanged());
|
||||
|
||||
UpdateVisuals();
|
||||
SetMenuMusicState();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
|
||||
private void UpdateVisuals()
|
||||
{
|
||||
_audioSettings = new AudioSettings(1f, 1f);
|
||||
FileStream stream = new FileStream(dataFilePath, FileMode.Create);
|
||||
using StreamWriter writer = new StreamWriter(stream);
|
||||
writer.Write(JsonUtility.ToJson(_audioSettings));
|
||||
writer.Close();
|
||||
musicImage.sprite = _audioSettings.musicVolume == 0f ? musicOffSprite : musicOnSprite;
|
||||
|
||||
sfxImage.sprite = _audioSettings.sfxVolume == 0f ? sfxOffSprite : sfxOnSprite;
|
||||
}
|
||||
|
||||
musicSlider.value = _audioSettings.musicVolume;
|
||||
sfxSlider.value = _audioSettings.sfxVolume;
|
||||
private void OnMusicSliderValueChanged()
|
||||
{
|
||||
_audioSettings.musicVolume = musicSlider.value;
|
||||
SetMenuMusicState();
|
||||
File.WriteAllText(dataFilePath, JsonUtility.ToJson(_audioSettings));
|
||||
UpdateVisuals();
|
||||
}
|
||||
|
||||
musicSlider.onValueChanged.AddListener(x => OnMusicSliderValueChanged());
|
||||
sfxSlider.onValueChanged.AddListener(x => OnSFXSliderValueChanged());
|
||||
private void OnSFXSliderValueChanged()
|
||||
{
|
||||
_audioSettings.sfxVolume = sfxSlider.value;
|
||||
File.WriteAllText(dataFilePath, JsonUtility.ToJson(_audioSettings));
|
||||
UpdateVisuals();
|
||||
}
|
||||
|
||||
UpdateVisuals();
|
||||
SetMenuMusicState();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void UpdateVisuals()
|
||||
{
|
||||
musicImage.sprite = _audioSettings.musicVolume == 0f ? musicOffSprite : musicOnSprite;
|
||||
|
||||
sfxImage.sprite = _audioSettings.sfxVolume == 0f ? sfxOffSprite : sfxOnSprite;
|
||||
}
|
||||
|
||||
private void OnMusicSliderValueChanged()
|
||||
{
|
||||
_audioSettings.musicVolume = musicSlider.value;
|
||||
SetMenuMusicState();
|
||||
File.WriteAllText(dataFilePath, JsonUtility.ToJson(_audioSettings));
|
||||
UpdateVisuals();
|
||||
}
|
||||
|
||||
private void OnSFXSliderValueChanged()
|
||||
{
|
||||
_audioSettings.sfxVolume = sfxSlider.value;
|
||||
File.WriteAllText(dataFilePath, JsonUtility.ToJson(_audioSettings));
|
||||
UpdateVisuals();
|
||||
}
|
||||
|
||||
private void SetMenuMusicState()
|
||||
{
|
||||
menuMusSrc.volume = musicSlider.value;
|
||||
private void SetMenuMusicState()
|
||||
{
|
||||
menuMusSrc.volume = musicSlider.value;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +1,51 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using DanielLochner.Assets.SimpleScrollSnap;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
public class ToolBarController : MonoBehaviour
|
||||
namespace MainMenu
|
||||
{
|
||||
[SerializeField] private List<Button> buttons;
|
||||
[SerializeField] private SimpleScrollSnap _scrollSnap;
|
||||
[SerializeField] private bool hasHightlighter;
|
||||
|
||||
[SerializeField, ShowIf("hasHightlighter")]
|
||||
private GameObject highLighter;
|
||||
|
||||
[SerializeField, ShowIf("highLighter")] private Ease ease;
|
||||
[SerializeField, ShowIf("highLighter")] private float duration;
|
||||
|
||||
private void Start()
|
||||
public class ToolBarController : MonoBehaviour
|
||||
{
|
||||
for (var i = 0; i < buttons.Count; i++)
|
||||
[SerializeField] private List<Button> buttons;
|
||||
[SerializeField] private SimpleScrollSnap _scrollSnap;
|
||||
[SerializeField] private bool hasHightlighter;
|
||||
|
||||
[SerializeField, ShowIf("hasHightlighter")]
|
||||
private GameObject highLighter;
|
||||
|
||||
[SerializeField, ShowIf("highLighter")] private Ease ease;
|
||||
[SerializeField, ShowIf("highLighter")] private float duration;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var i1 = i;
|
||||
buttons[i].onClick.AddListener(() =>
|
||||
for (var i = 0; i < buttons.Count; i++)
|
||||
{
|
||||
_scrollSnap.GoToPanel(i1);
|
||||
buttons[i1].Select();
|
||||
if (hasHightlighter)
|
||||
var i1 = i;
|
||||
buttons[i].onClick.AddListener(() =>
|
||||
{
|
||||
Highlight(buttons[i1].transform);
|
||||
_scrollSnap.onPanelChanged.AddListener(() =>
|
||||
_scrollSnap.GoToPanel(i1);
|
||||
buttons[i1].Select();
|
||||
if (hasHightlighter)
|
||||
{
|
||||
Highlight(buttons[_scrollSnap.CurrentPanel].transform);
|
||||
buttons[_scrollSnap.CurrentPanel].Select();
|
||||
});
|
||||
}
|
||||
});
|
||||
Highlight(buttons[i1].transform);
|
||||
_scrollSnap.onPanelChanged.AddListener(() =>
|
||||
{
|
||||
Highlight(buttons[_scrollSnap.CurrentPanel].transform);
|
||||
buttons[_scrollSnap.CurrentPanel].Select();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void Highlight(Transform buttonTransform)
|
||||
{
|
||||
highLighter.transform
|
||||
.DOMove(new Vector3(buttonTransform.position.x, highLighter.transform.position.y, 0), duration)
|
||||
.SetEase(ease);
|
||||
}
|
||||
}
|
||||
|
||||
private void Highlight(Transform buttonTransform)
|
||||
{
|
||||
highLighter.transform
|
||||
.DOMove(new Vector3(buttonTransform.position.x, highLighter.transform.position.y, 0), duration)
|
||||
.SetEase(ease);
|
||||
}
|
||||
}
|
@ -1,24 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class WeaponIcon : MonoBehaviour
|
||||
namespace MainMenu
|
||||
{
|
||||
[SerializeField] private Button button;
|
||||
[SerializeField] private TMP_Text damageText;
|
||||
[SerializeField] private TMP_Text shotsCount;
|
||||
[SerializeField] private TMP_Text reloadText;
|
||||
[SerializeField] private TMP_Text weaponTitle;
|
||||
[SerializeField] private GameObject icon;
|
||||
public class WeaponIcon : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button button;
|
||||
[SerializeField] private TMP_Text damageText;
|
||||
[SerializeField] private TMP_Text shotsCount;
|
||||
[SerializeField] private TMP_Text reloadText;
|
||||
[SerializeField] private TMP_Text weaponTitle;
|
||||
[SerializeField] private GameObject icon;
|
||||
|
||||
public TMP_Text DamageText => damageText;
|
||||
public TMP_Text DamageText => damageText;
|
||||
|
||||
public TMP_Text ReloadText => reloadText;
|
||||
public TMP_Text ReloadText => reloadText;
|
||||
|
||||
public Button Button => button;
|
||||
public TMP_Text ShotsCount => shotsCount;
|
||||
public TMP_Text WeaponTitle => weaponTitle;
|
||||
public GameObject Icon => icon;
|
||||
public Button Button => button;
|
||||
public TMP_Text ShotsCount => shotsCount;
|
||||
public TMP_Text WeaponTitle => weaponTitle;
|
||||
public GameObject Icon => icon;
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Weapons;
|
||||
|
||||
public class WeaponSelection : MonoBehaviour
|
||||
namespace MainMenu
|
||||
{
|
||||
[SerializeField] private WeaponsData data;
|
||||
[SerializeField] private WeaponIcon weaponIcon;
|
||||
[SerializeField] private Transform grid;
|
||||
[SerializeField] private string dataFilePath;
|
||||
|
||||
private List<Button> _buttons;
|
||||
|
||||
private void Awake()
|
||||
public class WeaponSelection : MonoBehaviour
|
||||
{
|
||||
var dataPah = Application.persistentDataPath + "/" + dataFilePath;
|
||||
if (!File.Exists(dataPah))
|
||||
[SerializeField] private WeaponsData data;
|
||||
[SerializeField] private WeaponIcon weaponIcon;
|
||||
[SerializeField] private Transform grid;
|
||||
[SerializeField] private string dataFilePath;
|
||||
|
||||
private List<Button> _buttons;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
FileStream stream = new FileStream(dataPah, FileMode.Create);
|
||||
var dataPah = Application.persistentDataPath + "/" + dataFilePath;
|
||||
if (!File.Exists(dataPah))
|
||||
{
|
||||
FileStream stream = new FileStream(dataPah, FileMode.Create);
|
||||
using StreamWriter writer = new StreamWriter(stream);
|
||||
writer.Write("0");
|
||||
}
|
||||
|
||||
|
||||
_buttons = new List<Button>();
|
||||
|
||||
for (var i = 0; i < data.WeaponsList.Count - 1; i++)
|
||||
{
|
||||
var go = Instantiate(weaponIcon, grid);
|
||||
var icon = Instantiate(data.WeaponsList[i].icon, go.Icon.transform);
|
||||
icon.transform.localPosition = Vector3.zero;
|
||||
go.DamageText.text = data.WeaponsList[i].damage.ToString();
|
||||
go.ReloadText.text = data.WeaponsList[i].reloadTime.ToString();
|
||||
go.ShotsCount.text = data.WeaponsList[i].shots.ToString();
|
||||
go.WeaponTitle.text = data.WeaponsList[i].name;
|
||||
go.Button.onClick.AddListener(() => ChoseWeapon(i));
|
||||
_buttons.Add(go.Button);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ChoseWeapon(int i)
|
||||
{
|
||||
FileStream stream = new FileStream(Application.persistentDataPath + "/" + dataFilePath, FileMode.Create);
|
||||
using StreamWriter writer = new StreamWriter(stream);
|
||||
writer.Write("0");
|
||||
writer.Write($"{i}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
_buttons = new List<Button>();
|
||||
|
||||
for (var i = 0; i < data.WeaponsList.Count - 1; i++)
|
||||
{
|
||||
var go = Instantiate(weaponIcon, grid);
|
||||
var icon = Instantiate(data.WeaponsList[i].icon, go.Icon.transform);
|
||||
icon.transform.localPosition = Vector3.zero;
|
||||
go.DamageText.text = data.WeaponsList[i].damage.ToString();
|
||||
go.ReloadText.text = data.WeaponsList[i].reloadTime.ToString();
|
||||
go.ShotsCount.text = data.WeaponsList[i].shots.ToString();
|
||||
go.WeaponTitle.text = data.WeaponsList[i].name;
|
||||
go.Button.onClick.AddListener(() => ChoseWeapon(i));
|
||||
_buttons.Add(go.Button);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ChoseWeapon(int i)
|
||||
{
|
||||
FileStream stream = new FileStream(Application.persistentDataPath + "/" + dataFilePath, FileMode.Create);
|
||||
using StreamWriter writer = new StreamWriter(stream);
|
||||
writer.Write($"{i}");
|
||||
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ namespace Weapons
|
||||
modifiedDamage = damage + bonus;
|
||||
}
|
||||
|
||||
public GameObject Fire(Transform start, Vector2 direction, Unit unit)
|
||||
public GameObject Fire(Transform start, Vector2 direction, Unit unit, bool isMoving = true)
|
||||
{
|
||||
var ball = Object.Instantiate(objectToThrow,
|
||||
start.forward + start.transform.position + new Vector3(0, 1),
|
||||
@ -40,26 +40,30 @@ namespace Weapons
|
||||
MusicController.Instance.PlayAudioClip(shotSound, ball);
|
||||
ball.AddComponent<WeaponView>().SetWeapon(this, unit);
|
||||
Weapon tmpThis = this;
|
||||
GameObject localBall = ball;
|
||||
Weapon tmpThis1 = this;
|
||||
localBall.transform.DOMove(new Vector3(direction.normalized.x,
|
||||
0, direction.normalized.y) * tmpThis.disnatce * HexGrid.HexDistance +
|
||||
start.position + new Vector3(0, 1, 0), tmpThis.speed)
|
||||
.SetEase(Ease.Linear)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
if(ball == null)
|
||||
return;
|
||||
var vfx = VFXController.Instance.PlayEffect(tmpThis1.VFXGameObject, ball.transform.position, Quaternion.identity);
|
||||
if (vfx != null)
|
||||
{
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
MusicController.Instance.PlayAudioClip(tmpThis1.hitSound, vfx);
|
||||
}
|
||||
|
||||
ball.transform.DOKill();
|
||||
Object.Destroy(ball);
|
||||
});
|
||||
Weapon tmpThis1 = this;
|
||||
if (isMoving)
|
||||
{
|
||||
ball.transform.DOMove(new Vector3(direction.normalized.x,
|
||||
0, direction.normalized.y) * tmpThis.disnatce * HexGrid.HexDistance +
|
||||
start.position + new Vector3(0, 1, 0), tmpThis.speed)
|
||||
.SetEase(Ease.Linear)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
if(ball == null)
|
||||
return;
|
||||
var vfx = VFXController.Instance.PlayEffect(tmpThis1.VFXGameObject, ball.transform.position, Quaternion.identity);
|
||||
if (vfx != null)
|
||||
{
|
||||
MusicController.Instance.AddAudioSource(vfx);
|
||||
MusicController.Instance.PlayAudioClip(tmpThis1.hitSound, vfx);
|
||||
}
|
||||
|
||||
ball.transform.DOKill();
|
||||
Object.Destroy(ball);
|
||||
});
|
||||
}
|
||||
|
||||
return ball;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user