_xiaofang/xiaofang/Assets/Script/XFS.cs
2024-12-17 12:00:17 +08:00

54 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class XFS : MonoBehaviour
{
// 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;
private GameObject gun;
public GameObject firewater;
void Start()
{
ConnectGun.onClick.AddListener((() => { Invoke("connectGun",6f);}));
ConnectFa.onClick.AddListener(() => { Invoke("connectFa", 6f); });
OpenFa.onClick.AddListener(() => { Invoke("openFa", 6f); });
}
public void connectGun()
{
gun = Instantiate(Gun);
gun.transform.SetParent(Hand);
gun.transform.localRotation = new Quaternion(0, 180, 0, 0);
gun.transform.localPosition = new Vector3(0.000419999997f, 0.00138999999f, 0.000569999975f);
gun.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
}
public void connectFa()
{
BezierPipe bezier = ShuiguanGameObject.GetComponent<BezierPipe>();
bezier.point1 = XFsTransform;
bezier.point2 = gun.transform;
}
public void openFa()
{
GameObject ob = Instantiate(firewater);
ob.transform.SetParent(gun.transform);
ob.transform.localPosition = new Vector3(0, 0, 0);
ob.transform.localRotation = new Quaternion(0, 180, 0, 0);
}
// Update is called once per frame
void Update()
{
}
}