weapon fixes
This commit is contained in:
parent
6ccb4723cb
commit
95f941abb8
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "1.0",
|
|
||||||
"components": [
|
|
||||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
|
||||||
]
|
|
||||||
}
|
|
@ -95,19 +95,19 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 5db196e1099b97246bde07a348189567, type: 3}
|
m_Script: {fileID: 11500000, guid: 5db196e1099b97246bde07a348189567, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_weapon:
|
weapon:
|
||||||
name: Tower
|
name: Tower
|
||||||
icon: {fileID: 4774919592469818776}
|
icon: {fileID: 0}
|
||||||
objectToThrow: {fileID: 4746165193704193263, guid: 4e7523811a052fd46acf941fc69c8c98,
|
objectToThrow: {fileID: 4746165193704193263, guid: 4e7523811a052fd46acf941fc69c8c98,
|
||||||
type: 3}
|
type: 3}
|
||||||
VFXGameObject: {fileID: 2957420090356197408, guid: 5d1244f7b80cadd428a70173a01ce889,
|
VFXGameObject: {fileID: 2957420090356197408, guid: 5d1244f7b80cadd428a70173a01ce889,
|
||||||
type: 3}
|
type: 3}
|
||||||
manaCost: 0
|
modifiedDamage: 0
|
||||||
damage: 10
|
damage: 15
|
||||||
speed: 10
|
speed: 10
|
||||||
disnatce: 10
|
disnatce: 6
|
||||||
reloadTime: 3
|
reloadTime: 6
|
||||||
shots: 3
|
shots: 4
|
||||||
shotSound: {fileID: 8300000, guid: 9ea918c6c23577f4e885a8490d2f2046, type: 3}
|
shotSound: {fileID: 8300000, guid: 9ea918c6c23577f4e885a8490d2f2046, type: 3}
|
||||||
hitSound: {fileID: 8300000, guid: 6c42231c18643dc4d9d8f8d15bc4735b, type: 3}
|
hitSound: {fileID: 8300000, guid: 6c42231c18643dc4d9d8f8d15bc4735b, type: 3}
|
||||||
--- !u!136 &5879628246065515362
|
--- !u!136 &5879628246065515362
|
||||||
|
@ -20,19 +20,22 @@ MonoBehaviour:
|
|||||||
spawnablePrefab: {fileID: 4774919592469818776, guid: 0dbed8f974ba44a42af9d8fcae504ce0,
|
spawnablePrefab: {fileID: 4774919592469818776, guid: 0dbed8f974ba44a42af9d8fcae504ce0,
|
||||||
type: 3}
|
type: 3}
|
||||||
values:
|
values:
|
||||||
|
spawnChance: 0.23
|
||||||
- prefab: {fileID: 3197816592181874056, guid: 2704c4f795b0d7748a3e3fa53be4d893,
|
- prefab: {fileID: 3197816592181874056, guid: 2704c4f795b0d7748a3e3fa53be4d893,
|
||||||
type: 3}
|
type: 3}
|
||||||
isInstantUse: 1
|
isInstantUse: 1
|
||||||
type: AttackBonus
|
type: AttackBonus
|
||||||
icon: {fileID: 21300000, guid: caf8bc0311dd2fc4ca1528a82a063754, type: 3}
|
icon: {fileID: 21300000, guid: caf8bc0311dd2fc4ca1528a82a063754, type: 3}
|
||||||
spawnablePrefab: {fileID: 0}
|
spawnablePrefab: {fileID: 0}
|
||||||
values: 030000000f000000
|
values: 0500000064000000
|
||||||
|
spawnChance: 0.62
|
||||||
- prefab: {fileID: 8639522512577941448, guid: 7b6a7f64e52da514d88aa97ad8f863df,
|
- prefab: {fileID: 8639522512577941448, guid: 7b6a7f64e52da514d88aa97ad8f863df,
|
||||||
type: 3}
|
type: 3}
|
||||||
isInstantUse: 1
|
isInstantUse: 1
|
||||||
type: DefenceBonus
|
type: DefenceBonus
|
||||||
icon: {fileID: 21300000, guid: 35be128594dcdce48b5d8e5317b38ed9, type: 3}
|
icon: {fileID: 21300000, guid: 35be128594dcdce48b5d8e5317b38ed9, type: 3}
|
||||||
spawnablePrefab: {fileID: 0}
|
spawnablePrefab: {fileID: 0}
|
||||||
values: 0a0000001e000000
|
values: 1e0000001e000000
|
||||||
|
spawnChance: 0.77
|
||||||
fromTimeSpawn: 3
|
fromTimeSpawn: 3
|
||||||
toTimeSpawn: 10
|
toTimeSpawn: 10
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Chars;
|
using Chars;
|
||||||
|
using GameUI;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Data
|
namespace Data
|
||||||
|
@ -1,68 +1,90 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Items;
|
using Items;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class PlayerInventoryView : MonoBehaviour
|
namespace GameUI
|
||||||
{
|
{
|
||||||
[SerializeField] private GameObject item;
|
public class PlayerInventoryView : MonoBehaviour
|
||||||
[SerializeField] private GameObject grid;
|
|
||||||
|
|
||||||
public Action<Item> OnItemInvoked;
|
|
||||||
|
|
||||||
private List<Button> _buttons;
|
|
||||||
private Queue<Button> _freeButtons;
|
|
||||||
private Dictionary<Item, Button> _dictionary;
|
|
||||||
|
|
||||||
|
|
||||||
public void SetUpUI(int inventoryCapacity)
|
|
||||||
{
|
{
|
||||||
_buttons = new List<Button>();
|
[SerializeField] private GameObject item;
|
||||||
_dictionary = new Dictionary<Item, Button>();
|
[SerializeField] private GameObject grid;
|
||||||
_freeButtons = new Queue<Button>();
|
|
||||||
for (int i = 0; i < inventoryCapacity; i++)
|
public Action<Item> OnItemInvoked;
|
||||||
|
|
||||||
|
private List<Button> _buttons;
|
||||||
|
private Button[] _freeButtons;
|
||||||
|
private Dictionary<Item, Button> _dictionary;
|
||||||
|
|
||||||
|
|
||||||
|
public void SetUpUI(int inventoryCapacity)
|
||||||
{
|
{
|
||||||
var itemGo = Instantiate(item, grid.transform);
|
_buttons = new List<Button>();
|
||||||
var button = itemGo.GetComponentInChildren<Button>();
|
_dictionary = new Dictionary<Item, Button>();
|
||||||
_buttons.Add(button);
|
_freeButtons = new Button[inventoryCapacity];
|
||||||
button.gameObject.SetActive(false);
|
for (int i = 0; i < inventoryCapacity; i++)
|
||||||
}
|
|
||||||
|
|
||||||
_buttons.ForEach(button => _freeButtons.Enqueue(button));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SwitchButton(Item item)
|
|
||||||
{
|
|
||||||
var button = _dictionary[item];
|
|
||||||
_dictionary.Remove(item);
|
|
||||||
button.gameObject.SetActive(false);
|
|
||||||
_freeButtons.Enqueue(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PickUpItem(Item item)
|
|
||||||
{
|
|
||||||
var button = _freeButtons.Dequeue();
|
|
||||||
_dictionary.Add(item, button);
|
|
||||||
button.gameObject.SetActive(true);
|
|
||||||
button.image.sprite = item.Icon;
|
|
||||||
button.onClick.AddListener(() =>
|
|
||||||
{
|
|
||||||
if (item.IsInstantUse)
|
|
||||||
{
|
{
|
||||||
item.InstanceInvoke();
|
var itemGo = Instantiate(item, grid.transform);
|
||||||
_freeButtons.Enqueue(button);
|
var button = itemGo.GetComponentInChildren<Button>();
|
||||||
|
_buttons.Add(button);
|
||||||
button.gameObject.SetActive(false);
|
button.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
var j = 0;
|
||||||
|
_buttons.ForEach(button => _freeButtons[j++] = button);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SwitchButton(Item item)
|
||||||
|
{
|
||||||
|
var button = _dictionary[item];
|
||||||
|
_dictionary.Remove(item);
|
||||||
|
button.gameObject.SetActive(false);
|
||||||
|
for (int i = 0; i < _freeButtons.Length; i++)
|
||||||
{
|
{
|
||||||
item.Invoke(SwitchButton);
|
if (_freeButtons[i] != null) continue;
|
||||||
OnItemInvoked?.Invoke(item);
|
_freeButtons[i] = button;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PickUpItem(Item item)
|
||||||
|
{
|
||||||
|
Button button = null;
|
||||||
|
for (int i = 0; i < _freeButtons.Length; i++)
|
||||||
|
{
|
||||||
|
if (_freeButtons[i] == null) continue;
|
||||||
|
button = _freeButtons[i];
|
||||||
|
_freeButtons[i] = null;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
if (button == null)
|
||||||
|
return;
|
||||||
|
_dictionary.Add(item, button);
|
||||||
|
button.gameObject.SetActive(true);
|
||||||
|
button.image.sprite = item.Icon;
|
||||||
|
button.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
if (item.IsInstantUse)
|
||||||
|
{
|
||||||
|
button.onClick.RemoveAllListeners();
|
||||||
|
item.InstanceInvoke();
|
||||||
|
for (int i = 0; i < _freeButtons.Length; i++)
|
||||||
|
{
|
||||||
|
if (_freeButtons[i] != null) continue;
|
||||||
|
_freeButtons[i] = button;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.Invoke(SwitchButton);
|
||||||
|
OnItemInvoked?.Invoke(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ namespace Items
|
|||||||
public override void InstanceInvoke()
|
public override void InstanceInvoke()
|
||||||
{
|
{
|
||||||
Unit.SetAttackBonus(Data.Values[0], Data.Values[1]);
|
Unit.SetAttackBonus(Data.Values[0], Data.Values[1]);
|
||||||
|
Unit.UseItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PlaceItem(HexCell cell)
|
public override void PlaceItem(HexCell cell)
|
||||||
|
@ -18,6 +18,7 @@ namespace Items
|
|||||||
public override void InstanceInvoke()
|
public override void InstanceInvoke()
|
||||||
{
|
{
|
||||||
Unit.SetDefenceBonus(Data.Values[0], Data.Values[1]);
|
Unit.SetDefenceBonus(Data.Values[0], Data.Values[1]);
|
||||||
|
Unit.UseItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PlaceItem(HexCell cell)
|
public override void PlaceItem(HexCell cell)
|
||||||
|
@ -3,6 +3,7 @@ using Controller;
|
|||||||
using Data;
|
using Data;
|
||||||
using DefaultNamespace;
|
using DefaultNamespace;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using GameUI;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
using Items;
|
using Items;
|
||||||
using Runtime.Controller;
|
using Runtime.Controller;
|
||||||
|
@ -24,8 +24,9 @@ public class TowerView : MonoBehaviour
|
|||||||
private void OnCollisionEnter(Collision collision)
|
private void OnCollisionEnter(Collision collision)
|
||||||
{
|
{
|
||||||
var unit = collision.gameObject.GetComponent<UnitView>();
|
var unit = collision.gameObject.GetComponent<UnitView>();
|
||||||
if (unit != null && unit.Color != _color)
|
if (unit != null && unit.Color != _color) //TODO какие-то проблемы с задием цвета
|
||||||
{
|
{
|
||||||
|
weapon.SetModifiedDamage(0);
|
||||||
_target = unit.gameObject;
|
_target = unit.gameObject;
|
||||||
StartCoroutine(Shot());
|
StartCoroutine(Shot());
|
||||||
}
|
}
|
||||||
@ -48,7 +49,7 @@ public class TowerView : MonoBehaviour
|
|||||||
var direction = DirectionHelper.DirectionTo(transform.position, _target.transform.position);
|
var direction = DirectionHelper.DirectionTo(transform.position, _target.transform.position);
|
||||||
var ball = Instantiate(weapon.objectToThrow,
|
var ball = Instantiate(weapon.objectToThrow,
|
||||||
transform.forward + transform.position + new Vector3(0, 2),
|
transform.forward + transform.position + new Vector3(0, 2),
|
||||||
Quaternion.FromToRotation(transform.position, _target.transform.position));
|
Quaternion.LookRotation(direction));
|
||||||
|
|
||||||
MusicController.Instance.AddAudioSource(ball);
|
MusicController.Instance.AddAudioSource(ball);
|
||||||
MusicController.Instance.PlayAudioClip(weapon.shotSound, ball);
|
MusicController.Instance.PlayAudioClip(weapon.shotSound, ball);
|
||||||
|
@ -1 +0,0 @@
|
|||||||
{"icon":{"instanceID":17620},"objectToThrow":{"instanceID":17622},"VFXGameObject":{"instanceID":17624},"manaCost":15,"damage":30,"speed":0.5,"disnatce":3,"reloadTime":3.0,"shots":5,"shotSound":{"instanceID":17616},"hitSound":{"instanceID":17618}}
|
|
@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.2d.sprite": "1.0.0",
|
|
||||||
"com.unity.collab-proxy": "1.7.1",
|
"com.unity.collab-proxy": "1.7.1",
|
||||||
"com.unity.ide.rider": "2.0.7",
|
"com.unity.ide.rider": "2.0.7",
|
||||||
"com.unity.ide.visualstudio": "2.0.11",
|
"com.unity.ide.visualstudio": "2.0.11",
|
||||||
"com.unity.ide.vscode": "1.2.3",
|
"com.unity.ide.vscode": "1.2.3",
|
||||||
"com.unity.postprocessing": "3.1.1",
|
|
||||||
"com.unity.recorder": "2.5.5",
|
|
||||||
"com.unity.test-framework": "1.1.27",
|
"com.unity.test-framework": "1.1.27",
|
||||||
"com.unity.textmeshpro": "3.0.6",
|
"com.unity.textmeshpro": "3.0.6",
|
||||||
"com.unity.timeline": "1.4.8",
|
"com.unity.timeline": "1.4.8",
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.2d.sprite": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "builtin",
|
|
||||||
"dependencies": {}
|
|
||||||
},
|
|
||||||
"com.unity.collab-proxy": {
|
"com.unity.collab-proxy": {
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
@ -54,24 +48,6 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.postprocessing": {
|
|
||||||
"version": "3.1.1",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "registry",
|
|
||||||
"dependencies": {
|
|
||||||
"com.unity.modules.physics": "1.0.0"
|
|
||||||
},
|
|
||||||
"url": "https://packages.unity.com"
|
|
||||||
},
|
|
||||||
"com.unity.recorder": {
|
|
||||||
"version": "2.5.5",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "registry",
|
|
||||||
"dependencies": {
|
|
||||||
"com.unity.timeline": "1.0.0"
|
|
||||||
},
|
|
||||||
"url": "https://packages.unity.com"
|
|
||||||
},
|
|
||||||
"com.unity.test-framework": {
|
"com.unity.test-framework": {
|
||||||
"version": "1.1.27",
|
"version": "1.1.27",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
Точка входа — GameController.cs. Чтобы проект запустился надо создать на сцене пустой объект и добавить туда GameController, и указать ему путь до ScriptableObject Data (по умолчанию — Assets/Resources/Data)
|
|
||||||
|
|
||||||
В GameInit – Инициализация основных классов и добавление контроллеров, которые выполняются в цикле в GameController
|
|
||||||
|
|
||||||
Информация для объектов берётся из ScriptableObject, названия к которым прописываются в ScriptableObject Data по пути Assets/Resources/Data.
|
|
||||||
|
|
||||||
Чтобы выполнить метод в Start, Update и тд надо реализовать соответствующий интерфейс (IInitialization, IExecute и тд)
|
|
Loading…
x
Reference in New Issue
Block a user