_xiaofang/xiaofang/Assets/Script/XFS.cs

81 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class XFS : MonoBehaviour
{
public static XFS instance;
// Start is called before the first frame update
public Button ConnectGun;
public Button ConnectFa;
public Button OpenFa;
public GameObject Gun;
public Transform Hand;
public Transform XFsTransform;
public GameObject ShuiguanGameObject;
public GameObject firewater;
public GameObject water;
public bool IShavewater=false;
public CharacterControl CharacterControl;
public UseSkill UseSkill;
void Start()
{
ShuiguanGameObject.SetActive(false);
instance =this;
ConnectGun.onClick.AddListener((() =>
{
PLayerLook();
CharacterControl.enabled = false; Invoke("connectGun",6f);}));
ConnectFa.onClick.AddListener(() =>
{
PLayerLook();
ShuiguanGameObject.SetActive(true);
CharacterControl.enabled = false; Invoke("connectFa", 6f);
});
OpenFa.onClick.AddListener(() =>
{
PLayerLook();
CharacterControl.enabled = false; Invoke("openFa", 6f);
});
}
public void PLayerLook()
{
GameObject.FindGameObjectWithTag("Player").transform.LookAt(new Vector3(this.transform.position.x, GameObject.FindGameObjectWithTag("Player").transform.position.y, this.transform.position.z));
}
public void connectGun()
{
//UseSkill.Initgun(Gun);
CharacterControl.enabled = true;
}
public void connectFa()
{
Solver solver = ShuiguanGameObject.GetComponent<Solver>();
solver.INit(Gun.transform);
CharacterControl.enabled = true;
}
public void openFa()
{
water = Instantiate(firewater);
water.transform.SetParent(Gun.transform);
water.transform.localPosition = new Vector3(0, 0, 0);
water.transform.localRotation = new Quaternion(0, 180, 0, 0);
CharacterControl.enabled = true;
water.SetActive(false);
IShavewater = true;
UseSkill.Initgun();
}
// Update is called once per frame
void Update()
{
}
}