Behavior choice complete

omg ça marche juste la défense il faut une reine mais en vrai c'est pas grave
This commit is contained in:
Kirabsol 2025-01-28 23:41:01 +01:00
parent 0e815e1a05
commit f52ac8863c
11 changed files with 1295 additions and 15 deletions

View file

@ -0,0 +1,61 @@
using UnityEngine;
public class BehaviorChoice : MonoBehaviour
{
public GameObject chosenUnit;
public void Neutral()
{
if (chosenUnit.GetComponent<OffensiveBehaviour>() != null)
{
Destroy(chosenUnit.GetComponent<OffensiveBehaviour>());
}
if (chosenUnit.GetComponent<DefensiveBehaviour>() != null)
{
Destroy(chosenUnit.GetComponent<DefensiveBehaviour>());
}
if (chosenUnit.GetComponent<NeutralBehaviour>() == null)
{
chosenUnit.AddComponent<NeutralBehaviour>();
this.gameObject.SetActive(false);
}
}
public void Offensive()
{
if (chosenUnit.GetComponent<NeutralBehaviour>() != null)
{
Destroy(chosenUnit.GetComponent<NeutralBehaviour>());
}
if (chosenUnit.GetComponent<DefensiveBehaviour>() != null)
{
Destroy(chosenUnit.GetComponent<DefensiveBehaviour>());
}
if (chosenUnit.GetComponent<OffensiveBehaviour>() == null)
{
chosenUnit.AddComponent<OffensiveBehaviour>();
this.gameObject.SetActive(false);
}
}
public void Defensive()
{
if (chosenUnit.GetComponent<NeutralBehaviour>() != null)
{
Destroy(chosenUnit.GetComponent<NeutralBehaviour>());
}
if (chosenUnit.GetComponent<OffensiveBehaviour>() != null)
{
Destroy(chosenUnit.GetComponent<OffensiveBehaviour>());
}
if (chosenUnit.GetComponent<DefensiveBehaviour>() == null)
{
chosenUnit.AddComponent<DefensiveBehaviour>();
this.gameObject.SetActive(false);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c6efd77ab92bc124d94cdd0f63dc60f3

View file

@ -1,11 +1,15 @@
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.AI;
public class UnitPlacement : MonoBehaviour
public class ShopCanvas : MonoBehaviour
{
[SerializeField] private Camera _camera;
public Vector3 lastPosition;
[SerializeField] private LayerMask placementLayer;
[SerializeField] private LayerMask behaviorLayer;
[SerializeField] private GameObject behaviorMenu;
public Vector3 MapPosition()
{
@ -33,4 +37,22 @@ public class UnitPlacement : MonoBehaviour
return lastPosition;
}
private void Update()
{
if (Input.GetMouseButtonDown(1))
{
Vector3 mousePos = Input.mousePosition;
mousePos.z = _camera.nearClipPlane;
Ray ray = _camera.ScreenPointToRay(mousePos);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100, behaviorLayer))
{
GameObject unite = hit.transform.GameObject();
behaviorMenu.SetActive(true);
behaviorMenu.GetComponent<BehaviorChoice>().chosenUnit = unite;
}
}
}
}

View file

@ -18,7 +18,7 @@ public class GameManager : MonoBehaviourSingletonPersistent<GameManager>
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
GoNextLevel();
}
// Update is called once per frame

View file

@ -9,7 +9,7 @@ public class UnitButton : MonoBehaviour
[SerializeField] GameObject unitPrefab;
[SerializeField] UnitPlacement unitPlacement;
[SerializeField] ShopCanvas unitPlacement;
public event Action OnClicked, OnExit;

View file

@ -1,19 +1,17 @@
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
public class WinCanvas : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
[SerializeField] TextMeshProUGUI time;
[SerializeField] GameObject gameUI;
void Start()
{
time.text = gameUI.GetComponent<GameUI>().time.ToString();
}
// Update is called once per frame
void Update()
{
}
public void NextLevel()
{