Change l'unité par l'upgrade choisi
This commit is contained in:
parent
968f255cd5
commit
3e0ddca9a4
@ -101,6 +101,18 @@ TextureImporter:
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
|
||||
@ -549,6 +549,7 @@ GameObject:
|
||||
- component: {fileID: 4251894621246849979}
|
||||
- component: {fileID: -488994066602243508}
|
||||
- component: {fileID: 9177659942431061517}
|
||||
- component: {fileID: -8508458510402479271}
|
||||
- component: {fileID: -6673723252830894487}
|
||||
m_Layer: 0
|
||||
m_Name: archerStick
|
||||
@ -653,6 +654,21 @@ MonoBehaviour:
|
||||
_speed: 0
|
||||
_attack_damage: 2
|
||||
_attack_interval: 4
|
||||
--- !u!114 &-8508458510402479271
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5531237550998824024}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: edcd1782caa73a747b1f060d18ce0f18, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_upgradeUI: {fileID: 4817988606444742093, guid: 1d481c7093a8d2443a04261fd7c72be2, type: 3}
|
||||
_upgradeUnitCardList: []
|
||||
_upgradePrefabList: []
|
||||
--- !u!82 &-6673723252830894487
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -134,6 +134,10 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 4817988606444742094}
|
||||
m_Modifications:
|
||||
- target: {fileID: -7391144163609056699, guid: 7a4156822defb3f4bb8a2ed6de7cacdb, type: 3}
|
||||
propertyPath: _buttonContainer
|
||||
value:
|
||||
objectReference: {fileID: 4817988606444742093}
|
||||
- target: {fileID: 907652127959947826, guid: 7a4156822defb3f4bb8a2ed6de7cacdb, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Upgrade3
|
||||
@ -300,6 +304,10 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 4817988606444742094}
|
||||
m_Modifications:
|
||||
- target: {fileID: -7391144163609056699, guid: 7a4156822defb3f4bb8a2ed6de7cacdb, type: 3}
|
||||
propertyPath: _buttonContainer
|
||||
value:
|
||||
objectReference: {fileID: 4817988606444742093}
|
||||
- target: {fileID: 907652127959947826, guid: 7a4156822defb3f4bb8a2ed6de7cacdb, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Upgrade1
|
||||
@ -462,6 +470,10 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 4817988606444742094}
|
||||
m_Modifications:
|
||||
- target: {fileID: -7391144163609056699, guid: 7a4156822defb3f4bb8a2ed6de7cacdb, type: 3}
|
||||
propertyPath: _buttonContainer
|
||||
value:
|
||||
objectReference: {fileID: 4817988606444742093}
|
||||
- target: {fileID: 907652127959947826, guid: 7a4156822defb3f4bb8a2ed6de7cacdb, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Upgrade2
|
||||
|
||||
@ -31,11 +31,11 @@ public class AllyUpgrade : MonoBehaviour, IPointerClickHandler
|
||||
else
|
||||
{
|
||||
_instance = Instantiate(_upgradeUI, Camera.main.WorldToScreenPoint(transform.position), Quaternion.identity, canvas.transform);
|
||||
AssignUpgrades(canvas);
|
||||
}
|
||||
}
|
||||
Debug.Log(_instance.transform.position);
|
||||
Debug.Log(Camera.main.WorldToScreenPoint(transform.position));
|
||||
AssignUpgrades();
|
||||
|
||||
}
|
||||
else
|
||||
@ -47,16 +47,14 @@ public class AllyUpgrade : MonoBehaviour, IPointerClickHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void AssignUpgrades()
|
||||
private void AssignUpgrades(Canvas canvas)
|
||||
{
|
||||
GameObject upgradeParent = _instance.transform.GetChild(0).gameObject;
|
||||
// Assign upgrade Prefabs
|
||||
for (int i = 0; i < upgradeParent.transform.childCount; i++)
|
||||
for (int i = 0; i < _instance.transform.childCount; i++)
|
||||
{
|
||||
GameObject upgradeEnfant = upgradeParent.transform.GetChild(i).gameObject;
|
||||
GameObject upgradeEnfant = _instance.transform.GetChild(i).gameObject;
|
||||
UpgradePlacementButton button = upgradeEnfant.GetComponent<UpgradePlacementButton>();
|
||||
button.SetUnit(_upgradeUnitCardList[i], _upgradePrefabList[i]);
|
||||
Debug.Log("Button " + button.name);
|
||||
button.Initialize(_upgradeUnitCardList[i], _upgradePrefabList[i], gameObject, canvas);
|
||||
Debug.Log("Button " + _upgradePrefabList[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using TMPro;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
@ -20,6 +21,10 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler
|
||||
private TMP_Text _rockLabel;
|
||||
[SerializeField]
|
||||
private GameObject _prefab;
|
||||
[SerializeField]
|
||||
private GameObject _buttonContainer;
|
||||
private GameObject _parentGameObject;
|
||||
private Canvas _canvas;
|
||||
|
||||
|
||||
public Button Button => _button;
|
||||
@ -34,11 +39,10 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler
|
||||
|
||||
void Update()
|
||||
{
|
||||
//_button.interactable = CanUse();
|
||||
|
||||
//SetTextFor(_foodLabel, _unitCardInformation.Food);
|
||||
//SetTextFor(_rockLabel, _unitCardInformation.Rock);
|
||||
//SetTextFor(_woodLabel, _unitCardInformation.Wood);
|
||||
if (_unitCardInformation != null)
|
||||
{
|
||||
_button.interactable = CanUse();
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanUse()
|
||||
@ -55,16 +59,24 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
//Change parent GameObject
|
||||
Vector3 instantiatePosition = _parentGameObject.transform.position;
|
||||
Debug.Log("Upgrade clicked...");
|
||||
Debug.Log("Position: " + instantiatePosition);
|
||||
Instantiate(_prefab, instantiatePosition, Quaternion.identity, _canvas.transform);
|
||||
Destroy(_parentGameObject);
|
||||
Destroy(_buttonContainer);
|
||||
|
||||
}
|
||||
|
||||
public void SetUnit(UnitCard card, GameObject gameObject)
|
||||
public void Initialize(UnitCard card, GameObject prefabGameObject, GameObject parentGameObject, Canvas canvas)
|
||||
{
|
||||
Debug.Log("Upgrade initialized...");
|
||||
SetTextFor(_foodLabel, card.Food);
|
||||
SetTextFor(_woodLabel, card.Wood);
|
||||
SetTextFor(_rockLabel, card.Rock);
|
||||
_unitCardInformation = card;
|
||||
_prefab = gameObject;
|
||||
_prefab = prefabGameObject;
|
||||
_parentGameObject = parentGameObject;
|
||||
_canvas = canvas;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user