using UnityEngine;
using System.Collections; public class EffectManager : MonoBehaviour { public Animator[] Animators;
public float amplify;
public float curAmplify;
public float totalEffectDelayTime;
public Transform MoveTarget; public ParticleEffect particleEffect;
public AnimatorOffsetChangeEffect animatorOffsetChangeEffect;
public AnimatorMeshChangeEffect animatorMeshChangeEffect;
public enum EffectType
{
Particles,
AnimatorOffsetChange,
AnimatorMeshChange
} public EffectType effectType; void Start ()
{
SetEffectSpeed();
EffectMoveToTarget();
} void Update ()
{ } void OnEnable()
{
if (animatorOffsetChangeEffect.middleEffectNode.rootNode != null)
{
animatorOffsetChangeEffect.middleEffectNode.rootNode.transform.position =
animatorOffsetChangeEffect.frontEffectNode.rootNode.transform.position;
animatorOffsetChangeEffect.middleEffectNode.rootNode.SetActive(true);
}
Start();
} private bool isFirst = true;
public void SetEffectSpeed()
{
//for (int i = 0; i < ParticlesSetStartDelay.Length; i++) {
// ParticlesSetStartDelay[i].startDelay /=amplify;
//} //for (int i = 0; i < ParticlesSetDuration.Length; i++) {
// ParticlesSetDuration[i].startLifetime /=amplify;
//} if (isFirst)
{
isFirst = false;
}
else
return;
Effect effect; if (effectType == EffectType.Particles)
{
effect = particleEffect;
if (effect.middleEffectNode != null)
{
for (int i = ; i < effect.middleEffectNode.Particles.Length; i++)
{
effect.middleEffectNode.Particles[i].startSpeed *= amplify;
}
} }
else if (effectType == EffectType.AnimatorOffsetChange)
{ effect = animatorOffsetChangeEffect;
for (int i = ; i < Animators.Length; i++)
{
Animators[i].speed *= amplify;
}
if (effect.middleEffectNode != null)
{
effect.middleEffectNode.durationTime /= amplify;
effect.middleEffectNode.startDelayTime /= amplify;
} }
else
{
effect = animatorMeshChangeEffect;
for (int i = ; i < Animators.Length; i++)
{
Animators[i].speed *= amplify;
} }
if (effect.frontEffectNode != null)
{
for (int i = ; i < effect.frontEffectNode.Particles.Length; i++)
{
effect.frontEffectNode.Particles[i].startDelay /= amplify;
effect.frontEffectNode.Particles[i].startLifetime /= amplify;
}
}
if (effect.lastEffectNode != null)
{
for (int i = ; i < effect.lastEffectNode.Particles.Length; i++)
{
effect.lastEffectNode.Particles[i].startDelay /= amplify;
effect.lastEffectNode.Particles[i].startLifetime /= amplify;
}
}
} public void EffectMoveToTarget()
{
if (effectType == EffectType.Particles)
{
particleEffect.EffectMoveToTarget(MoveTarget);
}
else if (effectType == EffectType.AnimatorOffsetChange)
{
animatorOffsetChangeEffect.EffectMoveToTarget(MoveTarget);
}
else
{
animatorMeshChangeEffect.EffectMoveToTarget(MoveTarget);
}
//Debug.Log(frontEffectTime);
//Hashtable args = new Hashtable();
//args.Add("position", MoveTarget.position);
//args.Add("time", middleEffectTime);
//args.Add("delay", frontEffectTime);
//args.Add("easeType", iTween.EaseType.easeInQuad); ////args.Add("isLocal", true);
//iTween.MoveTo(MiddleEffect, args);
//LastEffect.transform.position = MoveTarget.transform.position;
}
private void middleEffectNodeReachEvent()
{
animatorOffsetChangeEffect.middleEffectNode.rootNode.SetActive(false);
}
} [System.Serializable]
public class EffectNode
{
public GameObject rootNode;
public ParticleSystem[] Particles;
public float startDelayTime;
public float durationTime;
} public abstract class Effect
{
public EffectNode frontEffectNode;
public EffectNode middleEffectNode;
public EffectNode lastEffectNode; public abstract void EffectMoveToTarget(Transform target); } [System.Serializable]
public class AnimatorOffsetChangeEffect : Effect
{
public override void EffectMoveToTarget(Transform target)
{
//middleEffectNode.rootNode.transform.LookAt(target);
Hashtable args = new Hashtable();
args.Add("position", target.position);
args.Add("time", middleEffectNode.durationTime);
args.Add("delay", middleEffectNode.startDelayTime);
args.Add("easeType", iTween.EaseType.linear);
//args.Add("looktarget", target.position);
if (isHideMiddle)
{
args.Add("oncomplete", "middleEffectNodeReachEvent");
args.Add("oncompletetarget", frontEffectNode.rootNode.transform.parent.gameObject);
}
iTween.MoveTo(middleEffectNode.rootNode, args);
lastEffectNode.rootNode.transform.position = target.position;
} public bool isHideMiddle;
} [System.Serializable]
public class ParticleEffect : Effect
{
public override void EffectMoveToTarget(Transform target)
{
middleEffectNode.rootNode.transform.LookAt(target);
float dis = Vector3.Distance(frontEffectNode.rootNode.transform.position, target.position);
middleEffectNode.Particles[].startSpeed = dis / middleEffectNode.durationTime;
lastEffectNode.rootNode.transform.position = target.position;
}
} [System.Serializable]
public class AnimatorMeshChangeEffect : Effect
{
public override void EffectMoveToTarget(Transform target)
{
Vector3 dirV = (target.position - middleEffectNode.rootNode.transform.position).normalized;
middleEffectNode.rootNode.transform.right = dirV;
lastEffectNode.rootNode.transform.position = target.position; }
}
using UnityEngine;
using System.Collections; public class ShowParticleCout : MonoBehaviour {
//定义发射器组件
//粒子数量接受变量
ParticleSystem a = null;
public int banjing=;
int a_particleCout=;
// Use this for initialization
void Start () {
a = GetComponent<ParticleSystem>();
} // Update is called once per frame
void Update () {
if(a !=null){
//Debug.Log("粒子数:"+ a.particleCount);
a_particleCout=a.particleCount;
}
}
public int getParticleCout(){
//返回粒子数
return a_particleCout;
}
void OnGUI() {
string showParticleCout = "粒子数是:" + a_particleCout;
GUI.Label(new Rect(, ,showParticleCout.Length * , ),showParticleCout +"\r\n asdfasdfa" );
} }
using UnityEngine;
using System.Collections; public class Delay : MonoBehaviour { public float delayTime = 1.0f; // Use this for initialization
void Start () {
gameObject.SetActiveRecursively(false);
Invoke("DelayFunc", delayTime);
} void DelayFunc()
{
gameObject.SetActiveRecursively(true);
} }

EffectManager的更多相关文章

  1. FLEX 特效

    一.简介: flex特效是ria应用程序的rich的重要组成部分. EffectManager类管理所有的特效实例以避免不必要的定时器和方法调用造成的内内存使用过大.一个效果由两部分组成:一是效果的E ...

  2. Unity目录结构设置

    摄像机 Main Camera 跟随主角移动,不看 UI 剧情摄像机 当进入剧情时,可以关闭 main camera,启用剧情摄像机,不看 UI UI 摄像机 看 UI Unity编辑器常用的sett ...

  3. Unity 笔记

    摄像机 Main Camera 跟随主角移动,不看 UI 剧情摄像机 当进入剧情时,可以关闭 main camera,启用剧情摄像机,不看 UI UI 摄像机 看 UI Unity编辑器常用的sett ...

随机推荐

  1. rest_framework 权限流程

    权限流程 权限流程与认证流程非常相似,只是后续操作稍有不同 当用户访问是 首先执行dispatch函数,当执行当第二部时: #2.处理版本信息 处理认证信息 处理权限信息 对用户的访问频率进行限制 s ...

  2. 第一步:Java开发环境的配置

    一.下载JDK 下载地址:www.oracle.com.如下图: 二.配置JDK 安装JDK一直点击下一步就可以,默认是安装在C盘里.如下图: 然后配置系统路径(主要目的是方便开发),参考地址:jin ...

  3. 【转】Ubuntu 14.04.3上配置并成功编译Android 6.0 r1源码

    http://www.linuxidc.com/Linux/2016-01/127292.htm 终于成功把Android 6.0 r1源码的源码编译.先上图,这是在Ubuntu中运行的Android ...

  4. ubuntu fcitx google 输入法打不出中括号【】

    编辑/usr/share/fcitx/data/punc.mb.zh_CN, 将 [ · ] 「 」 这部分改成自己习惯的: [  [ ]  ] 保存后,重启一下fcitx就OK了.

  5. shell脚本学习(二)

    shell传递参数 shell脚本在执行是可以传递参数,脚本内获取参数的格式为:$n,n为一个数字,1为第一个参数,2为第二个参数,以此类推 其中,$0代表了要执行的文件名 实例: 代码如下: #!/ ...

  6. Python3 list与循环练习(购物车)

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author;Tsukasa product_list = [ ('Iphone',5800), (' ...

  7. 15、Django实战第15天:我要学习咨询

    今天完成的是课程机构列表页面的最后一个模块:我要学习 我们在models中创建对应的表时UserAsk.之前我们讲过:在做表单的时候,我们可以通过forms先对提交的数据做验证,之前我们使用的是For ...

  8. tomcat官网

    http://tomcat.jaxmao.org/appdev/index.html 配置 http://www.cnblogs.com/starhu/p/5599773.html

  9. spark DiskBlockManager

    RDD本身presist可以是本地存储,本地存储级别的持久化实现方式如下: DiskBlockManager负责管理和维护block和磁盘存储的映射关系,通过blockId作为文件名称,然后如果是多个 ...

  10. 静态html分页

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...