更改文件架构
This commit is contained in:
60
Packages/Common~/Scripts/Door/PhysicsDoor.cs
Normal file
60
Packages/Common~/Scripts/Door/PhysicsDoor.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class PhysicsDoor : MonoBehaviour, IAction
|
||||
{
|
||||
public enum State
|
||||
{
|
||||
Close,
|
||||
Open,
|
||||
HalfOpen,
|
||||
Locked,
|
||||
}
|
||||
public Transform root;
|
||||
public Vector3 openEuler;
|
||||
public Vector3 closeEuler;
|
||||
public State state;
|
||||
void Start()
|
||||
{
|
||||
Set();
|
||||
}
|
||||
public void Excute()
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case State.Open:
|
||||
state = State.Close;
|
||||
Set();
|
||||
break;
|
||||
case State.Close:
|
||||
state = State.Open;
|
||||
Set();
|
||||
break;
|
||||
}
|
||||
}
|
||||
void Set(bool isClosed)
|
||||
{
|
||||
if (isClosed)
|
||||
{
|
||||
root.localEulerAngles = closeEuler;
|
||||
}
|
||||
else
|
||||
{
|
||||
root.localEulerAngles = openEuler;
|
||||
}
|
||||
}
|
||||
void Set()
|
||||
{
|
||||
var isClosed = state switch
|
||||
{
|
||||
State.Locked => true,
|
||||
State.Close => true,
|
||||
State.Open => false,
|
||||
_ => true
|
||||
};
|
||||
Set(isClosed);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Door/PhysicsDoor.cs.meta
Normal file
11
Packages/Common~/Scripts/Door/PhysicsDoor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b1d23c488f41754ea714f972c248130
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user