_xiaofang/xiaofang/Assets/Script/Character/Skills/UseSkill.cs

164 lines
4.2 KiB
C#
Raw Normal View History

2024-10-21 10:08:49 +08:00
using System.Collections;
using System.Collections.Generic;
2024-12-24 17:55:44 +08:00
using Unity.VisualScripting;
2024-10-21 10:08:49 +08:00
using UnityEngine;
2024-12-25 14:42:59 +08:00
using UnityEngine.EventSystems;
2024-12-25 22:08:40 +08:00
using UnityEngine.UI;
2024-10-21 10:08:49 +08:00
/*
* ʹ<EFBFBD>ü<EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽű<EFBFBD>
*
*/
public class UseSkill : MonoBehaviour
{
//private CharacterAin CharacterAin;
2024-10-21 10:08:49 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>е<EFBFBD><D0B5><EFBFBD>Ʒ
2024-12-20 14:38:57 +08:00
//[HideInInspector]
2024-10-21 10:08:49 +08:00
public GameObject currentItem = null;
2024-12-26 04:17:03 +08:00
public Skill_Pick _skill_Pick;
public Skill_Jump _skill_Jump;
public Skill_watering _skill_Watering;
2024-11-18 17:19:35 +08:00
//Fire fire = new Fire();
2024-12-25 22:08:40 +08:00
public Button WaterButton;
2024-12-24 17:55:44 +08:00
public bool IsWater = false;
2024-10-21 10:08:49 +08:00
// Start is called before the first frame update
void Start()
{
_skill_Pick = transform.GetComponent<Skill_Pick>();
_skill_Jump = transform.GetComponent<Skill_Jump>();
_skill_Watering = transform.GetComponent<Skill_watering>();
2024-12-25 22:08:40 +08:00
WaterButton.onClick.AddListener(Skill_Watering);
//Debug.LogError(_skill_Pick.Pick());
2024-10-21 10:08:49 +08:00
}
// Update is called once per frame
void Update()
{
2024-12-25 22:08:40 +08:00
//Skill_Watering();
//Skill_Pick();
2024-12-24 22:01:21 +08:00
if (currentItem != null)
{
if(currentItem.gameObject.name=="gun")
{
float dis= Vector3.Distance(GameObject.Find("player").transform.position, XFS.instance.transform.position);
2024-12-25 17:38:45 +08:00
if (dis >= 30f)
2024-12-24 22:01:21 +08:00
{
2024-12-26 04:17:03 +08:00
2024-12-24 22:01:21 +08:00
Drop();
}
}
}
2024-10-21 10:08:49 +08:00
}
2024-12-20 14:38:57 +08:00
//<2F><><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>
2024-12-24 17:55:44 +08:00
public void Initgun()
2024-12-20 14:38:57 +08:00
{
2024-12-24 17:55:44 +08:00
if (currentItem != null)
{
currentItem = _skill_Pick.Drop(currentItem);
currentItem = null;
}
currentItem = _skill_Pick.Pick();
if (currentItem.transform.name == "NoFire")
{
currentItem.transform.Rotate(180f, -80f, -30f);
}
if (currentItem.transform.name == "gun")
{
currentItem.transform.rotation = new Quaternion(61.7036781f, 186.325302f, 348.049622f, 0);
}
2024-12-20 14:38:57 +08:00
}
2024-10-21 10:08:49 +08:00
2024-12-24 21:06:44 +08:00
public void Pick()
{
if (currentItem != null)
{
currentItem = _skill_Pick.Drop(currentItem);
currentItem = null;
}
currentItem = _skill_Pick.Pick();
if (currentItem.transform.name == "NoFire")
{
currentItem.transform.Rotate(180f, -80f, -30f);
}
if (currentItem.transform.name == "gun")
{
currentItem.transform.rotation = new Quaternion(61.7036781f, 186.325302f, 348.049622f, 0);
}
}
public void Drop()
{
currentItem = _skill_Pick.Drop(currentItem);
2024-12-24 21:06:44 +08:00
}
2024-10-21 10:08:49 +08:00
//ʰȡ
void Skill_Pick()
{
2024-12-25 22:08:40 +08:00
//Debug.LogError(skill_Pick.Pick());
2024-12-25 22:08:40 +08:00
if (currentItem != null) { currentItem = _skill_Pick.Drop(currentItem); currentItem=null;
}
currentItem = _skill_Pick.Pick();
if(currentItem.transform.name == "NoFire") { currentItem.transform.Rotate(180f, -80f, -30f);
2024-10-21 10:08:49 +08:00
}
2024-12-25 22:08:40 +08:00
if (currentItem.transform.name == "gun") { currentItem.transform.rotation = new Quaternion(61.7036781f, 186.325302f, 348.049622f, 0);
}
2024-10-21 10:08:49 +08:00
if (Input.GetKeyDown(KeyCode.Q))
{
currentItem = _skill_Pick.Drop(currentItem);
2024-10-21 10:08:49 +08:00
}
}
2024-12-04 10:58:48 +08:00
2024-10-21 10:08:49 +08:00
//<2F><>ˮ
void Skill_Watering()
{
if (currentItem == null)
{
return;
}
2024-12-25 22:08:40 +08:00
Debug.Log(00000000000000000);
IsWater=true;
_skill_Watering.StartWatering(currentItem);
2024-12-24 17:55:44 +08:00
2024-11-18 17:19:35 +08:00
2024-12-25 22:08:40 +08:00
//if (Input.GetMouseButtonUp(0) &&! EventSystem.current.IsPointerOverGameObject())
//{
// IsWater = false;
// _skill_Watering.StopWatering(currentItem);
// if (currentItem.gameObject.name == "gun")
// {
// if (XFS.instance.IShavewater)
// {
// XFS.instance.water.SetActive(false);
// }
2024-12-24 17:55:44 +08:00
2024-12-25 22:08:40 +08:00
// //currentItem.transform.rotation = new Quaternion(0, 180f,0, 0);
2024-12-24 17:55:44 +08:00
2024-12-25 22:08:40 +08:00
// }
//}
2024-10-23 20:48:23 +08:00
}
2024-10-21 10:08:49 +08:00
public void FireOUt()
2024-12-25 22:08:40 +08:00
{IsWater=false;
if (currentItem != null)
{
_skill_Watering.StopWatering(currentItem);
}
_skill_Watering.StopWateringAnim();
}
2024-10-23 20:48:23 +08:00
2024-10-21 10:08:49 +08:00
}