112 lines
2.6 KiB
C#
112 lines
2.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/*
|
|
* 使用技能,需要人物身上有动画控制脚本
|
|
*
|
|
*/
|
|
|
|
|
|
public class UseSkill : MonoBehaviour
|
|
{
|
|
//private CharacterAin CharacterAin;
|
|
|
|
// 玩家手中当前持有的物品
|
|
//[HideInInspector]
|
|
public GameObject currentItem = null;
|
|
|
|
public Skill_Pick _skill_Pick;
|
|
public Skill_Jump _skill_Jump;
|
|
public Skill_watering _skill_Watering;
|
|
//Fire fire = new Fire();
|
|
|
|
// 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>();
|
|
//Debug.LogError(_skill_Pick.Pick());
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Skill_Watering();
|
|
Skill_Pick();
|
|
|
|
}
|
|
//连接水管
|
|
public void Initgun(GameObject ob)
|
|
{
|
|
ob = _skill_Pick.Pick();
|
|
ob.transform.localRotation = new Quaternion(0, 180, 0, 0);
|
|
}
|
|
|
|
//拾取
|
|
void Skill_Pick()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.F))
|
|
{
|
|
Debug.LogError("F");
|
|
//Debug.LogError(skill_Pick.Pick());
|
|
currentItem = _skill_Pick.Pick();
|
|
if(currentItem==null) return;
|
|
if(currentItem.transform.name == "NoFire")
|
|
{
|
|
currentItem.transform.Rotate(180f, -80f, -30f);
|
|
}
|
|
if (currentItem.transform.name == "gun")
|
|
{
|
|
currentItem.transform.Rotate(0, 180f, 0);
|
|
}
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Q))
|
|
{
|
|
currentItem = _skill_Pick.Drop(currentItem);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//洒水
|
|
void Skill_Watering()
|
|
{
|
|
if (currentItem == null)
|
|
{
|
|
return;
|
|
}
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
if (currentItem == null)
|
|
{
|
|
return;
|
|
}
|
|
Debug.Log(00000000000000000);
|
|
_skill_Watering.StartWatering(currentItem);
|
|
if (currentItem.gameObject.name == "gun")
|
|
{
|
|
if (XFS.instance.IShavewater)
|
|
{
|
|
XFS.instance.water.SetActive(true);
|
|
}
|
|
}
|
|
|
|
}
|
|
if (Input.GetMouseButtonUp(0))
|
|
{
|
|
_skill_Watering.StopWatering(currentItem);
|
|
if (currentItem.gameObject.name == "gun")
|
|
{
|
|
if (XFS.instance.IShavewater)
|
|
{
|
|
XFS.instance.water.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|