From b197f6d8b2dd2b97aded3b32f31b33ccae29d479 Mon Sep 17 00:00:00 2001 From: DyatelO Date: Sat, 8 Jan 2022 15:50:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9B=D1=91=D0=B3=D0=BA=D0=B8=D0=B5=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Prefab/ADs.prefab | 16 ++-------- .../1/Character/Prefab/Asvald.prefab | 29 ------------------- Assets/Scripts/ADs/AdsMob.cs | 20 +++++++++++-- Assets/Scripts/AI/AIAgent.cs | 2 +- Assets/Scripts/Controller/GameInit.cs | 16 ++-------- Assets/Scripts/Units/Unit.cs | 7 +++-- 6 files changed, 28 insertions(+), 62 deletions(-) diff --git a/Assets/Prefab/ADs.prefab b/Assets/Prefab/ADs.prefab index 79843e14..25e525a4 100644 --- a/Assets/Prefab/ADs.prefab +++ b/Assets/Prefab/ADs.prefab @@ -222,19 +222,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1368758087} m_OnClick: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 7017227080055577099} - m_TargetAssemblyTypeName: AdsMob, Assembly-CSharp - m_MethodName: ShowAd - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 + m_Calls: [] --- !u!1 &1900174882 GameObject: m_ObjectHideFlags: 0 @@ -886,3 +874,5 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a7c276b4af35fbc4a80539b97e444f32, type: 3} m_Name: m_EditorClassIdentifier: + button: {fileID: 1368758086} + canvas: {fileID: 855721721} diff --git a/Assets/Resources/1/Character/Prefab/Asvald.prefab b/Assets/Resources/1/Character/Prefab/Asvald.prefab index d1cf50c8..5a9bec6a 100644 --- a/Assets/Resources/1/Character/Prefab/Asvald.prefab +++ b/Assets/Resources/1/Character/Prefab/Asvald.prefab @@ -2937,7 +2937,6 @@ GameObject: - component: {fileID: 8989822822968797088} - component: {fileID: 8911891366586862002} - component: {fileID: 3288245434296440335} - - component: {fileID: 8454664948868524491} m_Layer: 0 m_Name: Asvald m_TagString: Untagged @@ -3013,7 +3012,6 @@ MonoBehaviour: m_EditorClassIdentifier: barCanvas: {fileID: 5591725933991455353} aimCanvas: {fileID: 2334695180834975480} - captureBar: {fileID: 3265669888403619595} --- !u!136 &8911891366586862002 CapsuleCollider: m_ObjectHideFlags: 0 @@ -3044,21 +3042,6 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 126 m_CollisionDetection: 0 ---- !u!114 &8454664948868524491 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7527582019267571087} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 2d2f89853800f934f8dce9a6635a97bd, type: 3} - m_Name: - m_EditorClassIdentifier: - canvasPref: {fileID: 2000339881314694206, guid: 5460da0df497ae94aace59d1caf7cbdb, - type: 3} - health: 1 --- !u!1 &7550162364350684268 GameObject: m_ObjectHideFlags: 0 @@ -3971,18 +3954,6 @@ RectTransform: type: 3} m_PrefabInstance: {fileID: 2192210941540280859} m_PrefabAsset: {fileID: 0} ---- !u!114 &3265669888403619595 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 3692302203462554896, guid: dec5dd0d644d5c548a53563e65837162, - type: 3} - m_PrefabInstance: {fileID: 2192210941540280859} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1001 &4606608419032177277 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/ADs/AdsMob.cs b/Assets/Scripts/ADs/AdsMob.cs index 40645cfa..c02decbc 100644 --- a/Assets/Scripts/ADs/AdsMob.cs +++ b/Assets/Scripts/ADs/AdsMob.cs @@ -6,12 +6,17 @@ using GoogleMobileAds.Api; using UnityEditor.PackageManager.Requests; using HexFiled; using Random = UnityEngine.Random; +using Units; +using UnityEngine.UI; public class AdsMob : MonoBehaviour { private string _revardUnitId = "ca-app-pub-3940256099942544/5224354917"; private RewardedAd _ad; private AdRequest _request; + private Unit _player; + [SerializeField] private Button button; + [SerializeField] private GameObject canvas; private void OnEnable() { @@ -19,6 +24,8 @@ public class AdsMob : MonoBehaviour _request = new AdRequest.Builder().Build(); _ad.LoadAd(_request); _ad.OnUserEarnedReward += HandleUser; + button.onClick.AddListener(() => ShowAd()) ; + canvas.SetActive(false); // } // private void Start() { @@ -35,22 +42,30 @@ public class AdsMob : MonoBehaviour ExtraLife life = FindObjectOfType(); life.health += 1; - Respawn(life.gameObject); + //Respawn(life.gameObject); + _player.Spawn(); } public void ShowAd() { + //_player = player; if (_ad.IsLoaded()) { _ad.Show(); } } + public void ShowCanvas(Unit player) + { + _player = player; + canvas.SetActive(true); + } + public void Respawn(GameObject player) { List cells = new List(); - //cells.AddRange(); + cells.AddRange(HexManager.CellByColor[UnitColor.GREY]); // for (int i = 0; i < cells.Count; i++) // { @@ -63,6 +78,7 @@ public class AdsMob : MonoBehaviour Vector3 respawnPosition = cells[randomCell].transform.position; //cells[randomCell].Color = UnitColor.YELLOW; player = FindObjectOfType().gameObject; + player.transform.position = respawnPosition; if(player.transform.position == respawnPosition) { diff --git a/Assets/Scripts/AI/AIAgent.cs b/Assets/Scripts/AI/AIAgent.cs index 18a47487..f942f12c 100644 --- a/Assets/Scripts/AI/AIAgent.cs +++ b/Assets/Scripts/AI/AIAgent.cs @@ -25,7 +25,7 @@ namespace DefaultNamespace.AI _enemy.OnDeath += AgentDeath; } - private void AgentDeath() + private void AgentDeath(Unit unit) { AIManager.Instance.RemoveAgent(this); } diff --git a/Assets/Scripts/Controller/GameInit.cs b/Assets/Scripts/Controller/GameInit.cs index 3a3f70cb..a8e3c8f2 100644 --- a/Assets/Scripts/Controller/GameInit.cs +++ b/Assets/Scripts/Controller/GameInit.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; using System.Timers; -using AI; using CamControl; using Chars; using DefaultNamespace; -using DefaultNamespace.AI; using GameUI; using HexFiled; using Items; @@ -22,9 +20,6 @@ namespace Controller public GameInit(Controllers controllers, Data.Data data) { - HexManager.agents = new Dictionary(); - AIManager aiManager = new AIManager(); - controllers.Add(aiManager); new GameObject("Timer").AddComponent(); var hexGrid = new HexGrid(data.FieldData); @@ -57,20 +52,16 @@ namespace Controller player.onPlayerSpawned += cameraControl.InitCameraControl; player.onPlayerSpawned += MusicController.Instance.AddAudioListener; units.Add(player); + + player.OnDeath += uiController.AdsMob.ShowCanvas; } else { var enemy = new Unit(unit, data.WeaponsData.WeaponsList[Random.Range(0, data.WeaponsData.WeaponsList.Count - 1)], hexGrid); var enemyController = new EnemyController(unit, enemy); - controllers.Add(enemyController); units.Add(enemy); - AIAgent agent = new AIAgent(unit, enemy); - - - aiManager.AddAgent(agent); - enemy.onPlayerSpawned += agent.InitAgent; } }); @@ -83,14 +74,11 @@ namespace Controller hexGrid.OnHexPainted += paintedController.SetHexColors; hexGrid.OnHexPainted += itemFabric.UpdateCellToOpenList; - hexGrid.OnHexPainted += paintedController.CheckDeath; } private List SetUpItems() { return new List() { typeof(Tower), typeof(AttackBonus), typeof(DefenceBonus) }; } - - } } \ No newline at end of file diff --git a/Assets/Scripts/Units/Unit.cs b/Assets/Scripts/Units/Unit.cs index a28236e1..c81e8a0b 100644 --- a/Assets/Scripts/Units/Unit.cs +++ b/Assets/Scripts/Units/Unit.cs @@ -38,13 +38,14 @@ namespace Units private int _defenceBonus; - public bool IsBusy => _isBusy; + public bool IsBusy { get => _isBusy; set => _isBusy = value; } public UnitView UnitView => _unitView; public bool IsAlive => _isAlive; public UnitColor Color => _data.color; public int InventoryCapacity => _data.inventoryCapacity; public Action OnItemPickUp; public Action OnDeath; + public BarCanvas BarCanvas => _barCanvas; public Unit(UnitInfo unitData, Weapon weapon, HexGrid hexGrid) { @@ -109,7 +110,7 @@ namespace Units _isCapturing = _data.color != _cell.GetNeighbor(direction).Color; var previousCell = _cell; _cell = _cell.GetNeighbor(direction); - PaintedController.UnitCurrentCell[_data.color] = (previousCell, _cell); + HexManager.UnitCurrentCell[_data.color] = ( _cell, this ); RotateUnit(new Vector2((_cell.transform.position - _instance.transform.position).normalized.x, (_cell.transform.position - _instance.transform.position).normalized.z)); _animator.SetTrigger("Move"); @@ -160,7 +161,7 @@ namespace Units } // - PaintedController.UnitCurrentCell.Add(_data.color, (null, _cell)); + HexManager.UnitCurrentCell.Add(_data.color, (_cell, this)); // _instance = Object.Instantiate(_data.unitPrefa, _cell.transform.parent);