|
|
|
|
using AX.MessageSystem;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System;
|
|
|
|
|
//Author:ZCG
|
|
|
|
|
//CreatTime:12/1/2017
|
|
|
|
|
/// <summary>
|
|
|
|
|
///<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LadderStretch : ObjStretch
|
|
|
|
|
{
|
|
|
|
|
private enum LadderType
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 6<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
six,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 15<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
fifteen
|
|
|
|
|
}
|
|
|
|
|
[SerializeField]
|
|
|
|
|
private LadderType ladderType;
|
|
|
|
|
protected override void Init()
|
|
|
|
|
{
|
|
|
|
|
objUp = GetObj("LadderUp");
|
|
|
|
|
switch (ladderType)
|
|
|
|
|
{
|
|
|
|
|
case LadderType.six:
|
|
|
|
|
speed = 1;
|
|
|
|
|
nodeLength = 3;
|
|
|
|
|
break;
|
|
|
|
|
case LadderType.fifteen:
|
|
|
|
|
speed = 2;
|
|
|
|
|
nodeLength = 5;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected override void InputControl()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void LeftShift_W(IMessage obj)
|
|
|
|
|
{
|
|
|
|
|
if (SelectedObjs.selectedObj == gameObject)
|
|
|
|
|
{
|
|
|
|
|
Stretch();
|
|
|
|
|
AddRecordEventStrech();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LeftShift_S(IMessage obj)
|
|
|
|
|
{
|
|
|
|
|
if (SelectedObjs.selectedObj == gameObject)
|
|
|
|
|
{
|
|
|
|
|
Shorten();
|
|
|
|
|
AddRecordEventShorten();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void W(IMessage obj)
|
|
|
|
|
{
|
|
|
|
|
if (SelectedObjs.selectedObj == gameObject)
|
|
|
|
|
{
|
|
|
|
|
if (transform.localRotation.x > -0.7)
|
|
|
|
|
{
|
|
|
|
|
transform.Rotate(Vector3.right * Time.deltaTime * -100);
|
|
|
|
|
}
|
|
|
|
|
AddRecordEventW();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddRecordEventW()
|
|
|
|
|
{
|
|
|
|
|
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.LadderW;
|
|
|
|
|
eventData.json = gameObject.name;
|
|
|
|
|
|
|
|
|
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void S(IMessage obj)
|
|
|
|
|
{
|
|
|
|
|
if (SelectedObjs.selectedObj == gameObject)
|
|
|
|
|
{
|
|
|
|
|
if (transform.localRotation.x < 0.7)
|
|
|
|
|
{
|
|
|
|
|
transform.Rotate(Vector3.right * Time.deltaTime * 100);
|
|
|
|
|
}
|
|
|
|
|
AddRecordEventS();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddRecordEventS()
|
|
|
|
|
{
|
|
|
|
|
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.LadderS;
|
|
|
|
|
eventData.json = gameObject.name;
|
|
|
|
|
|
|
|
|
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
MessageDispatcher.AddListener("LEFTSHIFT_W_COMMAND", LeftShift_W);
|
|
|
|
|
MessageDispatcher.AddListener("LEFTSHIFT_S_COMMAND", LeftShift_S);
|
|
|
|
|
MessageDispatcher.AddListener("W_COMMAND", W);
|
|
|
|
|
MessageDispatcher.AddListener("S_COMMAND", S);
|
|
|
|
|
MessageDispatcher.AddListener("ReplayEvent", ReplayEventLadder);
|
|
|
|
|
}
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
MessageDispatcher.RemoveListener("LEFTSHIFT_W_COMMAND", LeftShift_W);
|
|
|
|
|
MessageDispatcher.RemoveListener("LEFTSHIFT_S_COMMAND", LeftShift_S);
|
|
|
|
|
MessageDispatcher.RemoveListener("W_COMMAND", W);
|
|
|
|
|
MessageDispatcher.RemoveListener("S_COMMAND", S);
|
|
|
|
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventLadder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ReplayEventLadder(IMessage obj)
|
|
|
|
|
{
|
|
|
|
|
var eventData = (EventData)obj.Data;
|
|
|
|
|
if (eventData.json == gameObject.name)
|
|
|
|
|
{
|
|
|
|
|
if(eventData.eventType== RecordEventType.LadderStrech)
|
|
|
|
|
{
|
|
|
|
|
Stretch();
|
|
|
|
|
}
|
|
|
|
|
else if(eventData.eventType == RecordEventType.LadderShorten)
|
|
|
|
|
{
|
|
|
|
|
Shorten();
|
|
|
|
|
}
|
|
|
|
|
else if (eventData.eventType == RecordEventType.LadderW)
|
|
|
|
|
{
|
|
|
|
|
if (transform.localRotation.x > -0.7)
|
|
|
|
|
{
|
|
|
|
|
transform.Rotate(Vector3.right * Time.deltaTime * -100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (eventData.eventType == RecordEventType.LadderS)
|
|
|
|
|
{
|
|
|
|
|
if (transform.localRotation.x < 0.7)
|
|
|
|
|
{
|
|
|
|
|
transform.Rotate(Vector3.right * Time.deltaTime * 100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddRecordEventStrech()
|
|
|
|
|
{
|
|
|
|
|
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.LadderStrech;
|
|
|
|
|
eventData.json = gameObject.name;
|
|
|
|
|
|
|
|
|
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void AddRecordEventShorten()
|
|
|
|
|
{
|
|
|
|
|
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.LadderShorten;
|
|
|
|
|
eventData.json = gameObject.name;
|
|
|
|
|
|
|
|
|
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
MessageDispatcher.RemoveListener("LEFTSHIFT_W_COMMAND", LeftShift_W);
|
|
|
|
|
MessageDispatcher.RemoveListener("LEFTSHIFT_S_COMMAND", LeftShift_S);
|
|
|
|
|
MessageDispatcher.RemoveListener("W_COMMAND", W);
|
|
|
|
|
MessageDispatcher.RemoveListener("S_COMMAND", S);
|
|
|
|
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventLadder);
|
|
|
|
|
}
|
|
|
|
|
}
|