temporary files rename
This commit is contained in:
parent
8e077e523c
commit
a87f0ed109
823 changed files with 20 additions and 5 deletions
67
Assets/BasedScripts/Crown.cs
Normal file
67
Assets/BasedScripts/Crown.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class Crown : MonoBehaviour
|
||||
{
|
||||
|
||||
public event Action OnClicked;
|
||||
public bool crowned=false;
|
||||
[SerializeField] TextMeshProUGUI texte;
|
||||
[SerializeField] private LayerMask placementLayer;
|
||||
|
||||
[SerializeField] private GameObject startButton;
|
||||
private Camera _camera;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
texte.enabled = false;
|
||||
_camera = Camera.main;
|
||||
}
|
||||
|
||||
public void StartCrown()
|
||||
{
|
||||
if (!crowned)
|
||||
{
|
||||
Debug.Log("Crowning right now");
|
||||
texte.enabled = true;
|
||||
OnClicked += Crowning;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GameObject ObjectPosition()
|
||||
{
|
||||
Vector3 mousePos = Input.mousePosition;
|
||||
mousePos.z = _camera.nearClipPlane;
|
||||
Ray ray = _camera.ScreenPointToRay(mousePos);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit, 100, placementLayer))
|
||||
{
|
||||
OnClicked -= Crowning;
|
||||
crowned = true;
|
||||
startButton.SetActive(true);
|
||||
return hit.transform.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Crowning()
|
||||
{
|
||||
GameObject unit = ObjectPosition();
|
||||
unit.GetComponent<AbstractUnit>().IsQueen = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
OnClicked?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue