Esempio n. 1
0
    public static void Shake(string name, float _time, float scale, float speed)
    {
        AssetInfo infor = null;

        if (!assetList.TryGetValue(name, out infor))
        {
            //"effect_zhenping_zuoyou"
            //"effect_zhenping_shangxia"
            //"effect_zhenping_yuanquan"
            assetList[name] = AssetLoader.GetInstance().PreLoad(URLUtil.GetEffectPath(name));
            return;
        }
        if (infor.isDone())
        {
            GameObject g    = GameObject.Instantiate(infor.bundle.mainAsset) as GameObject;
            Animation  anim = g.GetComponent <Animation>();
            if (null == anim || anim.clip == null)
            {
                GameObject.Destroy(g);
                return;
            }
            anim[anim.clip.name].normalizedSpeed = speed;

            g.transform.localScale = new Vector3(scale, scale, scale);
            GameObject c = new GameObject("aim");
            c.transform.parent = g.transform;
            DestoryObject dos = g.AddComponent <DestoryObject>();
            dos.delta = _time;
            shakeObjects.Add(c);
        }
    }
    /// <summary>
    /// 激活行为.
    /// </summary>
    public override void Active()
    {
        //FxAsset assert = new FxAsset();
        //assert.init(URLUtil.GetResourceLibPath() + buffInfor.BuffPath);

        base.Active();
        KParams kParams = KConfigFileManager.GetInstance().GetParams();

        outColor         = KingSoftCommonFunction.StringToColor(kParams.MonsterOutColor);
        totalTime        = kParams.MonsterOutTime;
        MonsterOutHeight = kParams.MonsterOutHeight;
        if (kParams.MonsterOutFx.Length > 0)
        {
            assert.init(URLUtil.GetResourceLibPath() + kParams.MonsterOutFx);
            GameObject fx = assert.CloneObj();
            if (null != fx)
            {
                fx.transform.position   = hero.Position;
                fx.transform.localScale = hero.transform.localScale * kParams.MonsterOutFxScale;
                DestoryObject d = fx.AddComponent <DestoryObject>();
                d.delta = 1f;
            }
        }
        hero.DispatchEvent(ControllerCommand.CrossFadeAnimation, "idle1", AMIN_MODEL.ONCE, false);
        isFinish = false;
        hero.DispatchEvent(ControllerCommand.CLEAR_BUFF);
        beginTime = Time.realtimeSinceStartup;
    }
Esempio n. 3
0
    public void PlaySound3d(string res_path, Vector3 pos)
    {
        AudioClip clip = null;

        if (audios.TryGetValue(res_path, out clip))
        {
            if (clip != null)
            {
                GameObject g = new GameObject("audio_" + res_path);
                //g.transform.position = pos;
                g.transform.position = Camera.main.transform.position;
                AudioSource _as = g.AddComponent <AudioSource>();
                _as.volume = volume;
                _as.clip   = clip;
                _as.Play();
                DestoryObject dot = g.AddComponent <DestoryObject>();
                dot.delta = 5f;
            }
        }
        else
        {
            AssetInfo infor = AssetLoader.GetInstance().Load(
                URLUtil.GetResourceLibPath() + "Audio/" + res_path,
                LoadAudioClipComplete, AssetType.BUNDLER, false,
                AssetLoaderLevel.IMMEDIATELY
                );
            urls[infor] = res_path;
        }
    }
 private void LoadLevelUpComplete(AssetInfo info)
 {
     try
     {
         if (null != SceneLogic.GetInstance().MainHero&& null != info.bundle.mainAsset)
         {
             GameObject fx = GameObject.Instantiate(info.bundle.mainAsset) as GameObject;
             fx.transform.parent        = SceneLogic.GetInstance().MainHero.transform;
             fx.transform.localPosition = Vector3.zero;
             KingSoftCommonFunction.SetLayer(fx, 11);
             DestoryObject d = fx.AddComponent <DestoryObject>();
             d.delta = 5f;
         }
     }
     catch (System.Exception e)
     {
     }
 }
Esempio n. 5
0
 public void PlayEndFx(float second)
 {
     if (displayInfor.EndEffect.Length > 0)
     {
         AssetInfo inf = AssetLoader.GetInstance().Load(URLUtil.GetResourceLibPath() + displayInfor.EndEffect);
         if (inf.isDone(false))
         {
             EndFxObj = inf.CloneGameObject();
             EndFxObj.transform.parent        = hero.transform;
             EndFxObj.transform.localPosition = Vector3.zero;
             ObjectUtil.SetTagWithAllChildren(EndFxObj, CameraLayerManager.GetInstance().GetMissionSignName());
             if (displayInfor.EndEffectBindPoint.Length == 0 || displayInfor.BeginEffectBindPoint.CompareTo("Ground") == 0)
             {
                 EndFxObj.transform.localRotation = Quaternion.identity;
                 EndFxObj.transform.localScale    = Vector3.one;
             }
             else
             {
                 Transform t = hero.GetChildTransform(displayInfor.BeginEffectBindPoint);
                 if (null != t)
                 {
                     EndFxObj.transform.parent        = t;
                     EndFxObj.transform.localPosition = Vector3.zero;
                     EndFxObj.transform.localRotation = Quaternion.identity;
                     EndFxObj.transform.localScale    = Vector3.one;
                     EndFxObj.transform.parent        = hero.transform;
                 }
             }
             if (!displayInfor.EndEffectBind)
             {
                 EndFxObj.transform.parent = hero.transform.parent;
             }
             ParticleSystemScaleManager.ScaleParticle(EndFxObj);
             KingSoftCommonFunction.SetLayer(EndFxObj, 11);
             EndFxObj.SetActive(true);
             DestoryObject dos = EndFxObj.AddComponent <DestoryObject>();
             dos.delta = second;
         }
     }
     if (hitTicker.isPlaying())
     {
         OnHit();
     }
 }
Esempio n. 6
0
        //播放战斗效果
        public void PlayFightEffect(ushort wSkillID, int damage, byte byAttackEvent, SceneEntity killerHero)
        {
            if (byAttackEvent == (byte)KAttackEvent.aeMiss)
            {
                if (Owner.property.isMainHero)
                {
                    Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "2", "FightFont", "effect_ui_shuzitanchu_putong.res");
                }
                else
                {
                    Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "1", "FightFont", "effect_ui_shuzitanchu_putong.res");
                }
                return;
            }
            else if (byAttackEvent == (byte)KAttackEvent.aeCrit)
            {
                Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "+" + damage, "CritFont", "effect_ui_shuzitanchu_baoji2.res");
            }
            else if (Owner.property.isMainHero)
            {
                Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "+" + damage, "HurtFont", "effect_ui_shuzitanchu_putong.res", NumTip.OFFSET_TYPE.LEFT);
            }
            else
            {
                Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "+" + damage, "AttackFont", "effect_ui_shuzitanchu_putong.res");
            }
            KSkillDisplay skillDisplay = KConfigFileManager.GetInstance().GetSkillDisplay(wSkillID, Owner.TabID);

            if (skillDisplay.OnHitAction.CompareTo("JUMP") == 0)
            {
                ActionBeAttactedAndThrowUp action = new ActionBeAttactedAndThrowUp(Owner);
                action.hitAnim     = skillDisplay.OnHitAnim;
                action.time        = skillDisplay.OnHitEffecTime;
                action.height      = skillDisplay.OnHitHeight;
                Owner.ActiveAction = action;
                //action
            }
            else if (Owner.property.heroObjType == KHeroObjectType.hotMonster && Owner.heroSetting.MonsterGrade == KMonsterGrade.mgQuestBoss)
            {
                if (Owner.property.activeAction.TryFinish())
                {
                    ActiionBeAttack beAttack = new ActiionBeAttack(Owner);
                    Owner.DispatchEvent(ControllerCommand.SetActiveAction, beAttack);
                }
            }
            else
            {
                Owner.DispatchEvent(ControllerCommand.BE_HIT);
            }

            Vector3 forward = Vector3.forward;

            if (null != killerHero)
            {
                forward = killerHero.transform.position - Owner.transform.position;
                forward = new Vector3(forward.x, 0, forward.z);
                forward.Normalize();
            }
            if (skillDisplay.HitShakeTime > 0 && skillDisplay.HitShakeDelta > 0)
            {
                Owner.DispatchEvent(ControllerCommand.HIT_SLOW, skillDisplay.HitShakeTime, skillDisplay.HitShakeDelta);
            }

            if (null != skillDisplay && skillDisplay.HitEffect.Length > 0 /*&& skillDisplay.BulletEffect.Length == 0*/)
            {
                AssetInfo inf = AssetLoader.GetInstance().Load(URLUtil.GetResourceLibPath() + skillDisplay.HitEffect);
                if (inf.isDone(false))
                {
                    if (skillDisplay.SingleHitFx)
                    {
                        GameObject _hit = null;
                        if (hitFxs.TryGetValue(skillDisplay.HitEffect, out _hit))
                        {
                            GameObject.Destroy(_hit);
                        }
                    }
                    GameObject hitObject = inf.CloneGameObject();
                    ObjectUtil.SetTagWithAllChildren(hitObject, CameraLayerManager.GetInstance().GetMissionSignName());
                    hitObject.transform.parent   = Owner.transform.parent;
                    hitObject.transform.position = Owner.transform.position;
                    hitObject.transform.forward  = forward;
                    if (skillDisplay.SingleHitFx)
                    {
                        hitFxs[skillDisplay.HitEffect] = hitObject;
                    }
                    KingSoftCommonFunction.SetLayer(hitObject, 11);
                    DestoryObject dos = hitObject.AddComponent <DestoryObject>();
                    dos.delta = 5;
                    if (skillDisplay.HitBindPoint.Length > 0)
                    {
                        if (skillDisplay.HitBindPoint.CompareTo("Ground") != 0)
                        {
                            Transform t = Owner.GetChildTransform(skillDisplay.HitBindPoint);
                            if (null != t)
                            {
                                hitObject.transform.parent        = t;
                                hitObject.transform.localPosition = Vector3.zero;
                                hitObject.transform.localScale    = Vector3.one;
                            }
                        }
                    }
                    hitObject.SetActive(true);
                }
            }
        }