学习目标:实现飞机射击核心功能
游戏概述与设计
- 游戏背景:空中战机游戏是一种经典的游戏题材,玩家可以驾驶战机在宽广的天空中与敌人进行战斗。
- 游戏目标:玩家需要扮演战机飞行员,通过操控战机完成各种任务,如击败敌军、保卫友军等。
- 游戏角色:包括玩家角色(战机飞行员)、敌人角色(敌军战机)。
- 游戏地图:设计多个不同的地图,增加游戏的多样性。地图中可以有各种地形,如山脉、海洋、城市等,这些地形会影响玩家的战术选择。
- 游戏关卡:关卡应分为多个难度等级,从简易到困难,逐渐提高游戏的挑战性。每个关卡都有不同的任务目标。
游戏画面
项目结构目录
部分核心代码
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class playermoveA :MonoBehaviour,IPointerUpHandler,IPointerDownHandler,IDragHandler{
//public class playermoveA :MonoBehaviour{//,IPointerUpHandler,IPointerDownHandler,IDragHandler{
public static playermoveA instance;
Vector3 Doenpostion;
public Vector3 Nowdragpostion;
public Vector3 ONdragpostion;
public Vector3 playerpostion;
bool move=false;
public Sprite asd;
// Use this for initialization
void Start () {
instance = this;
}
// Update is called once per frame
void Update () {
}
public void OnPointerUp (PointerEventData eventData)
{
Doenpostion = Vector3.zero;
ONdragpostion = Vector3.zero;
move = false;
}
public void OnPointerDown (PointerEventData eventData)
{
Doenpostion=eventData.position;
move = true;
}
public void OnDrag (PointerEventData eventData)
{
if (move) {
playerpostion=Camera.main.ScreenToWorldPoint(eventData.position);
playerpostion=new Vector3(playerpostion.x,playerpostion.y,0);
ONdragpostion =new Vector3 (Doenpostion.x - eventData.position.x, Doenpostion.y - eventData.position.y, 0);
ONdragpostion.Normalize ();
}
}
}