Лёгкие исправления.

This commit is contained in:
DyatelO 2022-01-08 15:50:03 +03:00
parent a6c79ba3aa
commit b197f6d8b2
6 changed files with 28 additions and 62 deletions

View File

@ -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}

View File

@ -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

View File

@ -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<ExtraLife>();
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<HexCell> cells = new List<HexCell>();
//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<ExtraLife>().gameObject;
player.transform.position = respawnPosition;
if(player.transform.position == respawnPosition)
{

View File

@ -25,7 +25,7 @@ namespace DefaultNamespace.AI
_enemy.OnDeath += AgentDeath;
}
private void AgentDeath()
private void AgentDeath(Unit unit)
{
AIManager.Instance.RemoveAgent(this);
}

View File

@ -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<GameObject, AIAgent>();
AIManager aiManager = new AIManager();
controllers.Add(aiManager);
new GameObject("Timer").AddComponent<TimerHelper>();
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<Type> SetUpItems()
{
return new List<Type>() { typeof(Tower), typeof(AttackBonus), typeof(DefenceBonus) };
}
}
}

View File

@ -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<Item> OnItemPickUp;
public Action<Unit> 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);