2024-10-21 10:08:49 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2024-12-25 11:12:18 +08:00
|
|
|
|
using UnityEngine.UI;
|
2024-10-21 10:08:49 +08:00
|
|
|
|
|
2024-10-23 20:48:23 +08:00
|
|
|
|
public enum Firestate
|
|
|
|
|
{
|
|
|
|
|
ExtinguishFire,//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
NotExtinguishFire//δ<><CEB4><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
public class Fire : MonoBehaviour
|
|
|
|
|
{
|
2024-10-23 20:48:23 +08:00
|
|
|
|
|
2024-12-27 17:43:27 +08:00
|
|
|
|
public bool isPlayerInRange = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڷ<EFBFBD>Χ<EFBFBD><CEA7>
|
2024-10-21 10:08:49 +08:00
|
|
|
|
private bool isExtinguishing = false; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-05 09:21:07 +08:00
|
|
|
|
public float extinguishTime = 3f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
2024-10-21 10:08:49 +08:00
|
|
|
|
private float holdTime = 0f; // <20><>ס<EFBFBD><D7A1>ť<EFBFBD>ļ<EFBFBD>ʱ
|
2024-12-04 16:40:48 +08:00
|
|
|
|
public float fireHurt = 10f;
|
2024-11-07 19:13:50 +08:00
|
|
|
|
|
2024-12-04 16:40:48 +08:00
|
|
|
|
public float dis;
|
|
|
|
|
|
|
|
|
|
public float maxfiredis = 2f;
|
2024-12-17 17:27:46 +08:00
|
|
|
|
public float firedis = 20f;
|
2024-12-04 16:40:48 +08:00
|
|
|
|
|
|
|
|
|
public PlayerState ps;
|
|
|
|
|
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
2024-12-04 16:40:48 +08:00
|
|
|
|
|
|
|
|
|
float timer = 0;
|
2024-11-06 11:28:04 +08:00
|
|
|
|
//private Firestate firestate = Firestate.NotExtinguishFire;
|
2024-12-25 11:12:18 +08:00
|
|
|
|
public UseSkill UseSkill;
|
2024-12-25 17:38:45 +08:00
|
|
|
|
public PlayerMovement_Jpystick characterControl;//<2F><><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-25 11:12:18 +08:00
|
|
|
|
public Text TimeText;
|
2024-10-21 10:08:49 +08:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
2024-12-04 16:40:48 +08:00
|
|
|
|
ps = GameObject.Find("player").GetComponent<PlayerState>();
|
2024-12-25 11:12:18 +08:00
|
|
|
|
TimeText.gameObject.SetActive(false);
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-24 09:23:47 +08:00
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
void Update()
|
2024-11-07 19:13:50 +08:00
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
|
|
|
|
|
HurtPeople();
|
|
|
|
|
|
2024-12-27 17:43:27 +08:00
|
|
|
|
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
|
|
|
|
if (UseSkill == null)
|
2024-12-04 16:40:48 +08:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-12-25 22:08:40 +08:00
|
|
|
|
if (UseSkill.currentItem == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-12-27 17:43:27 +08:00
|
|
|
|
else if(UseSkill.currentItem.transform.name != "NoFire" && UseSkill.currentItem.transform.name!="gun")
|
|
|
|
|
{
|
2024-12-06 11:29:20 +08:00
|
|
|
|
return;
|
2024-12-04 16:40:48 +08:00
|
|
|
|
}
|
2024-12-06 11:29:20 +08:00
|
|
|
|
MieFire();
|
|
|
|
|
|
2024-11-07 19:13:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-04 16:40:48 +08:00
|
|
|
|
public void HurtPeople()
|
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
dis = Vector3.Distance(GameObject.Find("player").transform.position, this.transform.position);
|
|
|
|
|
|
2024-12-04 16:40:48 +08:00
|
|
|
|
|
2024-12-05 09:21:07 +08:00
|
|
|
|
if(dis<maxfiredis)
|
2024-12-04 16:40:48 +08:00
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
timer += Time.deltaTime;
|
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѫ");
|
|
|
|
|
if (timer > 1f)
|
|
|
|
|
{
|
|
|
|
|
//Debug.Log("================================================");
|
|
|
|
|
ps.beHurt(fireHurt);
|
|
|
|
|
timer = 0;
|
|
|
|
|
}
|
2024-12-04 16:40:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-07 19:13:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-18 17:19:35 +08:00
|
|
|
|
public void MieFire()
|
2024-10-21 10:08:49 +08:00
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڷ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD>Ұ<EFBFBD>ס<EFBFBD><D7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//if (isPlayerInRange && Input.GetMouseButton(0))
|
|
|
|
|
//{
|
|
|
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
// if (!isExtinguishing)
|
|
|
|
|
// DisablePlayerControl();
|
|
|
|
|
|
|
|
|
|
// holdTime += Time.deltaTime;
|
|
|
|
|
// Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>" + holdTime);
|
|
|
|
|
|
|
|
|
|
// if (holdTime >= extinguishTime && !isExtinguishing)
|
|
|
|
|
// {
|
|
|
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD>ס<EFBFBD><D7A1><EFBFBD>ﵽָ<EFB5BD><D6B8>ʱ<EFBFBD>䣬ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
// StopFire();
|
|
|
|
|
// isExtinguishing = true; // <20><>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// //Debug.Log("<22>ɿ<EFBFBD><C9BF><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뿪<EFBFBD><EBBFAA>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD>ʱ
|
|
|
|
|
// holdTime = 0f;
|
|
|
|
|
// isExtinguishing = false;
|
|
|
|
|
// // <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// if (!Input.GetMouseButton(0)) EnablePlayerControl();
|
|
|
|
|
//}
|
2024-12-27 17:43:27 +08:00
|
|
|
|
Debug.Log(11111111);
|
2024-12-24 17:55:44 +08:00
|
|
|
|
if (isPlayerInRange&& UseSkill.IsWater)
|
2024-10-21 10:08:49 +08:00
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>
|
|
|
|
|
dis = Vector3.Distance(GameObject.Find("player").transform.position, this.transform.position);
|
2024-12-24 17:55:44 +08:00
|
|
|
|
|
2024-12-05 09:21:07 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҿ<EFBFBD><D2BE><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>㹻<EFBFBD><E3B9BB><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (dis <= firedis)
|
2024-10-21 10:08:49 +08:00
|
|
|
|
{
|
2024-12-25 11:12:18 +08:00
|
|
|
|
TimeText.gameObject.SetActive(true);
|
2024-12-05 09:21:07 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
if (!isExtinguishing)
|
|
|
|
|
DisablePlayerControl();
|
2024-12-25 11:12:18 +08:00
|
|
|
|
|
2024-12-05 09:21:07 +08:00
|
|
|
|
holdTime += Time.deltaTime;
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>" + holdTime);
|
2024-12-25 11:12:18 +08:00
|
|
|
|
TimeText.GetComponent<Text>().text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>" + holdTime;
|
2024-12-05 09:21:07 +08:00
|
|
|
|
if (holdTime >= extinguishTime && !isExtinguishing)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD>ס<EFBFBD><D7A1><EFBFBD>ﵽָ<EFB5BD><D6B8>ʱ<EFBFBD>䣬ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
StopFire();
|
|
|
|
|
isExtinguishing = true; // <20><>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
2024-12-05 09:21:07 +08:00
|
|
|
|
}
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-07 19:13:50 +08:00
|
|
|
|
else
|
2024-10-21 10:08:49 +08:00
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뿪<EFBFBD><EBBFAA>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD>ʱ
|
2024-10-21 10:08:49 +08:00
|
|
|
|
holdTime = 0f;
|
|
|
|
|
isExtinguishing = false;
|
2024-12-25 22:08:40 +08:00
|
|
|
|
//TimeText.gameObject.SetActive(false);
|
2024-10-21 10:08:49 +08:00
|
|
|
|
// <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
2024-12-04 16:40:48 +08:00
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 19:13:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|
|
|
|
public void StartFire()
|
|
|
|
|
{
|
2024-10-23 20:48:23 +08:00
|
|
|
|
this.gameObject.SetActive(true);
|
2024-10-21 10:08:49 +08:00
|
|
|
|
isExtinguishing = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
public void StopFire()
|
|
|
|
|
{
|
2024-12-25 18:02:44 +08:00
|
|
|
|
this.characterControl.DragTheScreen.enabled=true;
|
2024-10-23 20:48:23 +08:00
|
|
|
|
this.gameObject.SetActive(false);
|
2024-10-21 10:08:49 +08:00
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD>Ϩ<EFBFBD><CFA8>");
|
2024-12-24 17:55:44 +08:00
|
|
|
|
isPlayerInRange = false; // <20><><EFBFBD><EFBFBD><EFBFBD>뿪<EFBFBD><EBBFAA>Χ
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
|
|
|
|
UseSkill.FireOUt();
|
|
|
|
|
TimeText.gameObject.SetActive(false);
|
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
2024-12-25 11:12:18 +08:00
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>淶Χʱ<CEA7><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
//if (other.CompareTag("Player"))
|
|
|
|
|
//{
|
|
|
|
|
// isPlayerInRange = true; // <20><><EFBFBD>ҽ<EFBFBD><D2BD>뷶Χ
|
|
|
|
|
// characterControl = other.GetComponent<CharacterControl>();
|
|
|
|
|
|
|
|
|
|
//}
|
2024-10-21 10:08:49 +08:00
|
|
|
|
if (other.CompareTag("Player"))
|
|
|
|
|
{
|
2024-12-24 17:55:44 +08:00
|
|
|
|
Debug.Log(111111111);
|
2024-10-21 10:08:49 +08:00
|
|
|
|
isPlayerInRange = true; // <20><><EFBFBD>ҽ<EFBFBD><D2BD>뷶Χ
|
2024-12-25 17:38:45 +08:00
|
|
|
|
characterControl = other.GetComponent<PlayerMovement_Jpystick>();
|
2024-12-24 17:55:44 +08:00
|
|
|
|
UseSkill= other.GetComponent<UseSkill>();
|
|
|
|
|
//// <20><><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD>˴<EFBFBD><CBB4>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>Χ
|
|
|
|
|
//float playerDistance = Vector3.Distance(other.transform.position, this.transform.position);
|
|
|
|
|
//if (playerDistance <= maxfiredis)
|
|
|
|
|
//{
|
|
|
|
|
// isPlayerInRange = true;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// isPlayerInRange = false;
|
|
|
|
|
//}
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뿪<EFBFBD><EBBFAA><EFBFBD>淶Χʱ<CEA7><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
|
|
|
{
|
2024-12-05 09:21:07 +08:00
|
|
|
|
//if (other.CompareTag("Player"))
|
|
|
|
|
//{
|
|
|
|
|
// isPlayerInRange = false; // <20><><EFBFBD><EFBFBD><EFBFBD>뿪<EFBFBD><EBBFAA>Χ
|
|
|
|
|
// characterControl = null;
|
|
|
|
|
//}
|
2024-10-21 10:08:49 +08:00
|
|
|
|
if (other.CompareTag("Player"))
|
|
|
|
|
{
|
|
|
|
|
isPlayerInRange = false; // <20><><EFBFBD><EFBFBD><EFBFBD>뿪<EFBFBD><EBBFAA>Χ
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
2024-12-25 18:02:44 +08:00
|
|
|
|
characterControl.DragTheScreen.enabled = true;
|
2024-12-25 22:08:40 +08:00
|
|
|
|
|
|
|
|
|
UseSkill.FireOUt();
|
|
|
|
|
// TimeText.gameObject.SetActive(false);
|
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private void DisablePlayerControl()
|
|
|
|
|
{
|
|
|
|
|
if (characterControl != null)
|
|
|
|
|
{
|
2024-12-25 18:02:44 +08:00
|
|
|
|
characterControl.DragTheScreen.enabled = false;
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private void EnablePlayerControl()
|
|
|
|
|
{
|
|
|
|
|
if (characterControl != null)
|
|
|
|
|
{
|
2024-12-25 18:02:44 +08:00
|
|
|
|
characterControl.DragTheScreen.enabled = true;
|
2024-10-21 10:08:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|