1. 程式人生 > >小妖精的完美遊戲教室——東方PROJECT,同人,th12靈夢A

小妖精的完美遊戲教室——東方PROJECT,同人,th12靈夢A

ant static use game del null mon tor lec

  ╮(╯▽╰)╭沒辦法,小妖精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);
}
}

小妖精的完美遊戲教室——東方PROJECT,同人,th12靈夢A