Roman 9b7dbdf941 任务:搭建“序章-战场”的整体流程框架
1.创建可交互电报机这个逻辑物体
*.在所有脚本首行添加说明方便查看
2.编写假电报机类,因为这个电报机没有电报机功能,而是一个类似事件的物体。
3.使假电报机可以分清场景中电话线断裂和修复的情况,并对其做出不同反应。
4.没修完电报机的反馈等待策划,修完了的等待我明天编写场景的多态系统
5.均通过了程序简单测试,请各位尽快拉取寻找问题

下班,别摸了,兄弟们
2021-08-07 01:31:29 +08:00

79 lines
2.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Shell : MonoBehaviour
{
//炮弹类,控制轰炸区内的炮弹和炮弹的阴影🎇
// Start is called before the first frame update
public GameObject shadow;//阴影游戏物体
private Transform ground;//地面的位置信息
private float shellSpeed;//炮弹速度
private IndexRecoder indexRecoder;
private float fallingTime;
private bool isDroping = false;
private Transform m_shadow;
public GameObject boomObj;
void Start()
{
indexRecoder = FindObjectOfType<IndexRecoder>();
shellSpeed = indexRecoder.shellSpeed;
fallingTime = indexRecoder.shellFallingTime;
ground = GameObject.FindWithTag("地面").transform;
m_shadow = Instantiate(shadow,//生成一片阴影
new Vector3(transform.position.x,//在这枚炮弹的X
ground.transform.position.y + //地面的Y
indexRecoder.shellShadowPositionYOffSet,//加上偏移量
0),
Quaternion.identity)
.transform;
Invoke("Drop",fallingTime);
}
// Update is called once per frame
void Update()
{
ShadowShock();
if(isDroping)
{
transform.position -= new Vector3(0,shellSpeed*Time.deltaTime,0);
}
}
private void ShadowShock()
{
m_shadow.transform.localScale = new Vector3(m_shadow.localScale.x +
Random.Range(-indexRecoder.shellShadowRangeOfChange,
indexRecoder.shellShadowRangeOfChange),
m_shadow.localScale.y,
m_shadow.localScale.z);
}
private void Drop()
{
isDroping = true;
}
void OnTriggerEnter2D(Collider2D other)
{
//Debug.Log(other.name);
//当玩家被炮弹击中
switch (other.tag)
{
case "Player":
//玩家被炮弹击中
break;
case "地面":
Destroy(m_shadow.gameObject);
Destroy(gameObject);
Instantiate(boomObj, new Vector2(transform.position.x, transform.position.y),Quaternion.identity);
break;
}
}
}