上海苏宁宝丽嘉酒店,2020.11.17 15:30改为单机版本,以后合成单机版本可以以此版本为模板
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.
 
 
 
 

442 lines
13 KiB

using AX.InputSystem;
using AX.MessageSystem;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AerialTowerTruckArm : ControlTruckArm
{
private Transform part3;
private Transform part4;
private Transform part5;
private Transform part7;
private Transform part8; //水炮
private Transform water;
public bool firstZero = true;
public bool firstFull = false;
public bool secondZero = true;
public bool secondFull = false;
public bool thirdZero = true;
public bool thirdFull = false;
private bool allzero = true;//下降极限
private bool allfull = false;//上升极限
const float Maxlength = 19.4f;
const float Minlength = 0.01634139f;
private float part6EulerAngleX = 0;
private bool selfctrl = true;
private void Start()
{
GameObjID = GetComponent<BaseGameObjInfo>().GameObjID;
}
protected override void InitObject()
{
HorizontalBaseSupport = this.transform.Find("Bi");
VerticalBaseSupport = this.transform.Find("Bi/Bi1");
part3 = this.transform.Find("Bi/Bi1/Bi2");
part4 = this.transform.Find("Bi/Bi1/Bi2/Bi3");
part5 = this.transform.Find("Bi/Bi1/Bi2/Bi3/Bi4");
LastArm = this.transform.Find("Bi/Bi1/Bi2/Bi3/Bi4/Bi5");
part7 = this.transform.Find("Bi/Bi1/Bi2/Bi3/Bi4/Bi5/pingtai");
part8 = this.transform.Find("Bi/Bi1/Bi2/Bi3/Bi4/Bi5/pingtai/Sprayer");
Part1MinFrame_y = HorizontalBaseSupport.localEulerAngles.y;
Part2MinFrame_x = VerticalBaseSupport.localEulerAngles.x;
Part3MinFrame_z = part3.localPosition.z;
Part4MinFrame_z = part4.localPosition.z;
Part5MinFrame_z = part5.localPosition.z;
}
public bool AllZero
{
get
{
return allzero;
}
private set
{
allzero = value;
}
}
public bool AllFull
{
get
{
return allfull;
}
private set
{
allfull = value;
}
}
float part3maxframe_z = 0;
float Part1MaxFrame_y = 360f;
float Part1MinFrame_y;
float Part2MaxFrame_x = 84f;
float Part2MinFrame_x;
public float Part3MaxFrame_z
{
set
{
if (value >= Maxlength)
part3maxframe_z = Maxlength;
else
part3maxframe_z = value;
}
get { return part3maxframe_z; }
}
float Part3MinFrame_z;
float part4maxframe_z = 0;
public float Part4MaxFrame_z
{
set
{
if (value >= Maxlength)
part4maxframe_z = Maxlength;
else
part4maxframe_z = value;
}
get { return part4maxframe_z; }
}
float Part4MinFrame_z;
float part5maxframe_z = 0;
public float Part5MaxFrame_z
{
set
{
if (value >= Maxlength)
part5maxframe_z = Maxlength;
else
part5maxframe_z = value;
}
get { return part5maxframe_z; }
}
float Part5MinFrame_z;
public float part5currentheight
{
set
{
thirdZero = false;
thirdFull = false;
if (value >= Part5MaxFrame_z)
{
value = Part5MaxFrame_z;
thirdFull = true;
}
if (value <= Part5MinFrame_z)
{
value = Part5MinFrame_z;
thirdZero = true;
}
part5.localPosition = new Vector3(-0.03615417f, 0.256077f, value);
}
get { return part5.localPosition.z; }
}
public float part4currentheight
{
set
{
secondZero = false;
secondFull = false;
if (value >= Part4MaxFrame_z)
{
value = Part4MaxFrame_z;
secondFull = true;
}
if (value <= Part4MinFrame_z)
{
value = Part4MinFrame_z;
secondZero = true;
}
part4.localPosition = new Vector3(-0.01290771f, 0.08317993f, value);
}
get { return part4.localPosition.z; }
}
public float part3currentheight
{
set
{
firstFull = false;
firstZero = false;
if (value >= Part3MaxFrame_z)
{
value = Part3MaxFrame_z;
firstFull = true;
}
if (value <= Part3MinFrame_z)
{
value = Part3MinFrame_z;
firstZero = true;
}
part3.localPosition = new Vector3(0.0208847f, 0.0208847f, value);
}
get { return part3.localPosition.z; }
}
public override void Raise(float weight)
{
if (AllFull)
return;
AllZero = false;
if (!thirdFull)
part5currentheight += weight;
if (thirdFull && !secondFull)
part4currentheight += weight;
if (secondFull && !firstFull)
part3currentheight += weight;
if (firstFull && secondFull && thirdFull)
{
AllFull = true;
if (RecordEvent.IsRecord())
AddSizeEvent(transform);
}
OutArmLength += weight;
}
public override void SetOutArmLength(float outarmlength)
{
if (AllFull)
return;
AllZero = false;
OutArmLength = 0f;
if (!thirdFull)
{
part5currentheight += outarmlength;
OutArmLength += part5currentheight;
outarmlength -= part5currentheight;
}
if (thirdFull && !secondFull)
{
part4currentheight += outarmlength;
OutArmLength += part4currentheight;
outarmlength -= part4currentheight;
}
if (secondFull && !firstFull)
{
part3currentheight += outarmlength;
OutArmLength += part3currentheight;
outarmlength -= part3currentheight;
}
if (firstFull && secondFull && thirdFull)
{
AllFull = true;
}
}
public override void Decline(float weight)
{
if (AllZero)
return;
AllFull = false;
if (!thirdZero)
part5currentheight -= weight;
if (thirdZero && !secondZero)
part4currentheight -= weight;
if (secondZero && !firstZero)
part3currentheight -= weight;
if (firstZero && secondZero && thirdZero)
{
AllZero = true;
if (RecordEvent.IsRecord())
AddSizeEvent(transform);
}
OutArmLength -= weight;
}
/// <summary>
/// 赋值车臂最大的的高度
/// </summary>
/// <param name="height">高度</param>
public override void SetHeight(float height)
{
var Jieshu = Mathf.FloorToInt(height / Maxlength);
float yushu = 0;
for (int i = 1; i <= Jieshu; i++)
{
if (i == Jieshu)
yushu = height % Maxlength;
else
yushu = Maxlength;
if (i == 1)
Part3MaxFrame_z = yushu;
if (i == 2)
Part4MaxFrame_z = yushu;
if (i == 3)
Part5MaxFrame_z = yushu;
}
}
public override void FixedSupport(IMessage message)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
ControlTruckArmFlag = true;
// AddListener();
CarAnimationCtrl.Down();
}
}
public override void PackUpTheLiftArm(IMessage message)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
ControlTruckArmFlag = false;
CarAnimationCtrl.Up();
OutArmLength = 0f;
HorizontalBaseSupport.localEulerAngles = Vector3.zero;
VerticalBaseSupport.localEulerAngles = new Vector3(355.5f, 0, 0);//模型穿插,调整模型预设后,这里参数也跟着修改。
part3currentheight = Part3MinFrame_z;
part4currentheight = Part4MinFrame_z;
part5currentheight = Part5MinFrame_z;
LastArm.localEulerAngles = new Vector3(1.35f, 0, 0);
part8.localEulerAngles = new Vector3(2.752f, 2.912f, 2.067f);
allzero = true;
allfull = false;
}
}
public override void AutoLiftTruckArm(IMessage message)
{
}
public override void LeftShift_J(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord())
CreateRotationEvent(LastArm);
var speed = ((WeightCmdArgs)message.Data).Weight;
part6EulerAngleX += speed;
part6EulerAngleX = Mathf.Clamp(part6EulerAngleX, -175, 0);
LastArm.localEulerAngles = new Vector3(part6EulerAngleX, 0, 0);
}
}
}
public override void LeftShift_U(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord())
CreateRotationEvent(LastArm);
var speed = ((WeightCmdArgs)message.Data).Weight;
part6EulerAngleX -= speed;
part6EulerAngleX = Mathf.Clamp(part6EulerAngleX, -176, 0);
LastArm.localEulerAngles = new Vector3(part6EulerAngleX, 0, 0);
}
}
}
public override void D(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord())
CreateRotationEvent(HorizontalBaseSupport);
var speed = ((WeightCmdArgs)message.Data).Weight;
HorizontalBaseSupport.localEulerAngles += new Vector3(0, speed, 0);
}
}
}
public override void A(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord())
CreateRotationEvent(HorizontalBaseSupport);
var speed = ((WeightCmdArgs)message.Data).Weight;
HorizontalBaseSupport.localEulerAngles -= new Vector3(0, speed, 0);
}
}
}
public override void S(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord())
CreateRotationEvent(VerticalBaseSupport);
var speed = ((WeightCmdArgs)message.Data).Weight;
float x = VerticalBaseSupport.localEulerAngles.x;
float y = VerticalBaseSupport.localEulerAngles.y;
x = CheckValue(x);
x += speed;
x = Mathf.Clamp(x, -84, -4.5f);//模型穿插,调整模型预设后,这里参数也跟着修改。
VerticalBaseSupport.localEulerAngles = new Vector3(x, y, 0);
}
}
}
public override void W(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord())
CreateRotationEvent(VerticalBaseSupport);
var speed = ((WeightCmdArgs)message.Data).Weight;
float x = VerticalBaseSupport.localEulerAngles.x;
float y = VerticalBaseSupport.localEulerAngles.y;
x = CheckValue(x);
x -= speed;
x = Mathf.Clamp(x, -84, -4.5f);
VerticalBaseSupport.localEulerAngles = new Vector3(x, y, 0);
}
}
}
public override void LeftShift_S(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord() && !AllZero)
CreateSizeEvent(this.transform);
var weight = ((WeightCmdArgs)message.Data).Weight / 4f;
Decline(weight);
}
}
}
public override void LeftShift_W(IMessage message)
{
if (selfctrl)
{
var gameObjID = (long)message.Sender;
if (gameObjID == GameObjID)
{
if (RecordEvent.IsRecord() && !AllFull)
CreateSizeEvent(this.transform);
var weight = ((WeightCmdArgs)message.Data).Weight / 4f;
Raise(weight);
}
}
}
}