Merge branch 'main' of https://github.com/Crizomb/ProjetAMJV_CR
This commit is contained in:
commit
7925fd966a
10 changed files with 1294 additions and 14 deletions
61
Assets/Scripts/BehaviorChoice.cs
Normal file
61
Assets/Scripts/BehaviorChoice.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
2
Assets/Scripts/BehaviorChoice.cs.meta
Normal file
2
Assets/Scripts/BehaviorChoice.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c6efd77ab92bc124d94cdd0f63dc60f3
|
|
@ -1,11 +1,15 @@
|
|||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class UnitPlacement : MonoBehaviour
|
||||
public class ShopCanvas : MonoBehaviour
|
||||
{
|
||||
private Camera _camera;
|
||||
public Vector3 lastPosition;
|
||||
[SerializeField] private LayerMask placementLayer;
|
||||
[SerializeField] private LayerMask behaviorLayer;
|
||||
|
||||
[SerializeField] private GameObject behaviorMenu;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
@ -38,4 +42,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ public class UnitButton : MonoBehaviour
|
|||
|
||||
|
||||
[SerializeField] GameObject unitPrefab;
|
||||
[SerializeField] UnitPlacement unitPlacement;
|
||||
[SerializeField] ShopCanvas unitPlacement;
|
||||
public event Action OnClicked, OnExit;
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue