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. selenium TestNG 依赖和忽略测试

    依赖:通过使用Test 注释的dependsOnMethods={"verifyLogin"}子句,verifyAccountInfo 测试指定了它依赖verifyLogin()方 ...

  2. HBuilder开发移动App——manifest.json文件解析

    以前做过Android App开发,对于各项配置都是在AndroidManifest.xml文件中完成的,包括权限的设定.图标.标签.App的名字.Activity注册等等 使用HBuilder开发移 ...

  3. MyEclipse2015+Tomcat8.0+Maven3.3项目环境搭建

    之前一直用自己的笔记本进行web项目的开发,实验室配了一台台式机,软件和环境都需要重新配置和安装.最近准备用SSM(Spring,SpringMVC,MyBatis)框架编写一个图书管理系统,主要使用 ...

  4. ros中删除某个包之后用apt安装的包找不到

    原因是工作空间devel里还存有原来的二进制可执行文件,将build和devel内容全删除后再catkin_make就好了

  5. 解决center7默认shell不显示完整路径问题

    root用户下执行以下命令: vim ~/.bash_profile 然后屏蔽这两行: #PATH=$PATH:$HOME/bin #export PATH 新加入一下代码: PS1='[\u@\h: ...

  6. yii2中判断值是否存在二维数组中

    //在yii2中,在类里面的函数,可以不加action $arr = array( array('a', 'b'), array('c', 'd') ); in_array('a', $arr); / ...

  7. 打印sql语句方法

    var_dump($this->blackpool_model->getLastSql());

  8. POJ 1240 Pre-Post-erous! && East Central North America 2002 (由前序后序遍历序列推出M叉树的种类)

    题目链接:http://poj.org/problem?id=1240 本文链接:http://www.cnblogs.com/Ash-ly/p/5482520.html 题意: 通过一棵二叉树的中序 ...

  9. 【kd-tree】bzoj3290 Theresa与数据结构

    离线所有操作,对所有可能存在的点建立kd-tree,add相当于权值+1,cancel相当于权值-1. 修改操作要记录kd-tree上每个点的fa,从底向上地进行修改. 优化:若一个矩形框的sumv= ...

  10. 【哈希表】CODEVS1230 元素查找

    #include<cstdio> #include<vector> using namespace std; typedef vector<int>::iterat ...