小妖精的完美游戏教室——东方PROJECT,同人,符卡系统
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小妖精的完美游戏教室——东方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;
}
}
以上是关于小妖精的完美游戏教室——东方PROJECT,同人,符卡系统的主要内容,如果未能解决你的问题,请参考以下文章