Exemplo n.º 1
0
    public static EffectPlayer PlayAtPos(GameObject prefab, Vector3 worldPos, System.Action onFinish = null)
    {
        if (!prefab)
        {
            if (onFinish != null)
            {
                onFinish();
            }
            return(null);
        }
        if (!prefab.GetComponent <ParticleSystem>())
        {
            Debug.LogError("没有在预设体" + prefab.name + "上找到ParticleSystem");
            if (onFinish != null)
            {
                onFinish();
            }
            return(null);
        }
        GameObject obj = Instantiate(prefab);

        obj.transform.position = worldPos;
        EffectPlayer player = obj.GetOrAddComponent <EffectPlayer>();

        player.callback     = onFinish;
        player.bPlayOnAwake = true;
        return(player);
    }
Exemplo n.º 2
0
    public static GameObject[] Play(this EffectPlayer effectPlayer, Vector3 position)
    {
        if (effectPlayer == null)
        {
            return(null);
        }

        var newEffects = new GameObject[effectPlayer.effects.Length];

        foreach (var effect in effectPlayer.effects)
        {
            var newEffect = Assets.Clone(effect);
            newEffect.transform.SetParent(EffectPlayer.effectViewContainer, false);
            newEffect.transform.position = position;

            var pfxs          = newEffect.GetComponentsInChildren <ParticleSystem>();
            var totalDuration = 0f;
            foreach (var pfx in pfxs)
            {
                var duration = pfx.startDelay + pfx.startLifetime + pfx.duration;
                if (duration > totalDuration)
                {
                    totalDuration = duration;
                }
            }

            Assets.Destroy(newEffect, totalDuration);
        }

        return(newEffects);
    }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Serializer   ser             = new Serializer();
            Trait        xmlTrait        = ser.Deserialize <Trait>("trait.xml");
            EffectCity   xmlEffectCity   = ser.Deserialize <EffectCity>("effectCity.xml");
            EffectPlayer xmlEffectPlayer = ser.Deserialize <EffectPlayer>("effectPlayer.xml");
            EffectUnit   xmlEffectUnit   = ser.Deserialize <EffectUnit>("effectUnit.xml");

            // Load Trait.xml, then load other XMLs
            // Look for trait in city, player, unit.
            // If found, add to output obj

            OldWorldXmlParser parser = new OldWorldXmlParser();
            var vals = parser.GetArchtypeMetadata();

            foreach (var key in vals)
            {
                Console.WriteLine(key.Key);
                foreach (var val in key.Value)
                {
                    Console.WriteLine($"{val.Key} + {val.Value}");
                }
            }

            Console.Read();
        }
Exemplo n.º 4
0
 public void InitialStartup()
 {
     InputHistory.Initialize();
     InputHandlers.Initialize();
     SettingsManager.Initialize();
     MusicPlayer.Init();
     EffectPlayer.Init();
 }
Exemplo n.º 5
0
 public void InitDotResources(GameObject continueFX, AudioClip continueAC, GameObject effectFX, AudioClip effectAC, GameObject endFX, AudioClip endAC)
 {
     effectContinue      = EffectPlayer.PlayOnTransform(continueFX, Target.BeAtkPoint);
     audioContinue       = AudioSystem.Instance.PlayOnTransform(continueAC, Target.BeAtkPoint);
     objContinueEffectFX = effectFX;
     acContinueEffectSE  = effectAC;
     objEndEffectFX      = endFX;
     acEndEffectSE       = endAC;
 }
Exemplo n.º 6
0
 void Awake()
 {
     effects = GameObject.FindObjectOfType<EffectPlayer>();
     pieces = GameObject.FindObjectsOfType<MoveForward>().ToList();
     player = GameObject.FindObjectOfType<Player>();
     music = GetComponent<MusicManager>();
     score = GetComponent<ScoreManager>();
     instructor = GameObject.FindObjectOfType<Instructor>();
     obstacles = GameObject.Find("Obstacle");
 }
Exemplo n.º 7
0
    protected CastResult OnExucete()
    {
        if (SkillStatus == Status.Casting)
        {
            return(CastResult.IsCasting);
        }
        if (InCD)
        {
            return(CastResult.InCD);
        }
        CastResult result = PreExecute();

        if (result != CastResult.Success)
        {
            return(result);
        }
        result = CanExecute();
        if (result != CastResult.Success)
        {
            return(result);
        }
        if (!IsInRange())
        {
            return(CastResult.OutOfRange);
        }
        for (int i = 0, length = SkillCost.Length; i < length; ++i)
        {
            if (!Master.HasSkillEnergy(SkillCost[i].type, SkillCost[i].value))
            {
                return(CastResult.NoEnergy);
            }
        }

        ClearCastObjs();
        Master.OnSkillStart(this);
        if (CastTime > 0)
        {
            SkillStatus  = Status.Casting;
            fTimeCounter = 0;
            if (CastFX)
            {
                effectCastFx = EffectPlayer.PlayOnTransform(CastFX, CastFXPoint ? CastFXPoint : transform);
            }
            if (CastSE)
            {
                castPlayer = AudioSystem.Instance.PlayOnTransform(CastSE, CastFXPoint ? CastFXPoint : transform);
            }
            Master.Role.PlayAction(CastActionName, 0.1f);
        }
        else
        {
            PrepareCast();
        }
        return(result);
    }
Exemplo n.º 8
0
 public void effectAnimDone(EffectPlayer theEffect, bool loop)
 {
     if (loop)
     {
         theEffect.playEffect(0);
     }
     else
     {
         UnityEngine.Object.Destroy(theEffect);
     }
 }
Exemplo n.º 9
0
 void Explosion()
 {
     if (RigidSelf.velocity.sqrMagnitude < 8)
     {
         return;
     }
     EffectPlayer.PlayAtPos(explosionPath, transform.position);
     if (++_count > 2)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 10
0
    protected override void OnExecute(InteractiveObj self, InteractiveObj target)
    {
        target.DoDamage(new Damage(EffectType, self.CalAtkDamage(EffectBaseValue)), self);
        EffectPlayer.PlayOnTransform(EffectFX, target.BeAtkPoint);
        AudioSystem.Instance.PlayOnTransform(EffectSE, target.BeAtkPoint);

        Debuff_Dot dot = new Debuff_Dot();

        dot.Init(nBuffOrder, nDuration, BuffBase.Type.Debuff, self, target);
        dot.InitDot(nFirstEffectTime, nDuration, EffectType, self.CalAtkDamage(nEffectDamage), self.CalAtkDamage(nEndDamage));
        dot.InitDotResources(objContinueFX, acContinueSE, objContinueEffectFX, acContinueEffectSE, objEndEffectFX, acEndEffectSE);
        target.AddBuff(dot);
    }
Exemplo n.º 11
0
 public void Execute(InteractiveObj self, Vector3 pos)
 {
     GameClient.Instance.NextTick(() =>
     {
         if (!self)
         {
             return;
         }
         EffectPlayer.PlayAtPos(EffectFX, pos);
         AudioSystem.Instance.PlayAtPos(EffectSE, pos);
         OnExecute(self, pos);
     }, EffectDelay / 1000f);
 }
Exemplo n.º 12
0
        /// <summary>
        /// 注册EffectPlayer
        /// </summary>
        /// <param name="refObject">EffectPlayer跟随的物体</param>
        /// <param name="effectPack">和EffectPlayer关联的EffectPack</param>
        /// <returns></returns>
        private EffectPlayer RegisterEffectPlayer(GameObject refObject, EffectPack effectPack, bool isNeedClean)
        {
            EffectPlayer effectPlayer = refObject.AddComponent <EffectPlayer>();

            if (effectPlayer)
            {
                effectPlayer.EffectPack          = effectPack;
                effectPlayer.EffectList          = PreLoadEffects(effectPack);
                effectPlayer.IsObjectNeedDestroy = isNeedClean;
                return(effectPlayer);
            }
            return(null);
        }
Exemplo n.º 13
0
 public void Execute(InteractiveObj self, InteractiveObj target)
 {
     GameClient.Instance.NextTick(() =>
     {
         if (!target)
         {
             return;
         }
         EffectPlayer.PlayOnTransform(EffectFX, target.BeAtkPoint);
         AudioSystem.Instance.PlayAtPos(EffectSE, target.BeAtkPoint.position);
         OnExecute(self, target);
     }, EffectDelay / 1000f);
 }
Exemplo n.º 14
0
 void ClearCastObjs()
 {
     if (effectCastFx)
     {
         effectCastFx.Recycle();
     }
     if (castPlayer)
     {
         castPlayer.Recycle();
     }
     effectCastFx = null;
     castPlayer   = null;
 }
Exemplo n.º 15
0
 public override void DoUpdate(float deltaTime)
 {
     if (RaimainingTime < 0)
     {
         return;
     }
     if ((RaimainingTime -= (int)deltaTime * 1000) < nNextEffectTime)
     {
         Target.DoDamage(new Damage(eEffectType, nDamage), Master);
         nNextEffectTime = RaimainingTime - nEffectInterval;
         EffectPlayer.PlayOnTransform(objContinueEffectFX, Target.BeAtkPoint);
         AudioSystem.Instance.PlayOnTransform(acContinueEffectSE, Target.BeAtkPoint);
     }
 }
Exemplo n.º 16
0
        void OnTriggerEnter(Collider collider)
        {
            if (!collider.CompareTag("Player"))
            {
                return;
            }
            EffectPlayer effect = collider.GetComponent <EffectPlayer>();

            if (effect)
            {
                effect.Play();
            }
            EffectPool.GetFreeObject().GetComponent <PooledEffect>().Activate(transform);
            DeActivate();
        }
Exemplo n.º 17
0
 protected virtual void Settlement(Vector3 pos)
 {
     if (HitFX)
     {
         EffectPlayer.PlayAtPos(HitFX, pos);
     }
     if (HitSE)
     {
         AudioSystem.Instance.PlayAtPos(HitSE, pos);
     }
     SkillEffectBase[] effects = GetComponentsInChildren <SkillEffectBase>(true);
     for (int i = 0, length = effects.Length; i < length; ++i)
     {
         effects[i].Execute(Master, pos);
     }
 }
Exemplo n.º 18
0
 protected override void OnRemove(bool isDead)
 {
     if (effectContinue)
     {
         effectContinue.Recycle();
     }
     if (audioContinue)
     {
         audioContinue.Recycle();
     }
     effectContinue = null;
     audioContinue  = null;
     Target.DoDamage(new Damage(eEffectType, nEndDamage), Master);
     EffectPlayer.PlayOnTransform(objEndEffectFX, Target.BeAtkPoint);
     AudioSystem.Instance.PlayOnTransform(acEndEffectSE, Target.BeAtkPoint);
 }
Exemplo n.º 19
0
 protected void Death()
 {
     HP = 0;
     for (int i = 0, length = listBuff.Count; i < length; ++i)
     {
         listBuff[i].Remove(true);
     }
     listBuff.Clear();
     ForceTarget = CurrentTarget = null;
     dicFightingObjs.Clear();
     AudioSystem.Instance.PlayAtPos(clipDead, transform.position);
     EffectPlayer.PlayAtPos(effectDead, transform.position);
     OnSelfDeath();
     IsAlive = false;
     UIHeadInfo.DoUpdate(0);
     OnDeath.Invoke();
 }
Exemplo n.º 20
0
 protected virtual void Settlement(InteractiveObj target)
 {
     if (!target)
     {
         return;
     }
     if (HitFX)
     {
         EffectPlayer.PlayOnTransform(HitFX, target.BeAtkPoint);
     }
     if (HitSE)
     {
         AudioSystem.Instance.PlayAtPos(HitSE, target.BeAtkPoint.position);
     }
     SkillEffectBase[] effects = GetComponentsInChildren <SkillEffectBase>(true);
     for (int i = 0, length = effects.Length; i < length; ++i)
     {
         effects[i].Execute(Master, target);
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// 注册EffectPlayer
        /// </summary>
        /// <param name="name">EffectPack的名字</param>
        /// <param name="refObject">EffectPlayer跟随的物体</param>
        /// <returns></returns>
        private EffectPlayer RegisterEffectPlayer(GameObject refObject, string name, bool isNeedClean)
        {
            EffectPlayer effectPlayer = refObject.AddComponent <EffectPlayer>();

            if (effectPlayer)
            {
                string effectPackPath = Config.EffectPacksLoadRoot + "/" + name;
                App.ResourceManager.LoadResource <EffectPack>(effectPackPath, (EffectPack effectPack) =>
                {
                    if (effectPack != null)
                    {
                        effectPlayer.EffectPack          = effectPack;
                        effectPlayer.EffectList          = PreLoadEffects(effectPack);
                        effectPlayer.IsObjectNeedDestroy = isNeedClean;
                    }
                });
                return(effectPlayer);
            }
            return(null);
        }
Exemplo n.º 22
0
    /// <summary>
    /// 远程攻击
    /// </summary>
    /// <param name="effectName"></param>
    /// <param name="to"></param>
    private void OnRemoteAttack(string effectName, object[] args)
    {
        var to   = (Vector2)args[1];
        var from = (Vector2)args[0];

        if (m_pieceAnimator == null)
        {
            m_pieceAnimator = pieceModel.GetComponent <Animator>();
        }
        m_pieceAnimator.Play("Attack");

        EffectPlayer effectPlayer = App.EffectManager.LoadEffect(m_Attack, effectName);

        effectPlayer.IsOnce = true;

        TweenPlayer m_AttackPlayer = m_Attack.AddComponent <TweenPlayer>();
        var         steps          = CalMoveSteps(from, to);
        Tween       attackTween    = m_AttackPlayer.AddClip("attack", steps * Config.AttackStepTime);

        attackTween.SetTweenType(TweenType.LocalPosition);
        attackTween.SetDelayTime(0.8f);
        attackTween.SetOnComplete(OnRemoteAttackComplete, args);

        App.SoundManager.PlaySoundClip(Config.Sound.MagicAttack, 0.6f);

        var dx = Config.PieceWidth * (to.x - m_X);
        var dy = Config.PieceWidth * (to.y - m_Z);

        attackTween.SetTo(new Vector3(dx, m_Attack.transform.localPosition.y, dy));
        var angle      = GetAngleByDeltaXY(dx, dy);
        var localAngle = (angle) % 360;

        m_AttackPlayer.gameObject.transform.rotation = Quaternion.Euler(0, localAngle, 0);
        //if (pieceColor == Config.PieceColor.WHITE)
        //{
        //    effectPlayer.LocalRotation = Quaternion.Euler(0, 180, 0);
        //}
        effectPlayer.enabled = true;
        m_AttackPlayer.StartPlay();
    }
Exemplo n.º 23
0
        public void PlaySkill(EffectPlayer player)
        {
#if false
            var trans = player.GetCustom <Utility.Timeline.TransformTweenSetter>();

            // 座標から取得する
            var startPos = _mapManager.CurrentTilemap.GetCellCenterWorld(new Vector3Int(_xStartPos, _yStartPos, 0));
            trans.SetStartPosition(startPos);

            var endPos = _mapManager.CurrentTilemap.GetCellCenterWorld(new Vector3Int(_xEndPos, _yEndPos, 0));
            trans.SetEndPosition(endPos);

            // デバッグを閉じてから再生
            _debugManager.Close();

            // 0.2秒後に再生
            Observable.Timer(TimeSpan.FromSeconds(1))
            .Subscribe(_ =>
            {
                player.Play();
            });
#endif
        }
Exemplo n.º 24
0
        void OnTriggerEnter(Collider collider)
        {
            if (!collider.CompareTag("Player"))
            {
                return;
            }
            EffectPlayer effect = collider.GetComponent <EffectPlayer>();

            if (effect)
            {
                effect.Play();
            }
            if (gamePanel_ != null)
            {
                gamePanel_.changeGameTime(collisionAddTime_);
                gamePanel_.changeGameScore(collisionAddScore_);
            }



            EffectPool.GetFreeObject().GetComponent <PooledEffect>().Activate(transform);
            DeActivate();
        }
Exemplo n.º 25
0
    protected override CastResult OnCast()
    {
        for (int i = 0, length = Random.Range(MissleMinCount, MissleMaxCount + 1); i < length; ++i)
        {
            if (ReleaseFX)
            {
                EffectPlayer.PlayOnTransform(ReleaseFX, ReleaseFXPoint);
            }
            if (ReleaseSE)
            {
                AudioSystem.Instance.PlayOnTransform(ReleaseSE, ReleaseFXPoint);
            }
            Missle missle = Instantiate(MisslePrefab, transform.position, transform.rotation).GetOrAddComponent <Missle>();
            switch (LockType)
            {
            case SkillLockType.Position:
                switch (MissleType)
                {
                case Type.Bullet:
                    missle.InitBullet(TargetPos, MissileSpeed, Settlement);
                    break;

                default:
                    missle.Init(TargetPos, MissileSpeed, Settlement);
                    break;
                }
                break;

            case SkillLockType.NoLock:
                switch (MissleType)
                {
                case Type.Bullet:
                    //missle.InitBullet(TargetPos, MissileSpeed, Settlement);
                    break;

                default:
                    missle.gameObject.AddComponent <SphereCollider>().isTrigger = true;
                    missle.gameObject.AddComponent <Rigidbody>().isKinematic    = true;
                    missle.InitFlyFront(Master.transform.forward, MissileSpeed, SkillMaxRange, (hitObj, missleScript) =>
                    {
                        if (hitObj)
                        {
                            InteractiveObj target = hitObj.GetComponent <InteractiveObj>();
                            if (target)
                            {
                                if (target.IsAlive && target.IsEnemy(Master.Camp))
                                {
                                    Settlement(target);
                                    Destroy(missleScript.gameObject);
                                }
                                return;
                            }
                            Q_SceneObj sceneObj = hitObj.GetComponent <Q_SceneObj>();
                            if (sceneObj)
                            {
                                switch (sceneObj.objType)
                                {
                                case Q_SceneObj.Type.Skill:
                                case Q_SceneObj.Type.Item:
                                case Q_SceneObj.Type.NeedItem:
                                    break;

                                default:
                                    return;
                                }
                            }
                        }
                        if (HitFX)
                        {
                            EffectPlayer.PlayAtPos(HitFX, missleScript.transform.position);
                        }
                        if (HitSE)
                        {
                            AudioSystem.Instance.PlayAtPos(HitSE, missleScript.transform.position);
                        }
                        missleScript.Alive = false;
                        Destroy(missleScript.gameObject);
                    });
                    break;
                }
                break;

            default:
                if (Target)
                {
                    missle.Init(Target.transform, MissileSpeed, (tsf) => Settlement(tsf.GetComponent <InteractiveObj>()));
                }
                else
                {
                    missle.Init(TargetPos, MissileSpeed, Settlement);
                }
                break;
            }
            missle.SetLifeTime(MissleLifeTime);
            if (FlySE)
            {
                AudioSystem.Instance.PlayOnTransform(FlySE, missle.transform);
            }
        }
        return(CastResult.Success);
    }
Exemplo n.º 26
0
        public Dictionary <string, Dictionary <string, object> > GetArchtypeMetadata()
        {
            var          retDict         = new Dictionary <string, Dictionary <string, object> >();
            Serializer   ser             = new Serializer();
            Trait        xmlTrait        = ser.Deserialize <Trait>("trait.xml");
            EffectCity   xmlEffectCity   = ser.Deserialize <EffectCity>("effectCity.xml");
            EffectPlayer xmlEffectPlayer = ser.Deserialize <EffectPlayer>("effectPlayer.xml");
            EffectUnit   xmlEffectUnit   = ser.Deserialize <EffectUnit>("effectUnit.xml");
            var          listOfArchtypes = GetArchtypes(xmlTrait);

            foreach (var archtype in listOfArchtypes)
            {
                var traitEntry    = xmlTrait.Entries.First(a => a.Name.Contains(archtype));
                var archtypeStats = new Dictionary <string, object>();

                // LeaderEffectPlayer - EffectPlayer (applies global)
                // GeneralEffectUnit - EffectUnit (applies bonuses to the unit it is controlling.)
                // LeaderEffectUnit - EffectUnit (not sure)
                // GovernorEffectCity - EffectCity (governor)


                if (traitEntry.LeaderEffectPlayer != null)
                {
                    //var newdict = GetLeaderEffectPlayer(zealotEntry, xmlEffectPlayer);
                    var effPlayerEntry = xmlEffectPlayer.Entries.First(a => a.zType == traitEntry.LeaderEffectPlayer);
                    var newdict        = GetKeyValuesFromXml(effPlayerEntry);
                    archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value);
                }
                if (traitEntry.GeneralEffectUnit != null)
                {
                    var effPlayerEntry = xmlEffectUnit.Entries.First(a => a.zType == traitEntry.GeneralEffectUnit);
                    var newdict        = GetKeyValuesFromXml(effPlayerEntry);
                    archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value);
                }
                if (traitEntry.LeaderEffectUnit != null)
                {
                    var effPlayerEntry = xmlEffectUnit.Entries.First(a => a.zType == traitEntry.LeaderEffectUnit);
                    var newdict        = GetKeyValuesFromXml(effPlayerEntry);
                    archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value);
                }
                if (traitEntry.GovernorEffectCity != null)
                {
                    var effPlayerEntry = xmlEffectCity.Entries.First(a => a.zType == traitEntry.GovernorEffectCity);
                    var newdict        = GetKeyValuesFromXml(effPlayerEntry);
                    archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value);
                }

                List <string> removeProcessedKeys           = new List <string>();
                Dictionary <string, object> postProcessDict = new Dictionary <string, object>();
                // Post process elements.
                foreach (var stat in archtypeStats)
                {
                    if (stat.Key.Contains("EffectCity"))
                    {
                        var entry       = xmlEffectCity.Entries.First(a => a.zType == (string)stat.Value);
                        var childValues = GetKeyValuesFromXml(entry);
                        foreach (var childval in childValues)
                        {
                            postProcessDict[childval.Key] = childval.Value;
                        }
                        removeProcessedKeys.Add("EffectCity");
                    }
                }

                removeProcessedKeys.ForEach(a => archtypeStats.Remove(a));
                archtypeStats = archtypeStats.Concat(postProcessDict).ToDictionary(x => x.Key, x => x.Value);

                retDict[archtype] = archtypeStats;
            }


            return(retDict);
        }
Exemplo n.º 27
0
 public void effectAnimDone(EffectPlayer theEffect, bool loop)
 {
     if (loop)
     {
         theEffect.playEffect(0);
     }
     else
     {
         UnityEngine.Object.Destroy(theEffect);
     }
 }
Exemplo n.º 28
0
 public void locator(EffectPlayer effect, AnimLocator loc)
 {
 }
Exemplo n.º 29
0
 private void Awake()
 {
     self = this;
 }
Exemplo n.º 30
0
 public void locator(EffectPlayer effect, AnimLocator loc)
 {
 }
Exemplo n.º 31
0
 private void Awake()
 {
     _instance = this;
 }
Exemplo n.º 32
0
 public static void Initialize(IHellevator hardware)
 {
     hw = hardware;
     elevator = new EffectPlayer(hardware.ElevatorEffects);
     ceiling = new SolidColorPlayer(hardware.CeilingEffects);
 }