任务:搭建基本的系统
1.编写以撒逻辑 (1.继承于Enemy (2.编写OnSave(男童)事件,当有男童被解救,会触发以撒的这个事件,后续逻辑等待讨论 (3.具有冲撞和闪电两种攻击方式,通过类似地藏的方式轮回随机决定攻击方式 (4.编写冲撞攻击逻辑 ((*.创建鬼魂脚本 ((*.创建鬼魂预制体,需要内含触发器 ((1.当执行,以玩家为中心向周围一圈固定距离随机方向的某处召唤鬼魂,并记录下此时自身到玩家的方向 ((2.等待一小段时间,令鬼魂以记录方向冲撞出去,利用Tweener动画营造一种先抖一下然后猛地创过来的感觉 ((3.动画结束后,鬼魂逐渐消隐 ((4.消隐结束后,删除游戏物体 ((5.冲撞过程中具有攻击判定,若创到玩家,触发玩家的受击事件,同时获取主人的攻击力传给玩家 (3.编写闪电攻击逻辑 ((1.当执行,在玩家头顶一定距离处生成鬼魂 ((2.淡入显示鬼魂,一小段时间后,命令鬼魂发动落雷攻击 ((3.发动时,激活场景内的巨型落雷,同时更改落雷的x位置到鬼魂的x,子物体具有触发器,(每帧)检测到玩家在内则对玩家造成伤害 ((4.在极短的时间后关闭落雷同时开始淡出鬼魂 ((5.淡出结束后删除游戏物体 2.编写男童逻辑 (1.继承于Interactive (2.编写解救男童逻辑 ((*.修改Interactive基类,新增OnCallCancel事件,当交互键抬起时触发一次 ((*.新增男童状态的枚举类型,包含:wait、saving、OK三个状态 ((*:新增一个变量记录男童状态 ((1.重写OnCall事件,当OnCall,修改状态至saving ((2.Update回调中,若处于saving状态,则开始减少CDLeft,同时判断CDLeft是否耗尽,若耗尽,触发OnSave ((3.编写OnSave函数,修改状态至OK,通知owner自己已经OnSave ((4.重写OnCallCancel事件,当触发,判定状态,若处于saving状态,则修改状态至wait,恢复CDLeft ((*.使得玩家救人的时候无法移动,而当交互键抬起,重新获得移动能力 ((*.修改可交互基类,当玩家交互过程中丢失catching,触发可交互物体的中断,同时告知玩家交互中断,触发中断事件 ((5.解救结束后,通知玩家解救结束 至此,以撒的Boss逻辑还差首尾部分 加速吧
This commit is contained in:
parent
1cfe5ef4c0
commit
ca9a746b76
@ -195,7 +195,7 @@ public class @Player : IInputActionCollection, IDisposable
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""d5e36b3d-645c-4a18-914e-7a7ae9046eda"",
|
||||
""path"": ""<XInputController>/buttonNorth"",
|
||||
""path"": ""<Gamepad>/buttonNorth"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Play"",
|
||||
|
@ -182,7 +182,7 @@
|
||||
{
|
||||
"name": "",
|
||||
"id": "d5e36b3d-645c-4a18-914e-7a7ae9046eda",
|
||||
"path": "<XInputController>/buttonNorth",
|
||||
"path": "<Gamepad>/buttonNorth",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Play",
|
||||
|
116
Assets/Prefabs/以撒鬼魂.prefab
Normal file
116
Assets/Prefabs/以撒鬼魂.prefab
Normal file
@ -0,0 +1,116 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &7242342954004886428
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7242342954004886426}
|
||||
- component: {fileID: 7242342954004886429}
|
||||
- component: {fileID: 7242342954004886427}
|
||||
- component: {fileID: 7242342954004886424}
|
||||
m_Layer: 0
|
||||
m_Name: "\u4EE5\u6492\u9B3C\u9B42"
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7242342954004886426
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7242342954004886428}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -3.18, y: 6.39, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &7242342954004886429
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7242342954004886428}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 1
|
||||
m_Sprite: {fileID: 21300000, guid: 11b9cff6c92a53541a1acf380bc46247, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!70 &7242342954004886427
|
||||
CapsuleCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7242342954004886428}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: -0.03, y: -0.16}
|
||||
m_Size: {x: 1.04, y: 1.55}
|
||||
m_Direction: 0
|
||||
--- !u!114 &7242342954004886424
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7242342954004886428}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6734e02ccd3528e41b593315751e810f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
rushTime: 0.6
|
||||
lightning: {fileID: 0}
|
7
Assets/Prefabs/以撒鬼魂.prefab.meta
Normal file
7
Assets/Prefabs/以撒鬼魂.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b115139c858522e4284c9609bb70fd44
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
8
Assets/Scripts/Boss.meta
Normal file
8
Assets/Scripts/Boss.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb4cecb07f02a5a4eb1cb7612af729b7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Boss/以撒.meta
Normal file
8
Assets/Scripts/Boss/以撒.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d19c3e112c484414c9da80172ff8b7da
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
168
Assets/Scripts/Boss/以撒/YiSa.cs
Normal file
168
Assets/Scripts/Boss/以撒/YiSa.cs
Normal file
@ -0,0 +1,168 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
|
||||
/// <summary>
|
||||
/// 以撒类,控制以撒Boss
|
||||
/// </summary>
|
||||
public class YiSa : Enemy
|
||||
{
|
||||
// _____ _ _ _
|
||||
// | __ \ | | | (_)
|
||||
// | |__) | _| |__ | |_ ___
|
||||
// | ___/ | | | '_ \| | |/ __|
|
||||
// | | | |_| | |_) | | | (__
|
||||
// |_| \__,_|_.__/|_|_|\___|
|
||||
|
||||
/// <summary>
|
||||
/// 攻击之间的间隔时间
|
||||
/// </summary>
|
||||
[Header("攻击之间的间隔时间")][FoldoutGroup("以撒")]
|
||||
public float timeBetweenAttacks;
|
||||
/// <summary>
|
||||
/// 攻击用鬼魂的预制体
|
||||
/// </summary>
|
||||
[Header("攻击用鬼魂的预制体")][FoldoutGroup("预制体")]
|
||||
public GameObject goust;
|
||||
/// <summary>
|
||||
/// 鬼魂攻击玩家时,生成位置离玩家的距离
|
||||
/// </summary>
|
||||
[Header("鬼魂攻击玩家时,生成位置离玩家的距离")][FoldoutGroup("以撒")]
|
||||
public float atkOffsetDistance;
|
||||
|
||||
// _____ _ _
|
||||
// | __ \ (_) | |
|
||||
// | |__) | __ ___ ____ _| |_ ___
|
||||
// | ___/ '__| \ \ / / _` | __/ _ \
|
||||
// | | | | | |\ V / (_| | || __/
|
||||
// |_| |_| |_| \_/ \__,_|\__\___|
|
||||
|
||||
/// <summary>
|
||||
/// 返回类型为协程、参数为空的委托类型
|
||||
/// </summary>
|
||||
private delegate IEnumerator Action();
|
||||
private MyPlayer player;
|
||||
|
||||
// _____ _ _ ____ _
|
||||
// / ____| | | | _ \ | |
|
||||
// | | __ _| | | |_) | __ _ ___| | __
|
||||
// | | / _` | | | _ < / _` |/ __| |/ /
|
||||
// | |___| (_| | | | |_) | (_| | (__| <
|
||||
// \_____\__,_|_|_|____/ \__,_|\___|_|\_\
|
||||
|
||||
void Start(){
|
||||
Init();
|
||||
//测试用开启
|
||||
StartCoroutine(StartAATK());
|
||||
}
|
||||
|
||||
|
||||
// _ _ _
|
||||
// | \ | | | |
|
||||
// | \| | ___ _ __ _ __ ___ __ _| |
|
||||
// | . ` |/ _ \| '__| '_ ` _ \ / _` | |
|
||||
// | |\ | (_) | | | | | | | | (_| | |
|
||||
// |_| \_|\___/|_| |_| |_| |_|\__,_|_|
|
||||
|
||||
private void Init(){
|
||||
//找到必要的物体和组件
|
||||
player = FindObjectOfType<MyPlayer>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行一次攻击
|
||||
/// </summary>
|
||||
private IEnumerator StartAATK(){
|
||||
//等待攻击间隔
|
||||
yield return new WaitForSeconds(timeBetweenAttacks);
|
||||
//决定行动
|
||||
Action action = DecideAAction();
|
||||
//开始行动
|
||||
StartCoroutine(action());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 决定行动的函数
|
||||
/// </summary>
|
||||
private Action DecideAAction(){
|
||||
Action action;
|
||||
///从0、1中随机生成一种
|
||||
int r = Random.Range(0,2);
|
||||
if(r == 0)
|
||||
action = Rush;
|
||||
else
|
||||
action = Lighting;
|
||||
return action;
|
||||
}
|
||||
|
||||
private IEnumerator Rush(){
|
||||
yield return new WaitForEndOfFrame();
|
||||
Debug.Log("以撒使用了冲撞");
|
||||
//当以撒使用冲撞时
|
||||
//首先构建一个生成位置,以玩家为中心,向随机位置偏移固定距离便是
|
||||
Vector3 appearPos = (
|
||||
//玩家位置
|
||||
player.transform.position +
|
||||
//加上定长随机方向偏移量
|
||||
new Vector3(
|
||||
Random.Range(-1f,1f),Random.Range(-1f,1f),0
|
||||
).normalized *
|
||||
atkOffsetDistance
|
||||
);
|
||||
//在该位置生成一个鬼魂
|
||||
YiSaGoust t = Instantiate(
|
||||
goust,
|
||||
appearPos,
|
||||
Quaternion.identity
|
||||
).GetComponent<YiSaGoust>();
|
||||
//让鬼魂淡出
|
||||
Tweener tweener = t.GetComponent<SpriteRenderer>().DOFade(1,0.5f);
|
||||
//记录一下本次攻击的冲撞方向
|
||||
Vector2 rushDir = player.transform.position - t.transform.position;
|
||||
//告知该鬼魂执行冲撞攻击
|
||||
yield return new WaitForSeconds(1f);
|
||||
t.RushATK(rushDir);
|
||||
//ATKEnd();
|
||||
}
|
||||
|
||||
private IEnumerator Lighting(){
|
||||
yield return new WaitForEndOfFrame();
|
||||
Debug.Log("以撒使用了落雷");
|
||||
//在玩家头顶某位置召唤鬼魂
|
||||
YiSaGoust t = Instantiate(
|
||||
goust,player.transform.position +
|
||||
new Vector3(0,2f,0),Quaternion.identity
|
||||
).GetComponent<YiSaGoust>();
|
||||
//0.5秒淡入显示鬼魂
|
||||
Tweener tweener = t.GetComponent<SpriteRenderer>().DOFade(1,0.5f);
|
||||
//给玩家一秒的反应时间
|
||||
yield return new WaitForSeconds(1f);
|
||||
t.LightningATK();
|
||||
//ATKEnd();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 攻击结束的时候触发,重新开始新一轮攻击
|
||||
/// </summary>
|
||||
public void ATKEnd(){StartCoroutine(StartAATK());}
|
||||
|
||||
// ______ _
|
||||
// | ____| | |
|
||||
// | |____ _____ _ __ | |_
|
||||
// | __\ \ / / _ \ '_ \| __|
|
||||
// | |___\ V / __/ | | | |_
|
||||
// |______\_/ \___|_| |_|\__|
|
||||
|
||||
/// <summary>
|
||||
/// 当有男童被救的时候从男童触发
|
||||
/// </summary>
|
||||
public void OnSave(Boy boy){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
11
Assets/Scripts/Boss/以撒/YiSa.cs.meta
Normal file
11
Assets/Scripts/Boss/以撒/YiSa.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc2fd53966d9d3e42991b3656f32ef6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
100
Assets/Scripts/Boss/以撒/YiSaGoust.cs
Normal file
100
Assets/Scripts/Boss/以撒/YiSaGoust.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
|
||||
/// <summary>
|
||||
/// 以撒鬼魂类,控制以撒攻击时出现的鬼魂
|
||||
/// </summary>
|
||||
public class YiSaGoust : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 冲撞将消耗的时间
|
||||
/// </summary>
|
||||
[Header("冲撞将消耗的时间")]
|
||||
public float rushTime;
|
||||
private YiSa owner;
|
||||
/// <summary>
|
||||
/// 落雷的游戏物体
|
||||
/// </summary>
|
||||
[Header("落雷的游戏物体")]
|
||||
public GameObject lightning;
|
||||
void Start(){
|
||||
Init();
|
||||
}
|
||||
private void Init(){
|
||||
//找到必要的组件和物体
|
||||
owner = FindObjectOfType<YiSa>();
|
||||
//如果落雷没有落雷组件,则添加一个
|
||||
if(!lightning.TryGetComponent<Lightning>(out Lightning t))
|
||||
lightning.AddComponent<Lightning>();
|
||||
}
|
||||
public void RushATK(Vector2 rushDir){
|
||||
//创建并执行一段冲锋的动画
|
||||
Tweener tweener = transform.DOMove(
|
||||
transform.position + (Vector3)rushDir * 2,
|
||||
rushTime
|
||||
);
|
||||
tweener.SetEase(Ease.InElastic);
|
||||
//结束后,鬼魂逐渐消隐
|
||||
TweenCallback action = () => {
|
||||
GetComponent<SpriteRenderer>().DOFade(0,1);
|
||||
//消隐结束后删除自己
|
||||
Invoke("DestroySelf",1.1f);
|
||||
//宣告攻击结束
|
||||
owner.ATKEnd();
|
||||
};
|
||||
tweener.OnStepComplete(action);
|
||||
}
|
||||
|
||||
|
||||
public void LightningATK(){
|
||||
//激活落雷
|
||||
lightning.SetActive(true);
|
||||
//将落雷的X位置改变到鬼魂的X
|
||||
lightning.transform.position = new Vector3(
|
||||
transform.position.x,
|
||||
lightning.transform.position.y,
|
||||
lightning.transform.position.z
|
||||
);
|
||||
//极短的时间后关闭落雷
|
||||
Invoke("TurnOffLightning",0.2f);
|
||||
//宣告攻击结束
|
||||
owner.ATKEnd();
|
||||
//淡出鬼魂
|
||||
GetComponent<SpriteRenderer>().DOFade(0,1).OnStepComplete(()=>{
|
||||
//淡出结束后,删除游戏物体
|
||||
Destroy(gameObject);
|
||||
});
|
||||
}
|
||||
|
||||
private void TurnOffLightning(){lightning.SetActive(false);}
|
||||
private void DestroySelf(){Destroy(gameObject);}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
//如果创到玩家
|
||||
if(other.gameObject.TryGetComponent<MyPlayer>(out MyPlayer player)){
|
||||
//告诉玩家,你被攻击了
|
||||
player.OnBeHit(owner.ATK,
|
||||
((transform.position.x -
|
||||
player.transform.position.x)
|
||||
> 0) ? 1 : -1);//通过自身位置和玩家位置的比较来返回玩家本次的受击方向
|
||||
}
|
||||
}
|
||||
|
||||
private class Lightning : MonoBehaviour
|
||||
{
|
||||
void OnTriggerStay2D(Collider2D other){
|
||||
//如果创到玩家
|
||||
if(other.gameObject.TryGetComponent<MyPlayer>(out MyPlayer player)){
|
||||
//告诉玩家,你被攻击了
|
||||
player.OnBeHit(FindObjectOfType<YiSa>().ATK,
|
||||
((transform.position.x -
|
||||
player.transform.position.x)
|
||||
> 0) ? 1 : -1);//通过自身位置和玩家位置的比较来返回玩家本次的受击方向
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Boss/以撒/YiSaGoust.cs.meta
Normal file
11
Assets/Scripts/Boss/以撒/YiSaGoust.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6734e02ccd3528e41b593315751e810f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Boss/地藏.meta
Normal file
8
Assets/Scripts/Boss/地藏.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10157fa843dabbb4a8f5b247c02c084f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Boss/木马.meta
Normal file
8
Assets/Scripts/Boss/木马.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dda11ffdb64a7b4fbba53d1fb0c6a7d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/可交互.meta
Normal file
8
Assets/Scripts/可交互.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c6eb224c698c554eaaa5241aa5f775a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
125
Assets/Scripts/可交互/Boy.cs
Normal file
125
Assets/Scripts/可交互/Boy.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
|
||||
/// <summary>
|
||||
/// 男童类,基督Boss关的那个
|
||||
/// </summary>
|
||||
public class Boy : Interactive
|
||||
{
|
||||
// _____ _ _ _
|
||||
// | __ \ | | | (_)
|
||||
// | |__) | _| |__ | |_ ___
|
||||
// | ___/ | | | '_ \| | |/ __|
|
||||
// | | | |_| | |_) | | | (__
|
||||
// |_| \__,_|_.__/|_|_|\___|
|
||||
|
||||
public enum State {wait, saving, OK}
|
||||
/// <summary>
|
||||
/// 救下一个男童需要的时间
|
||||
/// </summary>
|
||||
[Header("救下一个男童需要的时间")]
|
||||
public float saveNeedTime;
|
||||
|
||||
// _____ _ _
|
||||
// | __ \ (_) | |
|
||||
// | |__) | __ ___ ____ _| |_ ___
|
||||
// | ___/ '__| \ \ / / _` | __/ _ \
|
||||
// | | | | | |\ V / (_| | || __/
|
||||
// |_| |_| |_| \_/ \__,_|\__\___|
|
||||
|
||||
private State state;
|
||||
/// <summary>
|
||||
/// 救这个男童还需要多长时间
|
||||
/// </summary>
|
||||
[Header("救这个男童还需要多长时间")][SerializeField][ReadOnly]
|
||||
private float saveNeedTimeLeft;
|
||||
private YiSa yiSa;
|
||||
|
||||
// _____ _ _ ____ _
|
||||
// / ____| | | | _ \ | |
|
||||
// | | __ _| | | |_) | __ _ ___| | __
|
||||
// | | / _` | | | _ < / _` |/ __| |/ /
|
||||
// | |___| (_| | | | |_) | (_| | (__| <
|
||||
// \_____\__,_|_|_|____/ \__,_|\___|_|\_\
|
||||
|
||||
void Start(){
|
||||
Init();
|
||||
}
|
||||
void Update(){
|
||||
//若处于被救中状态
|
||||
if(state == State.saving){
|
||||
//减少被救需要的剩余时间
|
||||
saveNeedTimeLeft -= Time.deltaTime;
|
||||
//判断是否已被救,若已成功被救
|
||||
if(saveNeedTimeLeft < 0)
|
||||
//触发被救事件
|
||||
OnSave();
|
||||
}
|
||||
}
|
||||
|
||||
// _ _ _
|
||||
// | \ | | | |
|
||||
// | \| | ___ _ __ _ __ ___ __ _| |
|
||||
// | . ` |/ _ \| '__| '_ ` _ \ / _` | |
|
||||
// | |\ | (_) | | | | | | | | (_| | |
|
||||
// |_| \_|\___/|_| |_| |_| |_|\__,_|_|
|
||||
private void Init(){
|
||||
//找到必须的组件和游戏物体
|
||||
yiSa = FindObjectOfType<YiSa>();
|
||||
//初始化救这个男童需要的剩余时间
|
||||
saveNeedTimeLeft = saveNeedTime;
|
||||
}
|
||||
/// <summary>
|
||||
/// 成功被救的时候触发
|
||||
/// </summary>
|
||||
private void OnSave(){
|
||||
//修改状态至OK
|
||||
state = State.OK;
|
||||
//通知主人自己已被救
|
||||
yiSa.OnSave(this);
|
||||
//通知玩家自己已被救
|
||||
FindObjectOfType<MyPlayer>().OnSave(this);
|
||||
}
|
||||
|
||||
// ______ _
|
||||
// | ____| | |
|
||||
// | |____ _____ _ __ | |_
|
||||
// | __\ \ / / _ \ '_ \| __|
|
||||
// | |___\ V / __/ | | | |_
|
||||
// |______\_/ \___|_| |_|\__|
|
||||
|
||||
/// <summary>
|
||||
/// 当玩家对男童使用交互
|
||||
/// </summary>
|
||||
public override void OnCall(){
|
||||
//只有当自己还在等待的时候,才能触发被救
|
||||
if(state == State.wait)
|
||||
//修改自身状态至saving
|
||||
state = State.saving;
|
||||
}
|
||||
/// <summary>
|
||||
/// 当玩家抬起交互键的时候触发
|
||||
/// </summary>
|
||||
public override void OnCallCancel(){
|
||||
if(state == State.saving){
|
||||
Debug.Log("救人中断了");
|
||||
state = State.wait;
|
||||
saveNeedTimeLeft = saveNeedTime;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 当玩家离开catching范围时触发
|
||||
/// </summary>
|
||||
public override void OnLeave(){
|
||||
//如果正在救,则触发玩家的中断事件
|
||||
if(state == State.saving){
|
||||
FindObjectOfType<MyPlayer>().OnInteractiveException();
|
||||
}
|
||||
}
|
||||
public override int RetuenState(){
|
||||
return (int)state;
|
||||
}
|
||||
}
|
11
Assets/Scripts/可交互/Boy.cs.meta
Normal file
11
Assets/Scripts/可交互/Boy.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b37c034eab19bf54384191c0f3c82043
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/小怪.meta
Normal file
8
Assets/Scripts/小怪.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e0cd0f0f375cf14d91889634c738717
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/抽象.meta
Normal file
8
Assets/Scripts/抽象.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a28c3501b715f4d459b9b7106b6ad7ae
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -13,7 +13,8 @@ public class Interactive : MonoBehaviour
|
||||
/// </summary>
|
||||
public enum ItemName{
|
||||
塞钱箱,
|
||||
硬币
|
||||
硬币,
|
||||
男童
|
||||
};
|
||||
|
||||
public ItemName itemName;
|
||||
@ -29,9 +30,21 @@ public class Interactive : MonoBehaviour
|
||||
//如果目前退出当前交互区域的时候,玩家的捕捉物体是自己,才把玩家的捕捉清空。否则说明玩家在推出前就捕捉到了新的
|
||||
//对象。这样是用来解决排布密集的可交互物体的问题
|
||||
if(player.catching == this)player.catching = null;
|
||||
//触发一个离开事件
|
||||
OnLeave();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnCall(){}
|
||||
public virtual void OnBeGaveMoney(){}
|
||||
|
||||
/// <summary>
|
||||
/// 交互键按下触发
|
||||
/// </summary>
|
||||
public virtual void OnCall(){}
|
||||
public virtual void OnBeGaveMoney(){}
|
||||
/// <summary>
|
||||
/// 交互键抬起触发
|
||||
/// </summary>
|
||||
public virtual void OnCallCancel(){}
|
||||
public virtual void OnLeave(){}
|
||||
public virtual int RetuenState(){return 0;}
|
||||
}
|
8
Assets/Scripts/玩家.meta
Normal file
8
Assets/Scripts/玩家.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc30443dcaaf65e4eac14f3668ed9ca0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -125,6 +125,11 @@ public class MyPlayer : MonoBehaviour, Boomer.I_CanBeBoomedObj
|
||||
///反击侦察器组件
|
||||
/// </summary>
|
||||
private CounterScout counterScout;
|
||||
/// <summary>
|
||||
/// 此时自己是否正在与物体交互
|
||||
/// </summary>
|
||||
[Header("此时自己是否正在与物体交互")][ReadOnly][SerializeField][FoldoutGroup("状态")]
|
||||
private bool isInteractive = false;
|
||||
|
||||
|
||||
|
||||
@ -182,14 +187,18 @@ public class MyPlayer : MonoBehaviour, Boomer.I_CanBeBoomedObj
|
||||
atkMethodMagnification.Add(AtkMethod.反弹炸弹,2);
|
||||
}
|
||||
|
||||
//移动函数,处理水平方向移动
|
||||
//移动函数,每帧运行一次,处理水平方向移动
|
||||
private void Move()
|
||||
{
|
||||
//只有不受击\不攻击的情况下可以移动
|
||||
if(inControl && !isAttacking){
|
||||
//直接修改刚体速度
|
||||
m_rigidbody.velocity = new Vector2(inputDir * speed,//水平方向以输入方向乘以预设速度大小
|
||||
m_rigidbody.velocity.y);//垂直方向不变
|
||||
}
|
||||
if(isInteractive){
|
||||
m_rigidbody.velocity = Vector2.zero;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -232,7 +241,7 @@ public class MyPlayer : MonoBehaviour, Boomer.I_CanBeBoomedObj
|
||||
{
|
||||
//移动动画
|
||||
if (inputDir == 0) m_Animator.SetBool("isWalking", false);
|
||||
else m_Animator.SetBool("isWalking", true);
|
||||
else if(!isInteractive)m_Animator.SetBool("isWalking", true);
|
||||
//跳跃动画
|
||||
m_Animator.SetBool("isJumping",isJumping);
|
||||
//下落动画
|
||||
@ -387,7 +396,9 @@ public class MyPlayer : MonoBehaviour, Boomer.I_CanBeBoomedObj
|
||||
}
|
||||
|
||||
public void OnInteractive(InputAction.CallbackContext context){
|
||||
//当按下交互键
|
||||
if(context.performed && catching != null){
|
||||
//根据所捕获物体的不同,区分一下操作
|
||||
switch(catching.itemName){
|
||||
case Interactive.ItemName.塞钱箱 :
|
||||
if(
|
||||
@ -402,8 +413,23 @@ public class MyPlayer : MonoBehaviour, Boomer.I_CanBeBoomedObj
|
||||
IPickedACoin();
|
||||
catching.OnCall();
|
||||
break;
|
||||
case Interactive.ItemName.男童 :
|
||||
if(catching.RetuenState() == (int)Boy.State.wait){
|
||||
catching.OnCall();
|
||||
isInteractive = true;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
catching.OnCall();
|
||||
isInteractive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//当抬起交互键触发OnCallCancle
|
||||
if(context.canceled && catching != null){
|
||||
catching.OnCallCancel();
|
||||
isInteractive = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ______ _
|
||||
@ -514,6 +540,21 @@ public class MyPlayer : MonoBehaviour, Boomer.I_CanBeBoomedObj
|
||||
//恢复减速减益
|
||||
speed *= 2f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当交互中断,从可交互物体触发
|
||||
/// </summary>
|
||||
public void OnInteractiveException(){
|
||||
Debug.Log("我超!什么玩意");
|
||||
isInteractive = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 当有男童被救从男童触发
|
||||
/// </summary>
|
||||
/// <param name="boy"></param>
|
||||
public void OnSave(Boy boy){
|
||||
isInteractive = false;
|
||||
}
|
||||
|
||||
|
||||
// _____ _ __
|
BIN
Assets/Sprites/早期临时混乱/3关boss.png
Normal file
BIN
Assets/Sprites/早期临时混乱/3关boss.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
132
Assets/Sprites/早期临时混乱/3关boss.png.meta
Normal file
132
Assets/Sprites/早期临时混乱/3关boss.png.meta
Normal file
@ -0,0 +1,132 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11b9cff6c92a53541a1acf380bc46247
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
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
|
||||
vTOnly: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 200
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -165,3 +165,23 @@ C# parse time : 221ms
|
||||
candidates check time : 46ms
|
||||
console write time : 0ms
|
||||
|
||||
[api-updater (non-obsolete-error-filter)] 2021/12/16 19:48:01 : Starting D:/unity/Editor/2020.3.20f1c1/Editor/Data/Tools/ScriptUpdater/APIUpdater.NonObsoleteApiUpdaterDetector.exe
|
||||
[api-updater (non-obsolete-error-filter)]
|
||||
----------------------------------
|
||||
jit/startup time : 789.0123ms
|
||||
moved types parse time: 57ms
|
||||
candidates parse time : 1ms
|
||||
C# parse time : 575ms
|
||||
candidates check time : 46ms
|
||||
console write time : 0ms
|
||||
|
||||
[api-updater (non-obsolete-error-filter)] 2021/12/16 19:48:19 : Starting D:/unity/Editor/2020.3.20f1c1/Editor/Data/Tools/ScriptUpdater/APIUpdater.NonObsoleteApiUpdaterDetector.exe
|
||||
[api-updater (non-obsolete-error-filter)]
|
||||
----------------------------------
|
||||
jit/startup time : 74.0739ms
|
||||
moved types parse time: 59ms
|
||||
candidates parse time : 1ms
|
||||
C# parse time : 193ms
|
||||
candidates check time : 46ms
|
||||
console write time : 0ms
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user