合并3.13分支

This commit is contained in:
lspdC 2022-03-13 23:27:31 +08:00
parent 5c7c268092
commit 53572ab941
18 changed files with 1493 additions and 5 deletions

View File

@ -62,6 +62,24 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""LeftChange"",
""type"": ""Button"",
""id"": ""5e4b2241-fdf3-4717-9892-456eb07bff7d"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""RightChange"",
""type"": ""Button"",
""id"": ""25825820-ed63-4821-a570-98c0346d0114"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
@ -196,6 +214,50 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
""action"": ""Interact"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""848dbb1f-2a82-4dc8-9673-c7f69bc2eaa5"",
""path"": ""<Keyboard>/q"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""LeftChange"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""d1bc2781-7f70-4170-93c3-c849ff56c3cf"",
""path"": ""<Gamepad>/dpad/left"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""LeftChange"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""bdd4c52b-c221-49d3-b467-201ebc18cb71"",
""path"": ""<Keyboard>/e"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""RightChange"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""257c9bb8-7e77-4e5c-9caf-97284fb0adbd"",
""path"": ""<Gamepad>/dpad/right"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""RightChange"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
@ -253,6 +315,8 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
m_Normal_Atk = m_Normal.FindAction("Atk", throwIfNotFound: true);
m_Normal_Jump = m_Normal.FindAction("Jump", throwIfNotFound: true);
m_Normal_Interact = m_Normal.FindAction("Interact", throwIfNotFound: true);
m_Normal_LeftChange = m_Normal.FindAction("LeftChange", throwIfNotFound: true);
m_Normal_RightChange = m_Normal.FindAction("RightChange", throwIfNotFound: true);
// Null
m_Null = asset.FindActionMap("Null", throwIfNotFound: true);
m_Null_Newaction = m_Null.FindAction("New action", throwIfNotFound: true);
@ -319,6 +383,8 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
private readonly InputAction m_Normal_Atk;
private readonly InputAction m_Normal_Jump;
private readonly InputAction m_Normal_Interact;
private readonly InputAction m_Normal_LeftChange;
private readonly InputAction m_Normal_RightChange;
public struct NormalActions
{
private @PlayerC m_Wrapper;
@ -327,6 +393,8 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
public InputAction @Atk => m_Wrapper.m_Normal_Atk;
public InputAction @Jump => m_Wrapper.m_Normal_Jump;
public InputAction @Interact => m_Wrapper.m_Normal_Interact;
public InputAction @LeftChange => m_Wrapper.m_Normal_LeftChange;
public InputAction @RightChange => m_Wrapper.m_Normal_RightChange;
public InputActionMap Get() { return m_Wrapper.m_Normal; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
@ -348,6 +416,12 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
@Interact.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
@Interact.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
@Interact.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
@LeftChange.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnLeftChange;
@LeftChange.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnLeftChange;
@LeftChange.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnLeftChange;
@RightChange.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnRightChange;
@RightChange.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnRightChange;
@RightChange.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnRightChange;
}
m_Wrapper.m_NormalActionsCallbackInterface = instance;
if (instance != null)
@ -364,6 +438,12 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
@Interact.started += instance.OnInteract;
@Interact.performed += instance.OnInteract;
@Interact.canceled += instance.OnInteract;
@LeftChange.started += instance.OnLeftChange;
@LeftChange.performed += instance.OnLeftChange;
@LeftChange.canceled += instance.OnLeftChange;
@RightChange.started += instance.OnRightChange;
@RightChange.performed += instance.OnRightChange;
@RightChange.canceled += instance.OnRightChange;
}
}
}
@ -416,6 +496,8 @@ public partial class @PlayerC : IInputActionCollection2, IDisposable
void OnAtk(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
void OnLeftChange(InputAction.CallbackContext context);
void OnRightChange(InputAction.CallbackContext context);
}
public interface INullActions
{

View File

@ -40,6 +40,24 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "LeftChange",
"type": "Button",
"id": "5e4b2241-fdf3-4717-9892-456eb07bff7d",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "RightChange",
"type": "Button",
"id": "25825820-ed63-4821-a570-98c0346d0114",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@ -174,6 +192,50 @@
"action": "Interact",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "848dbb1f-2a82-4dc8-9673-c7f69bc2eaa5",
"path": "<Keyboard>/q",
"interactions": "",
"processors": "",
"groups": "",
"action": "LeftChange",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "d1bc2781-7f70-4170-93c3-c849ff56c3cf",
"path": "<Gamepad>/dpad/left",
"interactions": "",
"processors": "",
"groups": "",
"action": "LeftChange",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "bdd4c52b-c221-49d3-b467-201ebc18cb71",
"path": "<Keyboard>/e",
"interactions": "",
"processors": "",
"groups": "",
"action": "RightChange",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "257c9bb8-7e77-4e5c-9caf-97284fb0adbd",
"path": "<Gamepad>/dpad/right",
"interactions": "",
"processors": "",
"groups": "",
"action": "RightChange",
"isComposite": false,
"isPartOfComposite": false
}
]
},

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9d2abd5208f4caf4fb48d255afe4a1c8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -111,10 +111,11 @@ public class Player : PlayerControl
base.OnMove(ctx);
m_rigidbody.velocity = new Vector2(inputDir*speed,m_rigidbody.velocity.y);
}
override protected void OnAtk() {
override protected void OnAtk() {
base.OnAtk();
}
override protected void OnJump() {
base.OnJump();
if (isGround == true) {
isGround = false;
m_rigidbody.velocity = new Vector2(m_rigidbody.velocity.x, jumpForce);
@ -122,7 +123,8 @@ public class Player : PlayerControl
}
override protected void OnInteract() {
base.OnInteract();
Leave.Instance.OnInteract();
}
private void OnCollisionEnter2D(Collision2D collision)//当有物体碰上

View File

@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
/// <summary>
/// 皇帝类,控制皇帝的行为,继承自可交互物体
/// </summary>
public class HuangDi : Interactable
{
[SerializeField][EnumPaging]
private KnotMediator.KnotType neededType = KnotMediator.KnotType.None;
public override void OnCall()
{
if(KnotMediator.Instance.CheckKnotType(neededType))
{
Debug.Log("皇帝接受了绳结");
}
else
{
Debug.Log("皇帝拒绝了绳结");
}
}
public void setNeededType(KnotMediator.KnotType type)
{
neededType = type;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1b2323b7275ad44c94037be9f2ccec3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 可交互物件基类
/// </summary>
public class Interactable : Event
{
void Start()
{
//检查触发器
if (GetComponent<Collider2D>() == null)
{
Debug.LogError(this.GetType() + ": 没有碰撞盒");
}
else if(GetComponent<Collider2D>().isTrigger == false)
{
Debug.LogError(this.GetType() + ": 碰撞盒没有设置为触发器");
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.TryGetComponent<PlayerInteract>(out PlayerInteract playerInteract))
{
playerInteract.SetCatched(this);
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.TryGetComponent<PlayerInteract>(out PlayerInteract playerInteract))
{
playerInteract.CancleCatched(this);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1efac6c6faf3ed94db548016ffee8ce5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
/// <summary>
/// 绳结中介者,负责交流皇帝、玩家、绳结的信息
/// </summary>
public class KnotMediator : UnitySingleton<KnotMediator>
{
public enum KnotType
{
None,
,
,
}
/// <summary>
/// 当前记录的绳结类型
/// </summary>
[Header("当前记录的绳结类型")][SerializeField][ReadOnly][EnumPaging]
private KnotType currentKnotType;
public void RecordKnotType(KnotType knotType)
{
currentKnotType = knotType;
}
/// <summary>
/// 有黄帝调用,检查当前记录的和需要的绳结类型是否一致
/// </summary>
/// <param name="knotType">黄帝需要的绳结类型</param>
/// <returns></returns>
public bool CheckKnotType(KnotType knotType)
{
return knotType == currentKnotType;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad9fbcfc0d0c69744804efe3d7ad3fce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
/// <summary>
/// 绳结类,继承自可交互物体
/// </summary>
public class Kont : Interactable
{
/// <summary>
/// 自身绳结类型
/// </summary>
[EnumPaging][Header("自身绳结类型")]
public KnotMediator.KnotType type;
public override void OnCall()
{
// 如果绳结类型为空,则报错
if (type == KnotMediator.KnotType.None)
{
Debug.LogError("绳结类型为空,请设置绳结类型");
return;
}
//切换记录的绳结类型
KnotMediator.Instance.RecordKnotType(type);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aaac64616770dce42a623c267c4d9d31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -16,6 +16,7 @@ public class PlayerControl : MonoBehaviour
/// </summary>
[SerializeField][ReadOnly][Header("此帧输入方向,-1为左1为右0表示此帧不输入")]
protected int inputDir;
protected PlayerInteract playerInteract;
protected virtual void Start()
{
@ -32,6 +33,19 @@ public class PlayerControl : MonoBehaviour
playerC.Normal.Jump.performed += ctx => OnJump();
//为交互操作订阅方法
playerC.Normal.Interact.performed += ctx => OnInteract();
//为左切换操作订阅方法
playerC.Normal.LeftChange.performed += ctx => OnLeftChange();
//为右切换操作订阅方法
playerC.Normal.RightChange.performed += ctx => OnRightChange();
//给玩家物体添加子物体:互动侦察器
GameObject checker = new GameObject("互动侦察器");//新建游戏物体:互动侦察器
checker.transform.SetParent(transform);//将其设置为玩家的子物体
playerInteract = checker.AddComponent<PlayerInteract>();//增加玩家互动侦察器组件
checker.AddComponent<BoxCollider2D>().isTrigger = true;//增加碰撞盒,并将其设置为触发器
checker.GetComponent<BoxCollider2D>().size = new Vector2(1f, 1f);//设置碰撞盒大小
checker.transform.localPosition = Vector3.zero;//设置碰撞盒位置
}
/// <summary>
@ -62,5 +76,17 @@ public class PlayerControl : MonoBehaviour
/// <summary>
/// 按下交互时触发
/// </summary>
protected virtual void OnInteract(){}
protected virtual void OnInteract(){
//如果有交互事件,则调用事件
playerInteract.OnCall();
}
/// <summary>
/// 按下十字键左或者Q触发
/// </summary>
protected virtual void OnLeftChange(){}
/// <summary>
/// 按下十字键右或者E触发
/// </summary>
protected virtual void OnRightChange(){}
}

View File

@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
/// <summary>
/// 玩家交互组件,挂在玩家下面的子物体中
/// </summary>
public class PlayerInteract : MonoBehaviour
{
[SerializeField][ReadOnly]
private Event catched;
public void SetCatched(Event e)
{
catched = e;
}
public void CancleCatched(Event e)
{
if (e == catched)
{
catched = null;
}
}
public void OnCall()
{
if (catched != null)
{
catched.OnCall();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 53a9e33ba521aa9469cf8214c44310e5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -38,3 +38,13 @@ C# parse time : -1ms
candidates check time : -1ms
console write time : -1ms
[api-updater (non-obsolete-error-filter)] 2022/3/13 21:33:35 : Starting D:/unity/Editor/2020.3.30f1c1/Editor/Data/Tools/ScriptUpdater/APIUpdater.NonObsoleteApiUpdaterDetector.exe
[api-updater (non-obsolete-error-filter)]
----------------------------------
jit/startup time : 826.23ms
moved types parse time: 48ms
candidates parse time : 1ms
C# parse time : -1ms
candidates check time : -1ms
console write time : -1ms

View File

@ -17,9 +17,12 @@ EditorUserSettings:
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-5:
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036cdbc9e6582b2b21382a357c67083debf42d
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036cdafbfb583124382d34312e3d2936f1f47a2decee22f0
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
flags: 0