
分析:分为五个阶段,每个阶段一屏宽。前四个阶段是教程阶段,分别仅放一种障碍(第一个无障碍)和提示,提示参照茶杯头教程关。 每个阶段间有明显间断、镜头固定,但当马通过该阶段的障碍后,镜头右移一个阶段。马不能倒退,相机左侧有空气墙。 到达最终阶段后,按流程点燃圣火进入游戏 设计: 1.搭建核心场景,放置障碍物。 DONE 2.设计教程及开始场景管理器 (1.控制相机,使马每通过一个阶段,相机运动到记录的位置 DONE (2.给相机左侧添加空气墙 DONE (3.管理器要明确记录此时玩家处于哪个阶段 DONE (4.当玩家进入点燃圣火触发器,切断操控,等待动画结束或者一些信号,触发从右向左的渐变黑幕遮挡全屏,随后转场到新场景。 DONE 至此,基本逻辑完成,需要补充大量细节、替换大量美术素材。 修复问题: 1.人马分离障碍连续出现可能导致致命问题,修复使其不能连续出现 DONE 2.GamePlay中,远处的山需要补充运动逻辑 DONE
112 lines
2.9 KiB
C#
112 lines
2.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 相机管理员,主要控制游戏核心玩法中,相机向右移动和卡死死法的判定
|
|
/// </summary>
|
|
public class CameraManager : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 相机移动的速度
|
|
/// </summary>
|
|
[Header("相机移动的速度")]
|
|
public float speed = 1f;
|
|
|
|
|
|
private Transform killWall;
|
|
private Transform mountain1;
|
|
private Transform mountain2;
|
|
|
|
public float mountain1Speed = 0.5f;
|
|
public float mountain2Speed = 0.8f;
|
|
|
|
void Start()
|
|
{
|
|
InitSth();
|
|
FindSth();
|
|
CreatSth();
|
|
}
|
|
|
|
|
|
void Update() {
|
|
//向右移动镜头
|
|
Move();
|
|
//移动远山
|
|
MoveMountain();
|
|
}
|
|
|
|
private void MoveMountain(){
|
|
mountain1.Translate(Vector3.left * mountain1Speed * Time.deltaTime);
|
|
mountain2.Translate(Vector3.left * mountain2Speed * Time.deltaTime);
|
|
if(mountain1.localPosition.x < -140) mountain1.localPosition = new Vector3(140, -6.8f, 1);
|
|
if(mountain2.localPosition.x < -140) mountain2.localPosition = new Vector3(140, -6.8f, 1);
|
|
}
|
|
|
|
public void Death(GameController.Death deathInfo)
|
|
{
|
|
//相机不再运动
|
|
speed = 0;
|
|
//远景不再运动
|
|
mountain1Speed = 0;
|
|
mountain2Speed = 0;
|
|
}
|
|
|
|
void CreatSth()
|
|
{
|
|
killWall.gameObject.AddComponent<KillWall>();
|
|
}
|
|
|
|
void FindSth()
|
|
{
|
|
killWall = transform.Find("KillWall");
|
|
//killWall = GameObject.Find("KillWall").transform;
|
|
if(killWall == null) Debug.LogError("没找到KillWall,请检查相机是否有叫此名字的子物体");
|
|
mountain1 = transform.Find("远景1");
|
|
mountain2 = transform.Find("远景2");
|
|
}
|
|
|
|
void InitSth(){}
|
|
|
|
|
|
/// <summary>
|
|
/// 每帧调用,向右移动
|
|
/// </summary>
|
|
void Move(){
|
|
transform.position += (Vector3.right * speed * Time.deltaTime);
|
|
}
|
|
class KillWall : MonoBehaviour
|
|
{
|
|
void OnTriggerEnter2D(Collider2D other) {
|
|
if(other.tag == "HorseHead")
|
|
{
|
|
GameController.Death death;
|
|
death.deadReason = GameController.Death.DeadReason.Camera;
|
|
GameController.Instance.GameOver(death);
|
|
}
|
|
}
|
|
|
|
void OnTriggerExit2D(Collider2D other) {
|
|
//Debug.Log("出去了一个:" + other.name);
|
|
switch(other.tag)
|
|
{
|
|
case "Fragment":
|
|
Destroy(other.gameObject);
|
|
break;
|
|
case "Obstacle":
|
|
Destroy(other.gameObject);
|
|
break;
|
|
case "Right" :
|
|
other.transform.parent.position += new Vector3(1,0,0) * 230f;
|
|
break;
|
|
}
|
|
|
|
if(other.gameObject.layer == LayerMask.NameToLayer("Fragment"))
|
|
Destroy(other.gameObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|