• 小妖精的完美游戏教室——东方PROJECT,同人,符卡系统


    //================================================================
    //
    // Copyright (C) 东方同人社
    // All Rights Reserved
    //
    // Author:小妖精Balous

    //

    //Summary:这次是符卡系统,这个系统能完成绝大多数符卡,算是比较通用的了
    //
    //================================================================

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

    /// <summary>
    /// 符卡,Boss会迅速移动到起始位置,然后进入第一个状态
    /// </summary>
    public class SpellCard : State<Boss>
    {
    /// <summary>
    /// 符卡,Boss会迅速移动到起始位置,然后进入第一个状态
    /// </summary>
    /// <param name="_state">进入符卡后第一个状态</param>
    /// <param name="_startPlace">进入符卡的起始位置</param>
    /// <param name="_spellCardTime">符卡持续时间</param>
    /// <param name="_lifeMax">符卡生命值</param>
    public SpellCard(State<Boss> _state, Vector2 _startPlace, float _spellCardTime, int _lifeMax)
    {
    state = _state;
    startPlace = _startPlace;
    spellCardTime = _spellCardTime;
    lifeMax = _lifeMax;
    }

    private Vector2 startPlace;
    private float spellCardTime;
    private int lifeMax;
    private State<Boss> state;

    private static float moveSpeed = 9.6f;

    public override void Enter(Boss owner)
    {
    owner.lifeMax = lifeMax;
    owner.life = lifeMax;
    owner.invincible = true;
    }

    public override void Execute(Boss owner)
    {
    float distance = Vector2.Distance(new Vector2(owner.transform.position.x, owner.transform.position.y), startPlace);
    if (distance < 0.03f)
    {
    owner.stateMachine.currentState = state;
    return;
    }

    Vector2 direction = new Vector2(startPlace.x - owner.transform.position.x, startPlace.y - owner.transform.position.y).normalized;
    owner.transform.Translate(new Vector3(direction.x, direction.y) * Time.deltaTime * moveSpeed);
    }

    public override void Exit(Boss owner)
    {
    owner.spellCardTime = spellCardTime;
    owner.invincible = false;
    }
    }

  • 相关阅读:
    安卓平台下ARM Mali OpenCL编程-GPU信息检测(转)
    Android 常用的性能分析工具详解:GPU呈现模式, TraceView, Systrace, HirearchyViewer(转)
    windows配置meld
    nginx的学习材料
    nginx+lua组合的web框架
    [转] Linux下防火墙iptables用法规则详及其防火墙配置
    转:关于知乎音视频学习入门的解答
    转: 在创业公司使用C++
    【转】 消息队列设计精要
    转: __asm__ __volatile__内嵌汇编用法简述
  • 原文地址:https://www.cnblogs.com/balous/p/6917807.html
Copyright © 2020-2023  润新知