上海杨浦大连路地铁站单机版电子沙盘
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

125 lines
3.7 KiB

using SpringGUI;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//Author:ZCG
//CreatTime:12/15/2017
/// <summary>
/// 水炮属性面板
/// </summary>
public class UIPlanWaterCannon : BaseInstanceMono
{
private static UIPlanWaterCannon instance;
public static UIPlanWaterCannon Instance
{
get
{
if (instance == null)
{
Transform canvas = GameObject.Find("Canvas").transform;
GameObject panel = Instantiate(Resources.Load("Prefab/Tool/UIPlanWaterCannon") as GameObject, canvas);
instance = panel.GetComponent<UIPlanWaterCannon>();
instance.Init();
}
return instance;
}
}
private Slider Slider_SetWaterSpeed;//水速度
private Slider Slider_SetPingPongSpeed;//摇摆速度
private Text Text_WaterSpeed;//水速度
private Text Text_PingPongSpeed;//摇摆速度
public void Init()
{
Slider_SetWaterSpeed = transform.Find("Slider_SetWaterSpeed").GetComponent<Slider>();
Slider_SetPingPongSpeed = transform.Find("Slider_SetPingPongSpeed").GetComponent<Slider>();
Text_WaterSpeed = transform.Find("Text_WaterSpeed").GetComponent<Text>();
Text_PingPongSpeed = transform.Find("Text_PingPongSpeed").GetComponent<Text>();
}
/// <summary>
/// 重置面板
/// </summary>
public override void LoadObjData(GameObject chooseObject)
{
gameObject.SetActive(true);
ChooseObj = chooseObject;
//摇摆
var type = ChooseObj.GetComponent<WaterCannon>();
Slider_SetPingPongSpeed.value = type.GetPingPongSpeed() * 10;
Text_PingPongSpeed.text = (type.GetPingPongSpeed() * 10).ToString();
//射水
var particle = ChooseObj.transform.Find("Rotate/Head/WaterStraight/WaterStraightPos/WaterStraight").GetComponent<ParticleControlOfType>();
Slider_SetWaterSpeed.value = particle.GetScaleValue() * 10;
Text_WaterSpeed.text = (particle.GetScaleValue()*10).ToString();
}
public override void ResetData(GameObject dataObj)
{
dataObj.GetComponent<WaterCannon>().Revocation();
}
/// <summary>
/// 设置射水速度
/// </summary>
/// <param name="value"></param>
public void SetWaterSpeed(float value)
{
ChooseObj.GetComponent<WaterCannon>().SetWaterSpeed(value/10f);
Text_WaterSpeed.text = value.ToString();
}
/// <summary>
/// 设置摇摆速度
/// </summary>
/// <param name="value"></param>
public void SetPingPongSpeed(float value)
{
ChooseObj.GetComponent<WaterCannon>().SetPingPongSpeed(value/10f);
Text_PingPongSpeed.text = value.ToString();
}
public void OpenPingPong()
{
ChooseObj.GetComponent<WaterCannon>().OpenPingPong();
}
public void PutOutFire()
{
if (ChooseObj.GetComponent<WaterReceiver>().hasSupplier)
{
ChooseObj.GetComponent<WaterCannon>().PutOutFire();
}
else
{
ResourceLoadWindow.Instance.LoadTextHintWindow("请连接水源", 2);
}
}
/// <summary>
/// 确认
/// </summary>
public void Confirm()
{
gameObject.SetActive(false);
ChooseObj.GetComponent<WaterCannon>().Confirm();
}
/// <summary>
/// 关闭
/// </summary>
public void Cancel()
{
Revocation();
gameObject.SetActive(false);
}
/// <summary>
/// 撤销
/// </summary>
public void Revocation()
{
ChooseObj.GetComponent<WaterCannon>().Revocation();
LoadObjData(ChooseObj);
}
public override void EditorRight()
{
}
}