Permettre 1 à 3 upgrades
This commit is contained in:
parent
c8ecace848
commit
196740676d
@ -15,7 +15,6 @@ public class AllyUpgrade : MonoBehaviour, IPointerClickHandler
|
|||||||
{
|
{
|
||||||
if (eventData.button == 0) //Left click
|
if (eventData.button == 0) //Left click
|
||||||
{
|
{
|
||||||
Debug.Log("Event clicked...");
|
|
||||||
if (!_instance)
|
if (!_instance)
|
||||||
{
|
{
|
||||||
GameObject sceneCanvas = GameObject.Find("Canvas");
|
GameObject sceneCanvas = GameObject.Find("Canvas");
|
||||||
@ -32,14 +31,11 @@ public class AllyUpgrade : MonoBehaviour, IPointerClickHandler
|
|||||||
AssignUpgrades(canvas);
|
AssignUpgrades(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.Log(_instance.transform.position);
|
|
||||||
Debug.Log(Camera.main.WorldToScreenPoint(transform.position));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Destroy(_instance);
|
Destroy(_instance);
|
||||||
Debug.Log("Destroyed....");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -47,14 +43,14 @@ public class AllyUpgrade : MonoBehaviour, IPointerClickHandler
|
|||||||
|
|
||||||
private void AssignUpgrades(Canvas canvas)
|
private void AssignUpgrades(Canvas canvas)
|
||||||
{
|
{
|
||||||
GameObject _firstChildren = _instance.transform.GetChild(1).gameObject;
|
|
||||||
Debug.Log("Upgrade count: " + _firstChildren.transform.childCount);
|
|
||||||
// Assign upgrade Prefabs
|
// Assign upgrade Prefabs
|
||||||
for (int i = 0; i < _instance.transform.childCount - 1; i++)
|
for (int i = 0; i < _instance.transform.childCount - 1; i++)
|
||||||
{
|
{
|
||||||
Debug.Log(i);
|
if (_upgradeList[i] != null)
|
||||||
|
{
|
||||||
GameObject upgradeEnfant = _instance.transform.GetChild(i).gameObject;
|
GameObject upgradeEnfant = _instance.transform.GetChild(i).gameObject;
|
||||||
UpgradePlacementButton button = upgradeEnfant.GetComponent<UpgradePlacementButton>();
|
UpgradePlacementButton button = upgradeEnfant.GetComponent<UpgradePlacementButton>();
|
||||||
button.Initialize(_upgradeList[i], gameObject, canvas);
|
button.Initialize(_upgradeList[i], gameObject, canvas);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
public class UnitTreeDisplay : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
public class UnitTreeDisplay : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||||
{
|
{
|
||||||
//private Vector3 _originPosition;
|
//private Vector3 _originPosition;
|
||||||
private Vector2 _size;
|
private Vector2 _size;
|
||||||
@ -24,11 +24,6 @@ public class UnitTreeDisplay : MonoBehaviour, IPointerEnterHandler, IPointerExit
|
|||||||
_rectTransform.anchoredPosition = position;
|
_rectTransform.anchoredPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPointerClick(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
Debug.Log("Upgrade clicked!!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPointerEnter(PointerEventData eventData)
|
public void OnPointerEnter(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
_rectTransform.sizeDelta = _size * 1.05f;
|
_rectTransform.sizeDelta = _size * 1.05f;
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class UnitTreeManager : MonoBehaviour
|
|
||||||
{
|
|
||||||
private List<UnitTreeDisplay> oogaDisplay = new List<UnitTreeDisplay>();
|
|
||||||
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
//Shows the unit's upgrades around its position
|
|
||||||
public void ShowUpgrades(Vector3 position)
|
|
||||||
{
|
|
||||||
Vector3 m_Position = position;
|
|
||||||
|
|
||||||
//Instantiate UnitTreeDisplay rect 3 times
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
GameObject rect = new GameObject();
|
|
||||||
Vector3 rectPosition = m_Position;
|
|
||||||
rectPosition.x += 10.0f * i;
|
|
||||||
GameObject instance = Instantiate(rect, rectPosition, transform.rotation);
|
|
||||||
instance.AddComponent<RectTransform>();
|
|
||||||
UnitTreeDisplay ooga = instance.AddComponent<UnitTreeDisplay>();
|
|
||||||
ooga.SetPosition(rectPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Instantiate line (later curved line? https://forum.unity.com/threads/easy-curved-line-renderer-free-utility.391219/)
|
|
||||||
|
|
||||||
//TODO later... Get unit's next upgrades
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 61640dcfbaf00194593b814583a26f96
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -33,7 +33,10 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler
|
|||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
_button = GetComponent<Button>();
|
_button = GetComponent<Button>();
|
||||||
_button.enabled = true;
|
if (_unitCardInformation == null)
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user