╮(╯▽╰)╭没办法,小妖精Balous也很讨厌学院化的教育呀,一点意义都没有。

  这次就上传东方地灵殿灵梦A逻辑部分的核心代码吧,估计连老师都看不懂。动画部分的代码就不放上来了。

 

//================================================================
//
// Copyright (C)
// All Rights Reserved
//
// Author:小妖精Balous
//
//================================================================

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Reimu : Player
{
public GameObject reimuBomb;

protected override void Bomb()
{
invincibleTime = 2.6f;
bombTime = 2.6f;

if (reimuBomb != null)
{
Instantiate(reimuBomb, Vector3.zero, Quaternion.identity);
}
}
}

//================================================================
//
// Copyright (C)
// All Rights Reserved
//
// Author:小妖精Balous
//
//================================================================

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ReimuBomb : MonoBehaviour
{
/// <summary>
/// 消弹倒计时
/// </summary>
private float clearTime;

// Use this for initialization
void Start ()
{
clearTime = 2.6f;
}

// Update is called once per frame
void Update ()
{
clearTime -= Time.deltaTime;

if (clearTime <= 0f)
{
if (GameManager.bulletList.Count > 0)
{
for (var bullet = GameManager.bulletList.First; bullet != null;)
{
var next = bullet.Next;
if (bullet.Value.destructible) Destroy(bullet.Value.gameObject);
bullet = next;
}
}
Destroy(gameObject);
}
}
}

//================================================================
//
// Copyright (C)
// All Rights Reserved
//
// Author:小妖精Balous
//
//================================================================

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ReimuSubCraft : SubCraft
{
private static float normalDistance = 1.1f;
private static float slowDistance = 0.47f;

private static float verticalSpeed = 1.2f;
private static float rotateSpeed = -270f;

public override void Move()
{
transform.RotateAround(GameManager.player.transform.position, Vector3.forward, rotateSpeed * Time.deltaTime);
transform.eulerAngles = Vector3.forward;

//计算子机与自机的距离
float distance = Vector2.Distance(new Vector2(transform.position.x, transform.position.y), new Vector2(GameManager.player.transform.position.x, GameManager.player.transform.position.y));

if (Controller.Slow())
{
if (Mathf.Abs(distance - slowDistance) > 0.03f)
{
Vector2 direction = new Vector2(GameManager.player.transform.position.x - transform.position.x, GameManager.player.transform.position.y - transform.position.y).normalized;
transform.Translate(new Vector3(direction.x, direction.y) * Time.deltaTime * verticalSpeed);
}
}

else
{
if (Mathf.Abs(normalDistance - distance) > 0.03f)
{
Vector2 direction = new Vector2(transform.position.x - GameManager.player.transform.position.x, transform.position.y - GameManager.player.transform.position.y).normalized;
transform.Translate(new Vector3(direction.x, direction.y) * Time.deltaTime * verticalSpeed);
}
}
}

public override void NormalShoot()
{
GameObject normalBulletClone = Instantiate(normalBullet, transform.position + new Vector3(-0.04f, 0.2f, 0f), Quaternion.identity);
Destroy(normalBulletClone, 7f);
normalBulletClone = Instantiate(normalBullet, transform.position + new Vector3(0.04f, 0.2f, 0f), Quaternion.identity);
Destroy(normalBulletClone, 7f);
}

public override void SlowShoot()
{
GameObject slowBulletClone = Instantiate(slowBullet, transform.position + new Vector3(-0.04f, 0.2f, 0f), Quaternion.identity);
Destroy(slowBulletClone, 7f);
slowBulletClone = Instantiate(slowBullet, transform.position + new Vector3(0.04f, 0.2f, 0f), Quaternion.identity);
Destroy(slowBulletClone, 7f);
}
}