zoukankan      html  css  js  c++  java
  • 小妖精的完美游戏教室——东方PROJECT,同人,th12灵梦A

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

  • 相关阅读:
    tfidf 问题
    Win32汇编窗口程序设计[03]第一个窗口程序
    Win32汇编窗口程序设计[01]开发环境的搭建
    Win32汇编窗口程序设计[02]RadASM简介
    寄存器引用结构体变量
    始终居中的弹出层
    JSonJavaScript
    json
    <收录>jqueryuidatapicker生成的页面html
    网站数据抓取
  • 原文地址:https://www.cnblogs.com/balous/p/6875563.html
Copyright © 2011-2022 走看看