Example #1
0
 void UpdateEnergeRecharge()
 {
     if (null != m_Skill && m_Skill.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon)
     {
         for (int i = m_RechangeableEquipments.Count - 1; i >= 0; i--)
         {
             IRechargeableEquipment rechargeable = m_RechangeableEquipments[i];
             if (null != rechargeable && !rechargeable.Equals(null))
             {
                 if (Time.time > rechargeable.lastUsedTime + rechargeable.rechargeDelay)
                 {
                     if (rechargeable.enMax - rechargeable.enCurrent <= PETools.PEMath.Epsilon)
                     {
                         continue;
                     }
                     float currentEnerge  = m_Skill.GetAttribute(AttribType.Energy);
                     float rechargeEnerge = Mathf.Clamp(rechargeable.rechargeSpeed * Time.deltaTime,
                                                        0, rechargeable.enMax - rechargeable.enCurrent);
                     if (rechargeEnerge > currentEnerge)
                     {
                         rechargeEnerge = currentEnerge;
                     }
                     rechargeable.enCurrent += rechargeEnerge;
                     m_Skill.SetAttribute(AttribType.Energy, currentEnerge - rechargeEnerge);
                 }
             }
             else
             {
                 m_RechangeableEquipments.RemoveAt(i);
             }
         }
     }
 }
Example #2
0
        void InitReputationSystem()
        {
            if (GameConfig.IsMultiMode)
            {
                return;
            }

            if (m_Skill != null)
            {
                ReputationSystem.Instance.AddPlayerID((int)m_Skill.GetAttribute(AttribType.DefaultPlayerID));
                if (PeGameMgr.IsAdventure)
                {
                    ReputationSystem.Instance.ActiveReputation((int)m_Skill.GetAttribute(AttribType.DefaultPlayerID));
                }
            }
        }
Example #3
0
    void OnHpChange(SkillSystem.SkEntity caster, float hpChange)
    {
        float hp = alive.GetAttribute(Pathea.AttribType.Hp);

        if (mItemObj != null)
        {
            if (mLifeLimit != null)
            {
                mLifeLimit.floatValue.current = hp;
            }
            if (mDurability != null)
            {
                mDurability.floatValue.current = hp;
            }
        }
    }
Example #4
0
        void ApplyMoveEffect(SkEntity skEntity, Transform trans, Vector3 forceDir, float forcePower)
        {
            if (null == m_Param)
            {
                return;
            }
            float angle          = Vector3.Angle(m_PeTrans.existent.forward, forceDir);
            float thresholdScale = m_Param.m_AngleThresholdScale.Evaluate(angle);

            forcePower *= m_Param.m_AngleForceScale.Evaluate(angle);

            thresholdScale *= m_MotionMgr.GetMaskState(PEActionMask.InAir) ? m_Param.m_ThresholdScaleInAir : 1f;

            EffectType spType = EffectType.Repulsed;

            if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdWhacked) * thresholdScale)
            {
                spType = EffectType.Null;
            }
            else if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdRepulsed) * thresholdScale)
            {
                spType = EffectType.Whacked;
            }
            else if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdWentfly) * thresholdScale)
            {
                spType = EffectType.Repulsed;
            }
            else if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdKnocked) * thresholdScale)
            {
                spType = EffectType.Wentfly;
            }
            else
            {
                spType = EffectType.Knocked;
            }

#if UNITY_EDITOR
            if (m_WriteLog)
            {
                Debug.LogError("ForcePower:" + forcePower);
                Debug.LogError("ThresholdRepulsed:" + m_SkillCmpt.GetAttribute(AttribType.ThresholdRepulsed).ToString());
                Debug.LogError(spType.ToString());
            }
#endif
            SkAliveEntity skAliveEntity = skEntity as SkAliveEntity;
            if (null != skAliveEntity)
            {
                switch (spType)
                {
                case EffectType.Null:
                    ApplyHitEffect(trans, forceDir, forcePower);
                    break;

                case EffectType.Whacked:
                    m_MotionMgr.DoAction(PEActionType.Whacked);
                    break;

                case EffectType.Repulsed:
                    ApplyHitEffect(trans, forceDir, forcePower);
                    PEActionParamVVF param = PEActionParamVVF.param;
                    param.vec1 = m_PeTrans.position;
                    param.vec2 = forceDir;
                    param.f    = forcePower;
                    m_MotionMgr.DoAction(PEActionType.Repulsed, param);
                    break;

                case EffectType.Wentfly:
                case EffectType.Knocked:
                    PEActionParamVFNS paramVFNS = PEActionParamVFNS.param;
                    paramVFNS.vec = forceDir;
                    paramVFNS.f   = forcePower;
                    paramVFNS.n   = skAliveEntity.Entity.Id;
                    if (null != trans)
                    {
                        paramVFNS.str = trans.name;
                    }
                    else
                    {
                        paramVFNS.str = "";
                    }
                    m_MotionMgr.DoAction(PEActionType.Wentfly, paramVFNS);
                    break;
                }
            }
        }
Example #5
0
        void UpdateRotation()
        {
            if (m_Motor == null)
            {
                return;
            }

            if (m_CurFaceDirection != Vector3.zero)
            {
                m_Motor.desiredFacingDirection = m_CurFaceDirection.normalized;
            }
            else if (m_CurMovementDirection != Vector3.zero)
            {
                m_Motor.desiredFacingDirection = m_CurMovementDirection.normalized;
            }
            else
            {
                m_Motor.desiredFacingDirection = Vector3.zero;
            }

            //Vector3 direction = m_CurFaceDirection != Vector3.zero ? m_CurFaceDirection : m_CurMovementDirection;
            Vector3 direction = m_Motor.desiredFacingDirection;

            //Debug.DrawRay(m_Motor.transform.position, direction.normalized * 16f, Color.blue);

            Vector3 velocity = Quaternion.Inverse(m_Motor.transform.rotation) * direction;

            if (PEUtil.SqrMagnitudeH(velocity) > 0.05f * 0.05f)
            {
                m_Animator.SetFloat("Angle", Mathf.Atan2(velocity.x, velocity.z) * 180.0f / 3.14159f);
            }
            else
            {
                m_Animator.SetFloat("Angle", 0.0f);
            }

            PEMotorPhysics motorPhysic = m_Motor as PEMotorPhysics;

            if (motorPhysic != null)
            {
                float rotationSpeed = m_Attribute.GetAttribute(AttribType.RotationSpeed);

                if (motorPhysic.velocity.sqrMagnitude > 0.25f * 0.25f)
                {
                    if (m_SpeedState == SpeedState.Walk)
                    {
                        rotationSpeed = motorPhysic.walkSmoothSpeed;
                    }
                    else
                    {
                        rotationSpeed = motorPhysic.runSmoothSpeed;
                    }
                }

                if (m_Animator != null)
                {
                    float rotAnimSpeed = m_Animator.GetFloat("RotationSpeed");
                    rotationSpeed = rotAnimSpeed > 0.0f ? rotAnimSpeed : rotationSpeed;
                }

                motorPhysic.maxRotationSpeed = rotationSpeed;
            }
        }