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.
163 lines
6.0 KiB
163 lines
6.0 KiB
4 years ago
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.EventSystems;
|
||
|
|
||
|
public class BlizzardCannonControl : BaseTransformChange
|
||
|
{
|
||
|
public GameObject part1;
|
||
|
public GameObject water;
|
||
|
public GameObject tai;
|
||
|
public ParticleControlOfType waterControl;
|
||
|
protected override void Awake()
|
||
|
{
|
||
|
base.Awake();
|
||
|
part1 = TransformHelper.FindChild(transform, "paokou").gameObject;
|
||
|
water = TransformHelper.FindChild(transform, "Hose").gameObject;
|
||
|
tai = TransformHelper.FindChild(transform, "tai").gameObject;
|
||
|
waterControl = TransformHelper.FindChild(transform, "WaterStraight").GetComponentInChildren<ParticleControlOfType>();
|
||
|
waterControl.gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
protected override void D(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
if (gameObjID == GetComponent<BaseGameObjInfo>().GameObjID)
|
||
|
{
|
||
|
transform.Rotate(0, Time.deltaTime * 40, 0, Space.Self);
|
||
|
AddRecordADEvent();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected override void A(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
if (gameObjID == GetComponent<BaseGameObjInfo>().GameObjID)
|
||
|
{
|
||
|
transform.Rotate(0, -Time.deltaTime * 40, 0, Space.Self);
|
||
|
AddRecordADEvent();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected override void J(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
if (gameObjID == GetComponent<BaseGameObjInfo>().GameObjID)
|
||
|
{
|
||
|
if ((part1.transform.localEulerAngles.x < 20 && part1.transform.localEulerAngles.x >= 0) || (part1.transform.localEulerAngles.x <= 360 && part1.transform.localEulerAngles.x >180))
|
||
|
{
|
||
|
part1.transform.Rotate(-Time.deltaTime * 40, 0, 0, Space.Self);
|
||
|
AddRecordUJEvent();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected override void U(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
if (gameObjID == GetComponent<BaseGameObjInfo>().GameObjID)
|
||
|
{
|
||
|
if ((part1.transform.localEulerAngles.x > 285 && part1.transform.localEulerAngles.x <= 360) || (part1.transform.localEulerAngles.x >= 0 && part1.transform.localEulerAngles.x < 180))
|
||
|
{
|
||
|
part1.transform.Rotate(Time.deltaTime * 40, 0, 0, Space.Self);
|
||
|
AddRecordUJEvent();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected override void PressureDown(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
if (gameObjID == GetComponent<BaseGameObjInfo>().GameObjID)
|
||
|
{
|
||
|
waterControl.Decrease(1f);
|
||
|
AddRecordEvent(RecordEventType.WaterSprayMinus);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected override void PressureUp(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
if (gameObjID == GetComponent<BaseGameObjInfo>().GameObjID)
|
||
|
{
|
||
|
waterControl.Increase(1f);
|
||
|
AddRecordEvent(RecordEventType.WaterSprayPlus);
|
||
|
}
|
||
|
}
|
||
|
public float GetWaterScale()
|
||
|
{
|
||
|
return waterControl.GetScaleValue();
|
||
|
}
|
||
|
public void SetWaterScale(float value)
|
||
|
{
|
||
|
waterControl.SetScaleValue(value);
|
||
|
}
|
||
|
|
||
|
private void AddRecordUJEvent()
|
||
|
{
|
||
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal)
|
||
|
{
|
||
|
var eventData = new EventData();
|
||
|
eventData.time = RecordManager.Instance.RecordTimer;
|
||
|
eventData.cloneObjType = GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
eventData.eventType = RecordEventType.WaterSprayU;
|
||
|
RecordSprayerRotation data = new RecordSprayerRotation();
|
||
|
data.gameObjID = GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
data.rotation = part1.transform.localEulerAngles;
|
||
|
eventData.json = JsonUtility.ToJson(data);
|
||
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
||
|
}
|
||
|
}
|
||
|
private void AddRecordADEvent()
|
||
|
{
|
||
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal)
|
||
|
{
|
||
|
var eventData = new EventData();
|
||
|
eventData.time = RecordManager.Instance.RecordTimer;
|
||
|
eventData.cloneObjType = GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
eventData.eventType = RecordEventType.WaterSprayA;
|
||
|
RecordSprayerRotation data = new RecordSprayerRotation();
|
||
|
data.gameObjID = GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
data.rotation = transform.localEulerAngles;
|
||
|
eventData.json = JsonUtility.ToJson(data);
|
||
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
||
|
}
|
||
|
}
|
||
|
protected override void ReplayEvent(IMessage obj)
|
||
|
{
|
||
|
var eventData = (EventData)obj.Data;
|
||
|
if (eventData.eventType == RecordEventType.WaterSprayU)
|
||
|
{
|
||
|
RecordSprayerRotation data = JsonUtility.FromJson<RecordSprayerRotation>(eventData.json);
|
||
|
if (data.gameObjID == GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
{
|
||
|
part1.transform.localEulerAngles = data.rotation;
|
||
|
}
|
||
|
}
|
||
|
else if (eventData.eventType == RecordEventType.WaterSprayA)
|
||
|
{
|
||
|
RecordSprayerRotation data = JsonUtility.FromJson<RecordSprayerRotation>(eventData.json);
|
||
|
if (data.gameObjID == GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
{
|
||
|
transform.localEulerAngles = data.rotation;
|
||
|
}
|
||
|
}
|
||
|
else if (eventData.eventType == RecordEventType.WaterSprayPlus)
|
||
|
{
|
||
|
if (eventData.json == gameObject.name)
|
||
|
{
|
||
|
waterControl.Increase(1f);
|
||
|
}
|
||
|
}
|
||
|
else if (eventData.eventType == RecordEventType.WaterSprayMinus)
|
||
|
{
|
||
|
if (eventData.json == gameObject.name)
|
||
|
{
|
||
|
waterControl.Decrease(1f);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|