raft using debug.log rac ans engine 距离 ==
//================================================================
//// Copyright (C)// All Rights Reserved//// Author:小妖精Balous
//
//Summary:啊咧咧,小妖精Balous因为要应付学校的作业,同时要照顾新手程序员,所以把项目改成了东方project同人作了呢~
// 向神主大人致敬!然后,这是段自机代码的初稿呢~~不知米娜桑能不能看得小妖精Balous写的代码呢~~~~////================================================================
using System.Collections;using System.Collections.Generic;using UnityEngine;
public abstract class Player : MonoBehaviour{ public GameObject baseBullet; ///
///
///
if (subCraft != null) { int difference = (int)_power - subCraftList.Count; while (difference > 0) { GameObject subCraftClone = Instantiate(subCraft); subCraftList.Add(subCraftClone.GetComponent
///
///
///
///
public float normalMoveSpeed; public float slowMoveSpeed; private float moveSpeed;
protected virtual void Move() { if (Controller.Slow()) moveSpeed = slowMoveSpeed; else moveSpeed = normalMoveSpeed;
//up,left,down,right int[] direction = new int[4] { 0, 0, 0, 0 }; if (Controller.LeftArrow()) direction[1] = 1; if (Controller.DownArrow()) direction[2] = 1; if (direction[1] == 0 && Controller.RightArrow()) direction[3] = 1; if (direction[2] == 0 && Controller.UpArrow()) direction[0] = 1;
int count = 0; foreach (int i in direction) count += i;
if (count == 0) return; if (count == 1) { if (direction[1] == 1) transform.Translate(Vector3.left * moveSpeed * Time.deltaTime); else if (direction[3] == 1) transform.Translate(Vector3.right * moveSpeed * Time.deltaTime); else if (direction[2] == 1) transform.Translate(Vector3.down * moveSpeed * Time.deltaTime); else transform.Translate(Vector3.up * moveSpeed * Time.deltaTime); } else { if (direction[2] == 1) transform.Translate(Vector3.down * moveSpeed * Time.deltaTime * 0.7071067812f); else if (direction[0] == 1) transform.Translate(Vector3.up * moveSpeed * Time.deltaTime * 0.7071067812f); if (direction[1] == 1) transform.Translate(Vector3.left * moveSpeed * Time.deltaTime * 0.7071067812f); else if (direction[3] == 1) transform.Translate(Vector3.right * moveSpeed * Time.deltaTime * 0.7071067812f); } }
protected virtual void Init() { player = 3; power = 1f; bomb = 3; graze = 0; score = 0; invincibleTime = 3f; shootTime = 0f; bombTime = 0f; _playerFragment = 0; _bombFragment = 0;
subCraftList = new List
protected virtual void Shoot() { GameObject baseBulletClone = Instantiate(baseBullet, transform.position + new Vector3(-0.1f, 0.2f, 0f), Quaternion.identity); Destroy(baseBulletClone, 13f); baseBulletClone = Instantiate(baseBullet, transform.position + new Vector3(0.1f, 0.2f, 0f), Quaternion.identity); Destroy(baseBulletClone, 13f); }
protected abstract void Bomb();
void Start () { Init(); } void Update () { if (invincibleTime > 0f) invincibleTime -= Time.deltaTime; if (bombTime > 0f) bombTime -= Time.deltaTime; if (shootTime > 0f) shootTime -= Time.deltaTime;
Move();
if (shootTime <= 0f && Controller.Shoot() && baseBullet != null) { shootTime += timeInterval; Shoot(); }
if (Controller.BombDown() && bombTime <= 0f) Bomb(); }
private void OnEnable() { if (GameManager.player != null) Debug.LogError("你尝试创建2个Player,这种情况不允许!"); GameManager.player = this; }
private void OnDisable() { GameManager.player = null; }}
小妖精的完美游戏教室——东方project,同人,自机
来源: http://www.bubuko.com/infodetail-2057592.html