2024-10-21 10:08:49 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
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-10-21 10:08:49 +08:00
|
|
|
|
private bool isPlayerInRange = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڷ<EFBFBD>Χ<EFBFBD><CEA7>
|
|
|
|
|
private bool isExtinguishing = false; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public float extinguishTime = 3.0f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
private float holdTime = 0f; // <20><>ס<EFBFBD><D7A1>ť<EFBFBD>ļ<EFBFBD>ʱ
|
2024-11-07 19:13:50 +08:00
|
|
|
|
|
|
|
|
|
|
2024-11-06 11:28:04 +08:00
|
|
|
|
//private Firestate firestate = Firestate.NotExtinguishFire;
|
2024-10-23 20:48:23 +08:00
|
|
|
|
|
2024-10-21 10:08:49 +08:00
|
|
|
|
private CharacterControl characterControl;//<2F><><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
|
2024-10-23 20:48:23 +08:00
|
|
|
|
|
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-04 10:58:48 +08:00
|
|
|
|
|
|
|
|
|
MieFire();
|
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-11-06 11:28:04 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڷ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD>Ұ<EFBFBD>ס<EFBFBD><D7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-10-21 10:08:49 +08:00
|
|
|
|
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>
|
2024-11-20 03:42:04 +08:00
|
|
|
|
if (!isExtinguishing)
|
|
|
|
|
DisablePlayerControl();
|
2024-10-21 10:08:49 +08:00
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-07 19:13:50 +08:00
|
|
|
|
else
|
2024-10-21 10:08:49 +08:00
|
|
|
|
{
|
2024-11-07 19:13:50 +08:00
|
|
|
|
//Debug.Log("<22>ɿ<EFBFBD><C9BF><EFBFBD><EFBFBD><EFBFBD>");
|
2024-10-21 10:08:49 +08:00
|
|
|
|
// <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>
|
2024-11-20 03:42:04 +08:00
|
|
|
|
if (!Input.GetMouseButton(0)) EnablePlayerControl();
|
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-10-23 20:48:23 +08:00
|
|
|
|
this.characterControl.Restore();
|
|
|
|
|
this.gameObject.SetActive(false);
|
2024-10-21 10:08:49 +08:00
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD>Ϩ<EFBFBD><CFA8>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>淶Χʱ<CEA7><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
|
{
|
|
|
|
|
if (other.CompareTag("Player"))
|
|
|
|
|
{
|
|
|
|
|
isPlayerInRange = true; // <20><><EFBFBD>ҽ<EFBFBD><D2BD>뷶Χ
|
|
|
|
|
characterControl = other.GetComponent<CharacterControl>();
|
2024-11-18 17:19:35 +08:00
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (other.CompareTag("Player"))
|
|
|
|
|
{
|
|
|
|
|
isPlayerInRange = false; // <20><><EFBFBD><EFBFBD><EFBFBD>뿪<EFBFBD><EBBFAA>Χ
|
|
|
|
|
characterControl = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private void DisablePlayerControl()
|
|
|
|
|
{
|
|
|
|
|
if (characterControl != null)
|
|
|
|
|
{
|
|
|
|
|
characterControl.enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private void EnablePlayerControl()
|
|
|
|
|
{
|
|
|
|
|
if (characterControl != null)
|
|
|
|
|
{
|
|
|
|
|
characterControl.enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|