Browse Source

替换场景中的固定水炮模型并添加旋转功能。

develop
曹衍涛 4 years ago
parent
commit
f3e6ef25d1
  1. BIN
      Assets/01ZhongSha/Texture/Material #4.mat
  2. 8
      Assets/01ZhongSha/Texture/Material #4.mat.meta
  3. BIN
      Assets/01ZhongSha/Texture/XF_SP_Color.png
  4. 88
      Assets/01ZhongSha/Texture/XF_SP_Color.png.meta
  5. BIN
      Assets/01ZhongSha/Texture/XF_SP_Normal.png
  6. 88
      Assets/01ZhongSha/Texture/XF_SP_Normal.png.meta
  7. BIN
      Assets/01ZhongSha/XFSS/Materials/Material #4.mat
  8. 8
      Assets/01ZhongSha/XFSS/Materials/Material #4.mat.meta
  9. BIN
      Assets/01ZhongSha/XFSS/Materials/Material #5.mat
  10. 8
      Assets/01ZhongSha/XFSS/Materials/Material #5.mat.meta
  11. BIN
      Assets/01ZhongSha/XFSS/SP.FBX
  12. 121
      Assets/01ZhongSha/XFSS/SP.FBX.meta
  13. 17
      Assets/Editor/SceneToolNew.cs
  14. BIN
      Assets/Resources/SP.prefab
  15. 7
      Assets/Resources/SP.prefab.meta
  16. BIN
      Assets/Scene/MainScene_New.unity
  17. BIN
      Assets/SceneAll.prefab
  18. 297
      Assets/Scripts/DisasterSetting/ZDSP/FCGSPControl.cs
  19. 462
      Assets/Scripts/DisasterSetting/ZDSP/ZDSPControl.cs
  20. 3
      Assets/Scripts/InputSystem/InputManager/InputManager.cs
  21. BIN
      Assets/Sky/Materials/azure[Sky].mat

BIN
Assets/01ZhongSha/Texture/Material #4.mat

Binary file not shown.

8
Assets/01ZhongSha/Texture/Material #4.mat.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a656be339ec0ff74f86991e1e555d78f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/01ZhongSha/Texture/XF_SP_Color.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

88
Assets/01ZhongSha/Texture/XF_SP_Color.png.meta

@ -0,0 +1,88 @@
fileFormatVersion: 2
guid: 124a9d7611622954da1023a9a0cad7dd
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/01ZhongSha/Texture/XF_SP_Normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 KiB

88
Assets/01ZhongSha/Texture/XF_SP_Normal.png.meta

@ -0,0 +1,88 @@
fileFormatVersion: 2
guid: 1c5f89f253350c940b855652469ffd8a
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 1
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/01ZhongSha/XFSS/Materials/Material #4.mat

Binary file not shown.

8
Assets/01ZhongSha/XFSS/Materials/Material #4.mat.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 82ef11937ea7ddd4e937a5b04e23d13c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/01ZhongSha/XFSS/Materials/Material #5.mat

Binary file not shown.

8
Assets/01ZhongSha/XFSS/Materials/Material #5.mat.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 721f586957d5fc248b0a102333fc8310
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/01ZhongSha/XFSS/SP.FBX

Binary file not shown.

121
Assets/01ZhongSha/XFSS/SP.FBX.meta

@ -0,0 +1,121 @@
fileFormatVersion: 2
guid: cff193040e330eb4c9dcd85dfa7fb35d
ModelImporter:
serializedVersion: 23
fileIDToRecycleName:
100000: //RootNode
100002: sp_bi
100004: SP_DI
100006: SP_Famen
100008: sp_tou
400000: //RootNode
400002: sp_bi
400004: SP_DI
400006: SP_Famen
400008: sp_tou
2100000: 'Material #4'
2300000: sp_bi
2300002: SP_DI
2300004: SP_Famen
2300006: sp_tou
3300000: sp_bi
3300002: SP_DI
3300004: SP_Famen
3300006: sp_tou
4300000: sp_bi
4300002: sp_tou
4300004: SP_DI
4300006: SP_Famen
7400000: Take 001
9500000: //RootNode
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: 'Material #4'
second: {fileID: 2100000, guid: 721f586957d5fc248b0a102333fc8310, type: 2}
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 1
previousCalculatedGlobalScale: 0.01
hasPreviousCalculatedGlobalScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
importAnimation: 1
copyAvatar: 0
humanDescription:
serializedVersion: 2
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 2
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

17
Assets/Editor/SceneToolNew.cs

@ -403,4 +403,21 @@ public class SceneToolNew
}
}
}
[MenuItem("SceneToolNew/ChangeXFSP")]
public static void ChangeXFSP()
{
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
GameObject SP = Resources.Load("SP") as GameObject;
for (int i = 0; i < obj.Length; i++)
{
if (obj[i].name.Contains("XFSP")&& !obj[i].name.Contains("ziti"))
{
GameObject sp = GameObject.Instantiate(SP);
sp.transform.parent = obj[i].transform;
sp.name = "sp";
sp.transform. localPosition = new Vector3(0,0,-0.06f);
}
}
}
}

BIN
Assets/Resources/SP.prefab

Binary file not shown.

7
Assets/Resources/SP.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 722570206ab6e15429e81c32e7bac1eb
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scene/MainScene_New.unity

Binary file not shown.

BIN
Assets/SceneAll.prefab

Binary file not shown.

297
Assets/Scripts/DisasterSetting/ZDSP/FCGSPControl.cs

@ -1,9 +1,16 @@
using AX.MessageSystem;
using AX.InputSystem;
using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum RotateAxis
{
X,
Y,
Z,
}
public class FCGSPControl : ObjDoubleClick
{
public bool IsWartering;
@ -11,8 +18,17 @@ public class FCGSPControl : ObjDoubleClick
private long id;
public GameObject part;
public GameObject water;
public Transform Hrotate;
public Transform Vrotate;
public RotateAxis HAxis;
public RotateAxis VAxis;
public string Hpath;
public string Vpath;
public float MaxV;
public float MinV;
private void Awake()
{
//sp/sp_bi/sp_tou
int num = int.Parse(name.Substring(4,name.Length-4));
////if (gameObject.name.Split('_').Length > 0)
@ -29,18 +45,219 @@ public class FCGSPControl : ObjDoubleClick
water = GameObject.Instantiate(part, transform);
}
particle = transform.GetComponentInChildren<ParticleControlOfType>(true).transform;
Hrotate = transform.Find(Hpath);
Vrotate = transform.Find(Vpath);
if (particle.gameObject.activeInHierarchy)
{
particle.gameObject.SetActive(false);
}
}
// Start is called before the first frame update
void Start()
{
MessageDispatcher.AddListener("ReplayFrame", ReplayFrameZDSP);
MessageDispatcher.AddListener("ReplayEvent", ReplayEventZDSP);
MessageDispatcher.AddListener("EQUALS_COMMAND", PressureUp);
MessageDispatcher.AddListener("MINUS_COMMAND", PressureDown);
MessageDispatcher.AddListener("U_COMMAND", U);
MessageDispatcher.AddListener("J_COMMAND", J);
MessageDispatcher.AddListener("H_COMMAND", H);
MessageDispatcher.AddListener("K_COMMAND", K);
}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameZDSP);
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventZDSP);
MessageDispatcher.RemoveListener("EQUALS_COMMAND", PressureUp);
MessageDispatcher.RemoveListener("MINUS_COMMAND", PressureDown);
MessageDispatcher.RemoveListener("U_COMMAND", U);
MessageDispatcher.RemoveListener("J_COMMAND", J);
MessageDispatcher.RemoveListener("H_COMMAND", H);
MessageDispatcher.RemoveListener("K_COMMAND", K);
}
private void K(IMessage obj)
{
if (Hrotate==null)
{
return;
}
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight * 2f;
switch (HAxis)
{
case RotateAxis.X:
//var x = CheckV(Vrotate.localEulerAngles.x);
Hrotate.localEulerAngles += new Vector3(speed, 0, 0);
break;
case RotateAxis.Y:
Hrotate.localEulerAngles += new Vector3(0, speed, 0);
break;
case RotateAxis.Z:
Hrotate.localEulerAngles += new Vector3(0, 0, speed);
break;
default:
break;
}
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
private void H(IMessage obj)
{
if (Hrotate == null)
{
return;
}
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight * 2f;
switch (HAxis)
{
case RotateAxis.X:
//var x = CheckV(Vrotate.localEulerAngles.x);
Hrotate.localEulerAngles -= new Vector3(speed, 0, 0);
break;
case RotateAxis.Y:
Hrotate.localEulerAngles -= new Vector3(0, speed, 0);
break;
case RotateAxis.Z:
Hrotate.localEulerAngles -= new Vector3(0, 0, speed);
break;
default:
break;
}
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
private void J(IMessage obj)
{
if (Vrotate==null)
{
return;
}
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight * 2f;
switch (VAxis)
{
case RotateAxis.X:
var x = CheckV(Vrotate.localEulerAngles.x);
if (x < MinV)
{
Vrotate.localEulerAngles = new Vector3(MinV, Vrotate.localEulerAngles.y, Vrotate.localEulerAngles.z);
return;
}
Vrotate.localEulerAngles -= new Vector3(speed, 0, 0);
break;
case RotateAxis.Y:
var y = CheckV(Vrotate.localEulerAngles.y);
if (y < MinV)
{
Vrotate.localEulerAngles = new Vector3(Vrotate.localEulerAngles.x, y, Vrotate.localEulerAngles.z);
return;
}
Vrotate.localEulerAngles -= new Vector3(0, speed, 0);
break;
case RotateAxis.Z:
var z = CheckV(Vrotate.localEulerAngles.z);
if (z < MinV)
{
Vrotate.localEulerAngles = new Vector3(Vrotate.localEulerAngles.x, Vrotate.localEulerAngles.y, z);
return;
}
Vrotate.localEulerAngles -= new Vector3(0, 0, speed);
break;
default:
break;
}
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
private void U(IMessage obj)
{
if (Vrotate == null)
{
return;
}
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight * 2f;
switch (VAxis)
{
case RotateAxis.X:
var x = CheckV(Vrotate.localEulerAngles.x);
if (x>MaxV)
{
Vrotate.localEulerAngles = new Vector3(MaxV, Vrotate.localEulerAngles.y, Vrotate.localEulerAngles.z);
return;
}
Vrotate.localEulerAngles += new Vector3( speed, 0,0);
break;
case RotateAxis.Y:
var y = CheckV(Vrotate.localEulerAngles.y);
if (y > MaxV)
{
Vrotate.localEulerAngles = new Vector3(Vrotate.localEulerAngles.x, y, Vrotate.localEulerAngles.z);
return;
}
Vrotate.localEulerAngles += new Vector3( 0,speed, 0);
break;
case RotateAxis.Z:
var z = CheckV(Vrotate.localEulerAngles.z);
if (z > MaxV)
{
Vrotate.localEulerAngles = new Vector3(Vrotate.localEulerAngles.x, Vrotate.localEulerAngles.y, z);
return;
}
Vrotate.localEulerAngles += new Vector3(0, 0,speed);
break;
default:
break;
}
ZDSPData data = GetData();
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(data));
}
}
private void PressureDown(IMessage obj)
{
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight*0.1f;
float size = particle.GetComponent<ParticleControlOfType>().GetScaleValue();
particle.GetComponent<ParticleControlOfType>().SetScaleValue(size - speed);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
private void PressureUp(IMessage obj)
{
if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
{
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight*0.1f;
float size= particle.GetComponent<ParticleControlOfType>().GetScaleValue();
particle.GetComponent<ParticleControlOfType>().SetScaleValue(size+speed);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
}
private void ReplayEventZDSP(IMessage obj)
@ -70,7 +287,35 @@ public class FCGSPControl : ObjDoubleClick
GetComponent<BaseGameObjInfo>().gameObjID = data.id;
IsWartering = data.isWatering;
particle.GetComponent<ParticleControlOfType>().SetScaleValue(data.scale);
// Body.localEulerAngles = new Vector3(Body.localEulerAngles.x, Body.localEulerAngles.y, data.xRoate);
switch (HAxis)
{
case RotateAxis.X:
Hrotate.localEulerAngles = new Vector3(data.HRoate, Hrotate.localEulerAngles.y, Hrotate.localEulerAngles.z);
break;
case RotateAxis.Y:
Hrotate.localEulerAngles = new Vector3( Hrotate.localEulerAngles.x, data.HRoate, Hrotate.localEulerAngles.z);
break;
case RotateAxis.Z:
Hrotate.localEulerAngles = new Vector3(Hrotate.localEulerAngles.x, Hrotate.localEulerAngles.y, data.HRoate);
break;
default:
break;
}
switch (VAxis)
{
case RotateAxis.X:
Vrotate.localEulerAngles = new Vector3(data.VRoate, Vrotate.localEulerAngles.y, Vrotate.localEulerAngles.z);
break;
case RotateAxis.Y:
Vrotate.localEulerAngles = new Vector3(Vrotate.localEulerAngles.x, data.VRoate, Vrotate.localEulerAngles.z);
break;
case RotateAxis.Z:
Vrotate.localEulerAngles = new Vector3(Vrotate.localEulerAngles.x, Vrotate.localEulerAngles.y, data.VRoate);
break;
default:
break;
}
//Hrotate.localEulerAngles = new Vector3(Hrotate.localEulerAngles.x, Hrotate.localEulerAngles.y, data.xRoate);
// Pao.localEulerAngles = new Vector3(data.yRoate, Pao.localEulerAngles.y, Pao.localEulerAngles.z);
if (IsWartering)
particle.gameObject.SetActive(true);
@ -85,7 +330,7 @@ public class FCGSPControl : ObjDoubleClick
public override void ClickFunc()
{
base.ClickFunc();
Debug.Log(111);
if (!IsWartering)
ResourceLoadWindow.Instance.LoadTipWindow("开启喷水?", () =>
{
@ -103,14 +348,54 @@ public class FCGSPControl : ObjDoubleClick
}
public ZDSPData GetData()
{
return new ZDSPData()
ZDSPData data = new ZDSPData
{
name = gameObject.name,
id = this.id,
isWatering = IsWartering,
scale = particle.GetComponent<ParticleControlOfType>().GetScaleValue(),
//xRoate = Body.localEulerAngles.z,
// yRoate = Pao.localEulerAngles.x
HAxis = HAxis,
VAxis = VAxis,
// xRoate = Hrotate.localEulerAngles.z,
// yRoate = Vrotate.localEulerAngles.x
};
switch (data.VAxis)
{
case RotateAxis.X:
data.VRoate= Vrotate.localEulerAngles.x;
break;
case RotateAxis.Y:
data.VRoate = Vrotate.localEulerAngles.y;
break;
case RotateAxis.Z:
data.VRoate = Vrotate.localEulerAngles.z;
break;
default:
break;
}
switch (data.HAxis)
{
case RotateAxis.X:
data.HRoate = Hrotate.localEulerAngles.x;
break;
case RotateAxis.Y:
data.HRoate = Hrotate.localEulerAngles.y;
break;
case RotateAxis.Z:
data.HRoate = Hrotate.localEulerAngles.z;
break;
default:
break;
}
return data;
}
private float CheckV(float x)
{
if (x >= 180 && x <= 360)
{
x = x - 360;
}
return x;
}
}

462
Assets/Scripts/DisasterSetting/ZDSP/ZDSPControl.cs

@ -11,246 +11,248 @@ public class ZDSPData
public string name;
public long id;
public bool isWatering;
public float xRoate;
public float yRoate;
public float HRoate;
public float VRoate;
public RotateAxis HAxis;
public RotateAxis VAxis;
public float scale;
}
public class ZDSPControl : ObjDoubleClick
{
public bool IsWartering;
public Transform Body;
public Transform Pao;
private ZDSPParticle particle;
private long id;
private void Awake()
{
if (gameObject.name.Split('_').Length > 0)
{
id = 1990199019901990 + (long.Parse)(gameObject.name.Split('_')[1]);
GetComponent<BaseGameObjInfo>().gameObjID = id;
gameObject.name = id.ToString();
}
EntitiesManager.Instance.AddEntity(id, gameObject);
if (!SelectedObjs.gameObjs.Contains(gameObject))
SelectedObjs.gameObjs.Add(gameObject);
}
private void Start()
{
Body = transform.Find("PaoShen");
Pao = Body.transform.Find("PaoGuan");
// particle = Pao.transform.Find("WaterStraight").GetComponent<ZDSPParticle>();
particle = transform.GetComponentInChildren<ZDSPParticle>();
Debug.Log(particle.name);
MessageDispatcher.AddListener("EQUALS_COMMAND", PressureUp);
MessageDispatcher.AddListener("MINUS_COMMAND", PressureDown);
MessageDispatcher.AddListener("U_COMMAND", U);
MessageDispatcher.AddListener("J_COMMAND", J);
MessageDispatcher.AddListener("H_COMMAND", H);
MessageDispatcher.AddListener("K_COMMAND", K);
MessageDispatcher.AddListener("ReplayFrame", ReplayFrameZDSP);
MessageDispatcher.AddListener("ReplayEvent", ReplayEventZDSP);
}
public ZDSPData GetData()
{
return new ZDSPData()
{
name = gameObject.name,
id = this.id,
isWatering = IsWartering,
scale = particle.GetScaleValue(),
xRoate = Body.localEulerAngles.z,
yRoate = Pao.localEulerAngles.x
};
}
void SetData(ZDSPData data)
{
id = data.id;
GetComponent<BaseGameObjInfo>().gameObjID = data.id;
IsWartering = data.isWatering;
particle.SetScaleValue(data.scale);
Body.localEulerAngles = new Vector3(Body.localEulerAngles.x, Body.localEulerAngles.y, data.xRoate);
Pao.localEulerAngles = new Vector3(data.yRoate, Pao.localEulerAngles.y, Pao.localEulerAngles.z);
if (IsWartering)
particle.gameObject.SetActive(true);
else
particle.gameObject.SetActive(false);
}
private void ReplayEventZDSP(IMessage obj)
{
var eventData = (EventData)obj.Data;
if (eventData.eventType == RecordEventType.ZDSP)
{
ZDSPData data = JsonUtility.FromJson<ZDSPData>(eventData.json);
if (data.name == gameObject.name)
SetData(data);
}
}
//public bool IsWartering;
//public Transform Body;
//public Transform Pao;
//private ZDSPParticle particle;
//private long id;
//private void Awake()
//{
// if (gameObject.name.Split('_').Length > 0)
// {
// id = 1990199019901990 + (long.Parse)(gameObject.name.Split('_')[1]);
// GetComponent<BaseGameObjInfo>().gameObjID = id;
// gameObject.name = id.ToString();
// }
// EntitiesManager.Instance.AddEntity(id, gameObject);
// if (!SelectedObjs.gameObjs.Contains(gameObject))
// SelectedObjs.gameObjs.Add(gameObject);
//}
//private void Start()
//{
// Body = transform.Find("PaoShen");
// Pao = Body.transform.Find("PaoGuan");
// // particle = Pao.transform.Find("WaterStraight").GetComponent<ZDSPParticle>();
// particle = transform.GetComponentInChildren<ZDSPParticle>();
// Debug.Log(particle.name);
// MessageDispatcher.AddListener("EQUALS_COMMAND", PressureUp);
// MessageDispatcher.AddListener("MINUS_COMMAND", PressureDown);
// MessageDispatcher.AddListener("U_COMMAND", U);
// MessageDispatcher.AddListener("J_COMMAND", J);
// MessageDispatcher.AddListener("H_COMMAND", H);
// MessageDispatcher.AddListener("K_COMMAND", K);
// MessageDispatcher.AddListener("ReplayFrame", ReplayFrameZDSP);
// MessageDispatcher.AddListener("ReplayEvent", ReplayEventZDSP);
//}
//public ZDSPData GetData()
//{
// return new ZDSPData()
// {
// name = gameObject.name,
// id = this.id,
// isWatering = IsWartering,
// scale = particle.GetScaleValue(),
// xRoate = Body.localEulerAngles.z,
// yRoate = Pao.localEulerAngles.x
// };
//}
//void SetData(ZDSPData data)
//{
// id = data.id;
// GetComponent<BaseGameObjInfo>().gameObjID = data.id;
// IsWartering = data.isWatering;
// particle.SetScaleValue(data.scale);
// Body.localEulerAngles = new Vector3(Body.localEulerAngles.x, Body.localEulerAngles.y, data.xRoate);
// Pao.localEulerAngles = new Vector3(data.yRoate, Pao.localEulerAngles.y, Pao.localEulerAngles.z);
// if (IsWartering)
// particle.gameObject.SetActive(true);
// else
// particle.gameObject.SetActive(false);
//}
//private void ReplayEventZDSP(IMessage obj)
//{
// var eventData = (EventData)obj.Data;
// if (eventData.eventType == RecordEventType.ZDSP)
// {
// ZDSPData data = JsonUtility.FromJson<ZDSPData>(eventData.json);
// if (data.name == gameObject.name)
// SetData(data);
// }
//}
private void ReplayFrameZDSP(IMessage obj)
{
var objectData = (ObjectData)obj.Data;
if (objectData.cloneObjType == CloneObjType.ZDSP)
{
ZDSPData data = JsonUtility.FromJson<ZDSPData>(objectData.json);
if (data.name == gameObject.name)
SetData(data);
}
}
//private void ReplayFrameZDSP(IMessage obj)
//{
// var objectData = (ObjectData)obj.Data;
// if (objectData.cloneObjType == CloneObjType.ZDSP)
// {
// ZDSPData data = JsonUtility.FromJson<ZDSPData>(objectData.json);
// if (data.name == gameObject.name)
// SetData(data);
// }
//}
private void PressureDown(IMessage obj)
{
if (IsWartering && SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
particle.Decrease(0.1f);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
//private void PressureDown(IMessage obj)
//{
// if (IsWartering && SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// particle.Decrease(0.1f);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
//}
private void PressureUp(IMessage obj)
{
if (IsWartering && SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
particle.Increase(0.1f);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
//private void PressureUp(IMessage obj)
//{
// if (IsWartering && SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// particle.Increase(0.1f);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
//}
private void K(IMessage obj)
{
if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
{
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight;
speed = speed * 2;
float x = Body.localEulerAngles.x;
float y = Body.localEulerAngles.y;
float z = Body.localEulerAngles.z;
z = CheckValue(z);
z += speed;
if (z >= 360)
{
z -= 360;
}
if (z <= -360)
{
z += 360;
}
Body.localEulerAngles = new Vector3(x, y, z);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
}
//private void K(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Body.localEulerAngles.x;
// float y = Body.localEulerAngles.y;
// float z = Body.localEulerAngles.z;
// z = CheckValue(z);
// z += speed;
// if (z >= 360)
// {
// z -= 360;
// }
// if (z <= -360)
// {
// z += 360;
// }
// Body.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
private void H(IMessage obj)
{
if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
{
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight;
speed = speed * 2;
float x = Body.localEulerAngles.x;
float y = Body.localEulerAngles.y;
float z = Body.localEulerAngles.z;
z = CheckValue(z);
z -= speed;
if (z >= 360)
{
z -= 360;
}
if (z <= -360)
{
z += 360;
}
Body.localEulerAngles = new Vector3(x, y, z);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
}
//private void H(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Body.localEulerAngles.x;
// float y = Body.localEulerAngles.y;
// float z = Body.localEulerAngles.z;
// z = CheckValue(z);
// z -= speed;
// if (z >= 360)
// {
// z -= 360;
// }
// if (z <= -360)
// {
// z += 360;
// }
// Body.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
private void J(IMessage obj)
{
if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
{
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight;
speed = speed * 2;
float x = Pao.localEulerAngles.x;
float y = Pao.localEulerAngles.y;
float z = Pao.localEulerAngles.z;
x = CheckValue(x);
x -= speed;
x = Mathf.Clamp(x, 15, 90);
Pao.localEulerAngles = new Vector3(x, y, z);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
}
//private void J(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Pao.localEulerAngles.x;
// float y = Pao.localEulerAngles.y;
// float z = Pao.localEulerAngles.z;
// x = CheckValue(x);
// x -= speed;
// x = Mathf.Clamp(x, 15, 90);
// Pao.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
private void U(IMessage obj)
{
if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
{
var gameObjID = (long)obj.Sender;
if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
{
var speed = ((WeightCmdArgs)obj.Data).Weight;
speed = speed * 2;
float x = Pao.localEulerAngles.x;
float y = Pao.localEulerAngles.y;
float z = Pao.localEulerAngles.z;
x = CheckValue(x);
x += speed;
x = Mathf.Clamp(x, 15, 90);
Pao.localEulerAngles = new Vector3(x, y, z);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}
}
}
//private void U(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Pao.localEulerAngles.x;
// float y = Pao.localEulerAngles.y;
// float z = Pao.localEulerAngles.z;
// x = CheckValue(x);
// x += speed;
// x = Mathf.Clamp(x, 15, 90);
// Pao.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("EQUALS_COMMAND", PressureUp);
MessageDispatcher.RemoveListener("MINUS_COMMAND", PressureDown);
MessageDispatcher.RemoveListener("U_COMMAND", U);
MessageDispatcher.RemoveListener("J_COMMAND", J);
MessageDispatcher.RemoveListener("H_COMMAND", H);
MessageDispatcher.RemoveListener("K_COMMAND", K);
MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameZDSP);
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventZDSP);
EntitiesManager.Instance.RemoveEntity(id, gameObject);
}
public override void ClickFunc()
{
base.ClickFunc();
if (!IsWartering)
ResourceLoadWindow.Instance.LoadTipWindow("开启喷水?", () =>
{
IsWartering = true;
particle.gameObject.SetActive(true);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}, null);
else
ResourceLoadWindow.Instance.LoadTipWindow("关闭喷水?", () =>
{
IsWartering = false;
particle.gameObject.SetActive(false);
RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
}, null);
}
/// <summary>
/// 换算原始角度值为显式值
/// </summary>
/// <param name="x">获取的原始角度值</param>
/// <returns></returns>
protected float CheckValue(float x)
{
if (x >= 180 && x <= 360)
{
x = x - 360;
}
return x;
//举例:假如获取到的localEulerAngles.x = 300,则在显示面板其显示的值为-60=300-360,用此显式值计算
}
//private void OnDestroy()
//{
// MessageDispatcher.RemoveListener("EQUALS_COMMAND", PressureUp);
// MessageDispatcher.RemoveListener("MINUS_COMMAND", PressureDown);
// MessageDispatcher.RemoveListener("U_COMMAND", U);
// MessageDispatcher.RemoveListener("J_COMMAND", J);
// MessageDispatcher.RemoveListener("H_COMMAND", H);
// MessageDispatcher.RemoveListener("K_COMMAND", K);
// MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameZDSP);
// MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventZDSP);
// EntitiesManager.Instance.RemoveEntity(id, gameObject);
//}
//public override void ClickFunc()
//{
// base.ClickFunc();
// if (!IsWartering)
// ResourceLoadWindow.Instance.LoadTipWindow("开启喷水?", () =>
// {
// IsWartering = true;
// particle.gameObject.SetActive(true);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }, null);
// else
// ResourceLoadWindow.Instance.LoadTipWindow("关闭喷水?", () =>
// {
// IsWartering = false;
// particle.gameObject.SetActive(false);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }, null);
//}
///// <summary>
///// 换算原始角度值为显式值
///// </summary>
///// <param name="x">获取的原始角度值</param>
///// <returns></returns>
//protected float CheckValue(float x)
//{
// if (x >= 180 && x <= 360)
// {
// x = x - 360;
// }
// return x;
// //举例:假如获取到的localEulerAngles.x = 300,则在显示面板其显示的值为-60=300-360,用此显式值计算
//}
}

3
Assets/Scripts/InputSystem/InputManager/InputManager.cs

@ -163,7 +163,8 @@ public class InputManager : MonoBehaviour
}
}
if (SelectedObjs.selectedObj.GetComponent<ControlSprayHead>())
if (SelectedObjs.selectedObj.GetComponent<ControlSprayHead>()||
SelectedObjs.selectedObj.GetComponent<FCGSPControl>())
{
if (Input.GetButton("U"))
{

BIN
Assets/Sky/Materials/azure[Sky].mat

Binary file not shown.
Loading…
Cancel
Save