1.修改了脚本目录,使得脚本分类合理
2.完成投掷系统 3.完成抛物线绘制系统 4.完成地雷的触发和销毁系统
This commit is contained in:
parent
fb66487ff4
commit
f5f01f4fad
@ -14,7 +14,7 @@ GameObject:
|
||||
- component: {fileID: 4018427281142380164}
|
||||
m_Layer: 0
|
||||
m_Name: "\u6295\u63B7\u7269"
|
||||
m_TagString: Untagged
|
||||
m_TagString: "\u6295\u63B7\u7269"
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@ -28,7 +28,7 @@ Transform:
|
||||
m_GameObject: {fileID: 4018427281142380165}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1.26, y: -2.0112507, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
|
@ -3808,7 +3808,6 @@ Transform:
|
||||
- {fileID: 1170258148}
|
||||
- {fileID: 913332110}
|
||||
- {fileID: 1488455137}
|
||||
- {fileID: 1494853250}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -4075,7 +4074,7 @@ GameObject:
|
||||
- component: {fileID: 1488455138}
|
||||
- component: {fileID: 1488455139}
|
||||
m_Layer: 0
|
||||
m_Name: "\u6295\u63B7\u7269"
|
||||
m_Name: "\u6295\u63B7\u7269\u5806"
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -4185,36 +4184,6 @@ SpriteRenderer:
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &1494853249
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1494853250}
|
||||
m_Layer: 0
|
||||
m_Name: "\u5730\u96F7"
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1494853250
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1494853249}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1258629581}
|
||||
m_RootOrder: 13
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1500782587
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -4447,6 +4416,128 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: -750.0001, y: 0}
|
||||
m_SizeDelta: {x: 1500, y: 335}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &1629377377
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1629377378}
|
||||
- component: {fileID: 1629377380}
|
||||
- component: {fileID: 1629377379}
|
||||
- component: {fileID: 1629377381}
|
||||
m_Layer: 0
|
||||
m_Name: "\u5730\u96F7"
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1629377378
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1629377377}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1.42, y: -2.8, z: 0}
|
||||
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &1629377379
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1629377377}
|
||||
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: 0
|
||||
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 5.12, y: 5.12}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!61 &1629377380
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1629377377}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 3, y: 3}
|
||||
newSize: {x: 5.12, y: 5.12}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 2.56, y: 2.76}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!114 &1629377381
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1629377377}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6a07a98cdd923af489010663f00cfcb1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1647231577
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -4891,7 +4982,7 @@ GameObject:
|
||||
m_Layer: 0
|
||||
m_Name: "\u6295\u63B7\u70B9"
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_Icon: {fileID: 7174288486110832750, guid: 0000000000000000d000000000000000, type: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
@ -4923,6 +5014,7 @@ GameObject:
|
||||
- component: {fileID: 1811221467}
|
||||
- component: {fileID: 1811221466}
|
||||
- component: {fileID: 1811221465}
|
||||
- component: {fileID: 1811221471}
|
||||
m_Layer: 0
|
||||
m_Name: "\u5C0F\u5B69"
|
||||
m_TagString: Player
|
||||
@ -5192,6 +5284,104 @@ Transform:
|
||||
m_Father: {fileID: 1568214228}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!120 &1811221471
|
||||
LineRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1811221464}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 0
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 0
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10301, guid: 0000000000000000f000000000000000, type: 0}
|
||||
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: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 2
|
||||
m_Positions:
|
||||
- {x: 0, y: 0, z: 0}
|
||||
- {x: 0, y: 0, z: 1}
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
widthMultiplier: 1
|
||||
widthCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0.2857151
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
colorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 1, g: 1, b: 1, a: 1}
|
||||
key1: {r: 1, g: 1, b: 1, a: 1}
|
||||
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 65535
|
||||
ctime2: 0
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
numCornerVertices: 0
|
||||
numCapVertices: 0
|
||||
alignment: 0
|
||||
textureMode: 0
|
||||
shadowBias: 0.5
|
||||
generateLightingData: 0
|
||||
m_UseWorldSpace: 1
|
||||
m_Loop: 0
|
||||
--- !u!1 &1851675995
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -5720,8 +5910,8 @@ MonoBehaviour:
|
||||
shellFallingTime: 1
|
||||
shellShadowRangeOfChange: 0.1
|
||||
shellShadowPositionYOffSet: 1.5
|
||||
rateOfChangeOfThrowingAngle: 10
|
||||
strengthOfThrowing: 5
|
||||
rateOfChangeOfThrowingAngle: 1
|
||||
strengthOfThrowing: 8
|
||||
--- !u!4 &2039349954
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
8
Assets/Scripts/AbstractItem.meta
Normal file
8
Assets/Scripts/AbstractItem.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0de373aa953462d4e9ad9e4b712ada90
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Event.meta
Normal file
8
Assets/Scripts/Event.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 479e04949314f644d8794dca4d45d14e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/GameInfo.meta
Normal file
8
Assets/Scripts/GameInfo.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2df915099f9dec14d84980a2a41df1f3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Item.meta
Normal file
8
Assets/Scripts/Item.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c5b9cd7234d38747b89d82ebbb2bb8c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
34
Assets/Scripts/Item/Mine.cs
Normal file
34
Assets/Scripts/Item/Mine.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Mine : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
//看看进来的是个啥
|
||||
switch(other.tag)
|
||||
{
|
||||
case "Player"://如果是玩家,后续填写死亡
|
||||
Debug.Log("玩家踩到地雷了");
|
||||
break;
|
||||
case "投掷物"://如果是投掷物,销毁投掷物和自己
|
||||
Debug.Log("投掷物砸到地雷了");
|
||||
Destroy(other.gameObject);
|
||||
Destroy(gameObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Item/Mine.cs.meta
Normal file
11
Assets/Scripts/Item/Mine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a07a98cdd923af489010663f00cfcb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -52,11 +52,12 @@ public class M_Player : MonoBehaviour
|
||||
throwingAngle += throwingAngleDir//则让现在的抛出角度加上变化的速度
|
||||
* indexRecoder.rateOfChangeOfThrowingAngle//乘以变化的速率
|
||||
* Time.deltaTime;//使其与时间无关
|
||||
Debug.DrawLine(transform.position,
|
||||
Debug.DrawLine(throwOffset.position,
|
||||
new Vector3(transform.position.x + 100*Mathf.Cos(throwingAngle),
|
||||
transform.position.y + 100*Mathf.Sin(throwingAngle),
|
||||
transform.position.z),
|
||||
Color.red);
|
||||
DrawPath();
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +113,7 @@ public class M_Player : MonoBehaviour
|
||||
|
||||
private void Throw()
|
||||
{
|
||||
Debug.Log("我投出手上拿着的东西了");
|
||||
//Debug.Log("我投出手上拿着的东西了");
|
||||
Rigidbody2D rigidbodyOfMissile =
|
||||
Instantiate(missile,throwOffset.position,Quaternion.identity).GetComponent<Rigidbody2D>();
|
||||
rigidbodyOfMissile.velocity = new Vector2(indexRecoder.strengthOfThrowing*Mathf.Cos(throwingAngle),
|
||||
@ -182,4 +183,31 @@ public class M_Player : MonoBehaviour
|
||||
}
|
||||
public void QuitThrowingsState(){}
|
||||
|
||||
//绘制曲线的函数,非常🐂
|
||||
public void DrawPath()
|
||||
{
|
||||
//
|
||||
LineRenderer line = GetComponent<LineRenderer>();//获取组件
|
||||
int segmentCount = 15;//定义点数
|
||||
line.positionCount = segmentCount;//传入点数
|
||||
float gravity=9.8f;//定义重力常量
|
||||
Vector2 fireOffset = new Vector2(throwOffset.position.x - transform.position.x,
|
||||
throwOffset.position.y - transform.position.y);
|
||||
Vector2[] segments = new Vector2[segmentCount];//定义二维向量数组,用来存15个点的位置
|
||||
segments[0].Set(transform.position.x + fireOffset.x, transform.position.y + fireOffset.y);//定义起点
|
||||
line.SetPosition(0, segments[0]);//把起点位置传入线的起点
|
||||
for (int i = 1; i < segmentCount; i++)//根据时间、循环确定点的位置
|
||||
{
|
||||
float time = i * Time.fixedDeltaTime * 5;//类似时间间隔的定义,也就是抛物线上的x多久取值一次
|
||||
segments[i].x = transform.position.x + //自身位置的x
|
||||
fireOffset.x + //发射偏移量的x
|
||||
time * indexRecoder.strengthOfThrowing * Mathf.Cos(throwingAngle);//水平方向位移 = v*t
|
||||
segments[i].y = (transform.position.y + fireOffset.y + //自身位置的y
|
||||
time * indexRecoder.strengthOfThrowing * Mathf.Sin(throwingAngle) +
|
||||
(0.5f * gravity * time * time)*-1);//垂直方向位移 = vt + 1/2 * g * t^2
|
||||
line.SetPosition(i, segments[i]); //把算好的点传入线的点集
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ TagManager:
|
||||
tags:
|
||||
- "\u8FDB\u5EA6\u6761"
|
||||
- "\u5730\u9762"
|
||||
- "\u6295\u63B7\u7269"
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
Loading…
x
Reference in New Issue
Block a user