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;
    }
    }

  • 相关阅读:
    hdu4738(双连通分量)
    hdu4635(强连通缩点)
    hdu4612(双连通缩点+树的直径)
    poj3177(边双连通分量+缩点)
    poj3694(tarjan缩点+lca)
    hdu5171(矩阵快速幂)
    uva796(求桥数目)
    uva315(求割点数目)
    POJ1058 The Gourmet Club
    POJ1057 FILE MAPPING
  • 原文地址:https://www.cnblogs.com/balous/p/6917807.html
Copyright © 2011-2022 走看看