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