//================================================================
//
// Copyright (C)
// All Rights Reserved
//
// Author:小妖精Balous
//
//Summary:哎~小妖精Balous又来应付学院的作业了,感觉这样把别人看不懂的代码发上来也没用啊。
// 或许这就是传说中的学院教育的悲哀?如果有人要使用这段代码,请注明作者是小妖精Balous哟~~
//
//================================================================
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 子机
/// </summary>
public abstract class SubCraft : MonoBehaviour
{
/// <summary>
/// 普通移动时,子机发射的子弹
/// </summary>
public GameObject normalBullet;
/// <summary>
/// 低速移动时,子机发射的子弹
/// </summary>
public GameObject slowBullet;
/// <summary>
/// 子机生成子弹时间间隔
/// </summary>
public float timeInterval;
/// <summary>
/// 距离下次子机子弹生成的剩余时间,大于0f不会生成子弹
/// </summary>
private float shootTime;
public abstract void NormalShoot();
public abstract void SlowShoot();
public abstract void Move();
public virtual void Init()
{
shootTime = 0f;
}
void Start ()
{
Init();
}
void Update ()
{
if (shootTime > 0f) shootTime -= Time.deltaTime;
Move();
if (shootTime <= 0f && Controller.Shoot())
{
shootTime += timeInterval;
if (Controller.Slow() && slowBullet != null) SlowShoot();
else if (normalBullet != null) NormalShoot();
}
}
}