Ejemplo n.º 1
0
    private static X2DEffect CreateNewX2DEffect(X2DEffect org, Transform parent)
    {
        X2DEffect effect = GameObject.Instantiate <X2DEffect>(org);

        effect.transform.parent        = parent;
        effect.transform.localPosition = Vector3.zero;
        effect.transform.localRotation = Quaternion.identity;
        effect.gameObject.SetActive(true);
        return(effect);
    }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        X2DEffect effect = target as X2DEffect;

        //if(GUILayout.Button("UpdateDuration", GUILayout.Width(120)))
        if (effect.autoDuration)
        {
            UpdateEffectDurationInEditor(effect);
        }
    }
Ejemplo n.º 3
0
    public static X2DEffect GetX2DEffect(string animationName, Transform parent)
    {
        X2DEffect prefab = Resources.Load <X2DEffect>(x2DEffectsFolder + animationName);

        if (prefab == null)
        {
            Debug.LogError("X2DEffect is not exist: " + x2DEffectsFolder + animationName);
        }
        else
        {
            return(CreateNewX2DEffect(prefab, parent));
        }
        return(null);
    }
Ejemplo n.º 4
0
    private void UpdateEffectDurationInEditor(X2DEffect effect)
    {
        //把最后结束的那个结束时间作为持续时间
        X2DEffectClip[] clipArray = effect.GetComponentsInChildren <X2DEffectClip>(true);
        effect.clipArray = clipArray;
        //剪辑名字排列
        float t = 0;

        for (int i = 0; i < clipArray.Length; i++)
        {
            if (t < clipArray[i].startTime + clipArray[i].duration)
            {
                t = clipArray[i].startTime + clipArray[i].duration;
            }
        }
        effect.duration = t;
    }
Ejemplo n.º 5
0
    public void StartAttack(SkillBase skill, ActorBase actor, DBSkillAttackConf attackConf)
    {
        //Debug.Log("Do attack: " + attackConf.ID);
        isAttackObjectMoving = false;
        isAllDamageEnd       = false;
        isEffectPlayEnd      = false;

        this.skill = skill;

        damageConfArray = new DBSkillDamageConf[attackConf.damages.Length];
        for (int i = 0; i < attackConf.damages.Length; i++)
        {
            damageConfArray[i] = DBSkillDamageTable.GetRecord(attackConf.damages[i]);
        }

        if (!string.IsNullOrEmpty(attackConf.attackObjectName))
        {
            eo = EffectManager.GetEffect(attackConf.attackObjectName, null);
            eo.effectObject.gameObject.SetActive(attackConf.attackObjectAppearTime <= 0);            //需要倒计时显示的话,先隐藏
            X2DEffect effect = eo.x2dEffect;
            if (effect != null)
            {
                effect.Play();
                Vector3 pos = Vector3.zero;
                pos.x = attackConf.attackObjectAppearPos.x;
                pos.y = attackConf.attackObjectAppearPos.y;
                pos   = actor.objectbase.GetFaceBasedPos(pos);

                if (attackConf.attackObjectMoveMode == EmAttackObjectMoveMode.FollowCaster)
                {
                    eo.effectObject.transform.parent        = actor.transform;
                    eo.effectObject.transform.localRotation = Quaternion.identity;
                    eo.effectObject.realLocalPos            = pos;
                }
                else
                {
                    eo.effectObject.realPos = actor.objectbase.realLocalPos + pos;
                }
                eo.effectObject.isFacingRight = actor.objectbase.isFacingRight;

                //攻击物体移动
                if (attackConf.attackObjectMoveMode == EmAttackObjectMoveMode.AutoMove_Vector)
                {
                    //向量移动
                    isAttackObjectMoving     = true;
                    attackObjectMoveTimer    = 0;
                    attackObjectMoveDuration = attackConf.attackObjectMoveDuration;
                    //
                    attackObjectMoveCurve    = AnimationCurveCollection.GetAnimationCurve(attackConf.attackObjectMoveVectorCurve);
                    attackObjectMoveVector   = attackConf.attackObjectMoveVector;
                    attackObjectMoveStartPos = eo.effectObject.realLocalPos;
                    if (!eo.effectObject.isFacingRight)
                    {
                        attackObjectMoveVector.x = -attackObjectMoveVector.x;
                    }
                }
                else if (attackConf.attackObjectMoveMode == EmAttackObjectMoveMode.AutoMove_Speed)
                {
                    //曲线移动
                    isAttackObjectMoving     = true;
                    attackObjectMoveTimer    = 0;
                    attackObjectMoveDuration = attackConf.attackObjectMoveDuration;
                    //
                    attackObjectMoveSpeed = attackConf.attackObjectMoveSpeed;
                    if (!eo.effectObject.isFacingRight)
                    {
                        attackObjectMoveSpeed.x = -attackObjectMoveSpeed.x;
                    }
                }
            }
        }

        //音效
        if (!string.IsNullOrEmpty(attackConf.actorCastSoundName))
        {
            actor.audioSource.clip = ResourceLoader.LoadCharactorSound(attackConf.actorCastSoundName);
            actor.audioSource.Play();
        }

        this.actor      = actor;
        this.attackConf = attackConf;
        damageTimer     = 0f;
        attackTimer     = 0f;
        attackTimes     = 0;
        showTimer       = 0;
        damageIndex     = 0;
        isFinished      = false;
        isCurDamageEnd  = false;
        isBuffEnabled   = false;
        isInCollision   = false;
        isLifeTimeEnd   = false;
        isShowed        = false;
    }