zoukankan      html  css  js  c++  java
  • 小妖精的完美游戏教室——东方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;
    }
    }

  • 相关阅读:
    累加和校验算法(CheckSum算法)
    云锵投资 2021 年 09 月简报
    云锵投资 2021 年 08 月简报
    断言与忽略断言
    出现 undefined reference to `cv::String::deallocate()'的解决方法
    about of string
    esp32: A stack overflow in task spam_task has been detected.
    IDEA部署Tomcat报错:No artifacts marked for deployment
    在safari浏览器上使用php导出文件失败
    laravel中使用vue热加载时 Cannot read property 'call' of undefined BUG解决方案
  • 原文地址:https://www.cnblogs.com/balous/p/6917807.html
Copyright © 2011-2022 走看看