Пример #1
0
        //-----------------------------------------------------------------------
        void play(IActUnit target, int id)
        {
            if (mActiveStatus != null && mActiveStatus.AIActionCDList.Count != 0)
            {
                foreach (ActData.AIActionCD actionCD in mActiveStatus.AIActionCDList)
                {
                    if (actionCD.ActionCache == id)
                    {
                        ActionInfo actionInfo = new ActionInfo()
                        {
                            ActionID = id, Time = mStatusTime + actionCD.Cd * 0.001f
                        };
                        mActionCDMap.Add(actionInfo);
                        if (mActionCDMap.Count > 1)
                        {
                            mActionCDMap.Sort();
                        }
                        break;
                    }
                }
            }

            if (null != mPlaySkillListener)
            {
                mPlaySkillListener.PlayAISkill(mSkillIDByCurrAction);
            }

            mActionStatus.ChangeAction(id, 0);
        }
Пример #2
0
        public void Init(ActData.AttackDef data, IActUnit owner, string action, ISkillItem skillItem,
                         Action <HitDefinition> finishHandle)
        {
            mAttackDef    = data;
            mOwner        = owner;
            mAction       = action;
            mSkillItem    = skillItem;
            mFinishHandle = finishHandle;

            mIsFinish    = false;
            mInitPos     = owner.Position;
            mOrientation = owner.Orientation;
            mDelayTime   = mAttackDef.Delay * 0.001f;
            UpdatePosition(0);

            if (!string.IsNullOrEmpty(mAttackDef.SelfEffect))
            {
                Vector3 tmpPos = new Vector3(mAttackDef.SelfEffectOffset.X * 0.01f,
                                             mAttackDef.SelfEffectOffset.Y * 0.01f,
                                             mAttackDef.SelfEffectOffset.Z * 0.01f);

                mHitDefEffectMgr.PlayEffect(mAttackDef.SelfEffect, mAttackDef.SelfEffectDuration * 0.001f,
                                            mCacheTransform, tmpPos, mOwner.Transform.rotation);
            }
        }
Пример #3
0
        // Use this for initialization
        public InputBox(IActUnit owner, Controller controller)
        {
            mOwner        = owner;
            mController   = controller;
            mActionStatus = mOwner.ActStatus;

            for (int i = 0; i < KeyStates.Length; i++)
            {
                KeyStates[i] = new KeyState();
            }
            KeyStates[(int)EKeyList.KL_Jump].AxisName      = "Jump";
            KeyStates[(int)EKeyList.KL_Attack].AxisName    = "Attack";
            KeyStates[(int)EKeyList.KL_SubAttack].AxisName = "SubAttack";
            KeyStates[(int)EKeyList.KL_Block].AxisName     = "SkillAttack";
            KeyStates[(int)EKeyList.KL_Skill0].AxisName    = "skill0";
            KeyStates[(int)EKeyList.KL_Skill1].AxisName    = "skill1";
            KeyStates[(int)EKeyList.KL_Skill2].AxisName    = "skill2";
            KeyStates[(int)EKeyList.KL_Skill3].AxisName    = "skill3";
            KeyStates[(int)EKeyList.KL_Skill4].AxisName    = "skill4";
            KeyStates[(int)EKeyList.KL_Skill5].AxisName    = "skill5";
            KeyStates[(int)EKeyList.KL_Skill6].AxisName    = "skill6";
            KeyStates[(int)EKeyList.KL_Skill7].AxisName    = "skill7";
            KeyStates[(int)EKeyList.KL_Skill8].AxisName    = "skill8";
            KeyStates[(int)EKeyList.KL_Skill9].AxisName    = "skill9";
        }
Пример #4
0
        void CheckHit(IActUnit self)
        {
            // monster only attack local player.
            //if (self.UnitType == EUnitType.EUT_Monster &&
            //    self.Camp == EUnitCamp.EUC_ENEMY &&
            //    mAttackDef.Race == Data1.RaceType.Enemy)
            //{
            //    Unit target = UnitManager.Instance.LocalPlayer;
            //    if (target != null && target.UUnitInfo && CanHit(self, target))
            //        CheckHit(self, target);
            //    return;
            //}

            int comboHit = 0;

            for (int i = 0, max = ActionSystem.Instance.ActUnitMgr.Units.Count; i < max; ++i)
            {
                var tmpTarget = ActionSystem.Instance.ActUnitMgr.Units[i];

                if (!tmpTarget.UGameObject || tmpTarget.Dead || !CanHit(self, tmpTarget))
                {
                    continue;
                }

                if (CheckHit(self, tmpTarget))
                {
                    comboHit++;
                }
            }
        }
Пример #5
0
        // Use this for initialization
        public void Init(IActUnit actUnit, Transform cameraTag)
        {
            mOwner        = actUnit;
            mCameraTag    = cameraTag;
            mActionStatus = mOwner.ActStatus;

            OnEnable();
        }
Пример #6
0
 public AIListener(IActUnit owner, IPlaySkillListener playSkillListener)
 {
     mOwner             = owner;
     mPlaySkillListener = playSkillListener;
     mActionStatus      = mOwner.ActStatus;
     mRunActionCache    = mActionStatus.ActionGroup.GetActionIdx(ActData.CommonAction.Run);
     changeAIDiff(owner.AIDiff);
 }
Пример #7
0
        public void CreateHitDefinition(ActData.AttackDef data, IActUnit owner, string action, ISkillItem skillItem)
        {
            HitDefinition tmpHitDef = mHitDefPool.Spawn();

            tmpHitDef.CacheTransform.SetParent(mHitDefRoot, false);
            tmpHitDef.Init(data, owner, action, skillItem, OnFinishHandle);
            mHitDefList.Add(tmpHitDef);
        }
Пример #8
0
        protected void InitActUnit(GameObject go, Transform model)
        {
            mGameObject = go;
            mTransform  = go.transform;
            mModelTrans = model;

            if (null != mModelTrans)
            {
                mCachedAnimation = mModelTrans.GetComponent <Animation>();
            }

            // controller.
            mController = go.GetComponent <CharacterController>();
            if (mController)
            {
                mController.enabled = false;
                mRadius             = Mathf.Max(mRadius, mController.radius);
            }

            // setup radius.
            mCollider = go.GetComponent <Collider>();
            if (mCollider && mCollider is CapsuleCollider)
            {
                mRadius = (mCollider as CapsuleCollider).radius;
            }

            for (int i = 0; i < mVariables.Length; i++)
            {
                mVariables[i] = new CustomVariable();
            }

            // build the cache layer mask
            // for unit raycast params.
            for (int i = 0; i < 32; i++)
            {
                if (!Physics.GetIgnoreLayerCollision(go.layer, i))
                {
                    mCacheLayerMask |= (1 << i);
                }
            }

            mDead        = false;
            mOnGround    = false;
            mOnTouchWall = false;
            mOnHighest   = false;
            mDead        = false;
            mHitTarget   = null;

            mState        = EUnitState.Normal;
            mPosition     = mTransform.position;
            mOrientation  = mTransform.eulerAngles.y * Mathf.Deg2Rad;
            mActionStatus = new ActionStatus(this);
            mActionStatus.ChangeActionGroup(mActionGroupIdx);
        }
Пример #9
0
        public override ECombatResult Combat(IActUnit target, ISkillItem skillItem)
        {
            ECombatResult tmpResult = base.Combat(target, skillItem);

            if (ECombatResult.ECR_Block != tmpResult)
            {
                Game.EventMgr.FireNow(this, ReferencePool.Fetch <UnitEvent.Combo>());
            }

            return(tmpResult);
        }
Пример #10
0
        bool ProcessHit(IActUnit target)
        {
            // 设置穿越次数
            int hitCount = 0;

            if (mAttackDef.PassNum > 0)
            {
                mHitedPassedMap.TryGetValue(target.UGameObject, out hitCount);
                mHitedPassedMap[target.UGameObject] = ++hitCount;
            }

            // 累加击中次数。
            mHitSucessCount++;

            // 召唤出来的单位,属性集中需要计算来之父亲的属性。
            IActUnit owner = mOwner;

            if (owner.Owner != null)
            {
                owner = owner.Owner;
            }

            // 击中目标的技能Buff
            if (mSkillItem != null && mSkillItem.SkillInput != null)
            {
                mSkillItem.SkillInput.OnHitTarget(target);
            }

            // 被格挡住了,执行格挡回弹动作。
            if (owner.Combat(target, mSkillItem) == ECombatResult.ECR_Block)
            {
                // do not process hit result in pvp mode.
                //if (PvpClient.Instance != null && mOwner.UnitType != EUnitType.EUT_LocalPlayer)
                //    return false;

                //if (mAttackDef.IsRemoteAttacks == 0 && mSkillItem == null)
                //{
                //    owner.PlayAction(ActData.CommonAction.Bounce);
                //}

                mHitBlocked = true;

                owner.PlayAction(ActData.CommonAction.Bounce);
                return(false);
            }

            // 击中目标。
            Hit(owner, target);

            // 设置攻击者的硬直时间和速度。
            mOwner.ActStatus.SetStraightTime(mAttackDef.AttackerStraightTime, false);
            return(true);
        }
Пример #11
0
        //-----------------------------------------------------------------------
        bool fetchTargetPosition(EAITragetType target_type, ref Vector3 targetPos)
        {
            IActUnit target = getTargetObject(target_type);

            if (target == null)
            {
                return(false);
            }

            targetPos = target.Position;

            return(true);
        }
Пример #12
0
        //-----------------------------------------------------------------------
        void faceTarget(IActUnit target)
        {
            if (target == null)
            {
                return;
            }

            float x   = target.Position.x - mOwner.Position.x;
            float z   = target.Position.z - mOwner.Position.z;
            float dir = Mathf.Atan2(x, 0);

            mOwner.SetOrientation(dir);
        }
Пример #13
0
        bool CanHit(IActUnit self, IActUnit target)
        {
            if (mAttackDef.Race != ActData.RaceType.Self && self == target)
            {
                return(false);
            }

            if (mAttackDef.Race == ActData.RaceType.Enemy && self.Camp == target.Camp)
            {
                return(false);
            }

            if (mAttackDef.Race == ActData.RaceType.TeamMember && self.Camp != target.Camp)
            {
                return(false);
            }

            // 如果攻击高度不符合要求,停止击中判定
            if ((mAttackDef.HeightStatusHitMaskInt & (1 << target.ActStatus.ActiveAction.HeightStatus)) == 0)
            {
                return(false);
            }

            // 如果当前动作不接受受伤攻击,停止击中判定。
            if (!target.ActStatus.CanHurt)
            {
                return(false);
            }

            int hitCount = 0;

            if (mAttackDef.PassNum > 0 && mHitedPassedMap.TryGetValue(target.UGameObject, out hitCount) && hitCount >= mAttackDef.PassNum)
            {
                return(false);
            }

            return(true);
        }
Пример #14
0
        bool CompareAIVariable(IActUnit unit, int variableIdx, int comparetype, int comvalue)
        {
            switch (variableIdx)
            {
            case (int)EVariableIdx.EVI_HP:
                return(CustomVariable.Compare((ECompareType)comparetype, unit.CurHp, comvalue));

            case (int)EVariableIdx.EVI_HPPercent:
                return(CustomVariable.Compare((ECompareType)comparetype,
                                              unit.CurHp * 100 / unit.HpMax,
                                              comvalue));

            case (int)EVariableIdx.EVI_Level:
                return(CustomVariable.Compare((ECompareType)comparetype, unit.Level, comvalue));

            default:
            {
                int            varIndex = comvalue - (int)EVariableIdx.EVI_Custom;
                CustomVariable variable = unit.GetVariable(varIndex);
                return(variable.Compare((ECompareType)comparetype, comvalue));
            }
            }
        }
Пример #15
0
        bool checkStatusChange(int id)
        {
            // 当AI活动,并且没有AI状态在队列中。
            if (mActiveStatus != null && mQueuedStatusIdx < 0)
            {
                foreach (ActData.AIStatusSwitch sw in mActiveStatus.AIStatusSwitchList)
                {
                    if (sw.SwitchStatusID == mStatusIdx || sw.SwitchStatusID >= mAIGroup.AIStatusList.Count)
                    {
                        continue;
                    }

                    // 到达指定的动作,切换状态号。
                    bool switchSucess = true;
                    bool isinchecked  = false;
                    if ((sw.Condition & 1) != 0)
                    {
                        isinchecked   = true;
                        switchSucess &= (mStatusTime * 1000 >= sw.SelfTime);
                    }
                    if ((sw.Condition & (1 << 1)) != 0) //执行指定动作
                    {
                        isinchecked = true;
                        if (id == sw.ActionCache)
                        {
                            if (sw.SelfActionCount > 1)
                            {
                                int count;
                                if (mActionCount.TryGetValue(id, out count))
                                {
                                    mActionCount[id] = ++count;

                                    switchSucess &= (count >= sw.SelfActionCount);
                                }
                                else
                                {
                                    mActionCount[id] = 1;
                                    switchSucess    &= false;
                                }
                            }
                            else
                            {
                                switchSucess &= true;
                            }
                        }
                        else
                        {
                            switchSucess &= false;
                        }
                    }
                    if ((sw.Condition & (1 << 2)) != 0)
                    {
                        isinchecked   = true;
                        switchSucess &= CompareAIVariable(mOwner, sw.SelfVaribleName, sw.SelfVaribleCompare, sw.SelfVaribleValue);
                    }
                    if ((sw.Condition & (1 << 3)) != 0)
                    {
                        isinchecked = true;
                        if (mTarget != null)
                        {
                            switchSucess &= false;
                        }
                        else
                        {
                            switchSucess &= false;
                        }
                    }

                    if ((sw.Condition & (1 << 7)) != 0)
                    {
                        isinchecked = true;
                        IActUnit target = getTargetObject((EAITragetType)sw.TargetType);
                        if (sw.TargetExist)
                        {
                            switchSucess &= (target != null);
                        }
                        else
                        {
                            switchSucess &= (target == null);
                        }
                    }
                    if ((sw.Condition & (1 << 8)) != 0) //执行指定动作
                    {
                        isinchecked = true;
                        if (id == sw.TargetActionCache)
                        {
                            if (sw.TargetActionCount > 1)
                            {
                                int count;
                                if (mActionCount.TryGetValue(id, out count))
                                {
                                    mActionCount[id] = ++count;

                                    switchSucess &= (count >= sw.TargetActionCount);
                                }
                                else
                                {
                                    mActionCount[id] = 1;
                                    switchSucess    &= false;
                                }
                            }
                            else
                            {
                                switchSucess &= true;
                            }
                        }
                        else
                        {
                            switchSucess &= false;
                        }
                    }
                    if ((sw.Condition & (1 << 9)) != 0)
                    {
                        isinchecked   = true;
                        switchSucess &= CompareAIVariable(mTarget, sw.TargetVaribleName, sw.TargetVaribleCompare, sw.TargetVaribleValue);
                        //int variable = 0;
                        //Unit* target = getTargetObject(it->TargetType);
                        //if (target && target->GetVariable ((EVariableType)it->ConditionVaribleName, variable) &&
                        //    NetMath::Compare(variable, (ECompareType)it->ConditionVaribleCompare, it->ConditionVaribleValue))
                        //{
                        //    switchSucess = true;
                        //}
                    }
                    if ((sw.Condition & (1 << 10)) != 0)
                    {
                        isinchecked = true;
                        if (mTarget != null)
                        {
                            float distance = MathUtility.DistanceMax(mOwner.Position, mTarget.Position) * 100.0f;
                            switchSucess &= (distance >= sw.TargetDistanceMin && distance <= sw.TargetDistanceMax);
                        }
                        else
                        {
                            switchSucess &= false;
                        }
                    }
                    if ((sw.Condition & (1 << 11)) != 0)
                    {
                        isinchecked = true;
                        if (mTarget != null)
                        {
                            switchSucess &= false;
                        }
                        else
                        {
                            switchSucess &= false;
                        }
                    }
                    switchSucess &= isinchecked;

                    if (switchSucess)
                    {
                        if (sw.ActionSwitchNow != 0)
                        {
                            changeActionStatus(sw.SwitchStatusID);
                            return(true);
                        }
                        else
                        {
                            // 将弄成队列里面去。
                            mQueuedStatusIdx = sw.SwitchStatusID;
                        }

                        break;
                    }
                }
            }
            return(false);
        }
Пример #16
0
        IActUnit selectEnemy()
        {
            IActUnit tmpTarget = ActionSystem.Instance.ActUnitMgr.LocalPlayer;

            return(null != tmpTarget ? tmpTarget.Dead ? null : tmpTarget : tmpTarget);
        }
Пример #17
0
 void refreshTargetList()
 {
     mEnemy  = selectEnemy();
     mChild  = selectChild();
     mParent = null;// gameObject;
 }
Пример #18
0
 public void Add(IActUnit actUnit)
 {
     mUnits.Add(actUnit);
 }
Пример #19
0
        //-----------------------------------------------------------------------
        void chooseAction()
        {
            // 清楚当前选择。
            mActiveList = null;

            // 进行AI选择了。
            // 循环执行AI选择动作。
            if (mLoopCount > 0)
            {
                // 设置标签,避免重复计算[onActionFinished]
                mActionChanging = true;
                play(mTarget, mCurrentActionID);
                mActionChanging = false;
                return;
            }

            // choose a target when action finished.
            if (mActiveStatus != null && mActiveStatus.AILists.Count != 0)
            {
                mActiveList = null;
                mTarget     = getTargetObject((EAITragetType)mActiveStatus.TargetType);
                if (mTarget == null)
                {
                    refreshTargetList();
                }
                mActionStatus.ActionTarget = mTarget;

                if (null == mTarget)
                {
                    return;
                }

                if (Mathf.Abs(mTarget.Position.z - mOwner.Position.z) > 1f)
                {
                    mSkillIDByCurrAction = 0;

                    mActionChanging = true;
                    play(mTarget, mRunActionCache);
                    mActionChanging = false;

                    mLoopCount       = 1;
                    mCurrentActionID = mRunActionCache;
                    return;
                }

                if (fetchTargetPosition((EAITragetType)mActiveStatus.TargetType, ref mTargetPos))
                {
                    float targetDistanceSqr = MathUtility.DistanceSqr(mOwner.Position, mTargetPos);

                    // choose a action set base the distance.
                    int checkDist = (int)(targetDistanceSqr * 10000);
                    foreach (ActData.AIList aiList in mActiveStatus.AILists)
                    {
                        if (aiList.DistanceSqr < checkDist)
                        {
                            break;
                        }
                        mActiveList = aiList;
                    }
                }

                // 是否有AI距离可以选择。
                if (mActiveList == null || mActiveList.AISlots.Count == 0)
                {
                    mActionChanging = false;
                    return;
                }


                // 计算出总共的动作几率。
                int totalProability = 0, idx = 0;
                int action_enabled = 0;
                foreach (ActData.AISlot slot in mActiveList.AISlots)
                {
                    if (!string.IsNullOrEmpty(slot.SwitchActionID))
                    {
                        int checkid = slot.ActionCache;
                        if (mActionCDMap.Count == 0 || !mActionCDMap.Exists(delegate(ActionInfo info) { return(info.ActionID == checkid); }))
                        {
                            action_enabled  |= (1 << idx);
                            totalProability += slot.Ratio;
                        }
                    }
                    idx++;
                }

                idx = 0;
                if (totalProability <= 0)
                {
                    return;
                }

                // 取出随机值范围值。
                int            randValue  = UnityEngine.Random.Range(0, totalProability);
                ActData.AISlot targetSlot = null;
                foreach (ActData.AISlot slot in mActiveList.AISlots)
                {
                    if ((action_enabled & (1 << idx)) != 0)
                    {
                        randValue -= slot.Ratio;
                        if (randValue < 0)
                        {
                            targetSlot = slot;
                            break;
                        }
                    }
                    idx++;
                }

                if (targetSlot != null)
                {
                    // 刷新目标列表。
                    if (targetSlot.RefreshTargetList != 0)
                    {
                        refreshTargetList();
                    }

                    mSkillIDByCurrAction = targetSlot.SkillID;

                    mActionChanging = true;
                    play(mTarget, targetSlot.ActionCache);
                    mActionChanging = false;

                    mLoopCount       = targetSlot.Count;
                    mCurrentActionID = targetSlot.ActionCache;
                }
            }
        }
Пример #20
0
 public void Remove(IActUnit actUnit)
 {
     mRemoveUnits.Add(actUnit);
 }
Пример #21
0
        void LashProcess(ActData.AttackDef attackDef,
                         ref HitData hitData,
                         IActUnit target,
                         ActData.HeightStatusFlag targetHeightStatus,
                         bool processLash,
                         bool rotateOnHit)
        {
            int   AttackeeStraightTime = attackDef.AttackeeStraightTime;
            float AttackeeLashX        = attackDef.AttackeeLash.X;
            float AttackeeLashY        = attackDef.AttackeeLash.Y;
            float AttackeeLashZ        = attackDef.AttackeeLash.Z;
            int   AttackeeTime         = attackDef.AttackeeTime;

            ActData.AttackDef.Types.HitResultData hitResultData = null;
            switch (targetHeightStatus)
            {
            case ActData.HeightStatusFlag.Ground:
                hitResultData = attackDef.GroundHit;
                break;

            case ActData.HeightStatusFlag.LowAir:
                hitResultData = attackDef.LowAirHit;
                break;

            case ActData.HeightStatusFlag.HighAir:
                hitResultData = attackDef.HighAirHit;
                break;
            }

            if (hitResultData != null && hitResultData.Enabled)
            {
                AttackeeLashX        = hitResultData.AttackeeLash.X;
                AttackeeLashY        = hitResultData.AttackeeLash.Y;
                AttackeeLashZ        = hitResultData.AttackeeLash.Z;
                AttackeeTime         = hitResultData.AttackeeTime;
                AttackeeStraightTime = hitResultData.AttackeeStraightTime;
            }

            if (processLash)
            {
                // 非受击转向的时候,冲击速度需要转换为本地坐标。
                if (!rotateOnHit)
                {
                    Quaternion rotate = Quaternion.AngleAxis(mOrientation * Mathf.Rad2Deg + 180, Vector3.up);
                    if (mAttackDef.FramType != ActData.HitDefnitionFramType.CuboidType)
                    {
                        Vector3 targetToOwner = mPos - target.Position;
                        targetToOwner.y = 0;
                        rotate          = Quaternion.LookRotation(targetToOwner);
                    }
                    Vector3 lashVector = rotate * new Vector3(AttackeeLashX, AttackeeLashY, AttackeeLashZ);
                    lashVector = target.UGameObject.transform.InverseTransformDirection(lashVector);

                    AttackeeLashX = (short)lashVector.x;
                    AttackeeLashZ = (short)lashVector.z;
                }

                hitData.LashX    = (short)AttackeeLashX;
                hitData.LashY    = (short)AttackeeLashY;
                hitData.LashZ    = (short)AttackeeLashZ;
                hitData.LashTime = (short)AttackeeTime;
            }

            hitData.StraightTime = (short)AttackeeStraightTime;
        }
Пример #22
0
        bool CheckHit(IActUnit self, IActUnit target)
        {
            // 转换offset到世界坐标系
            ActionStatus targetActionStatus = target.ActStatus;

            ActData.Action targetAction = targetActionStatus.ActiveAction;
            float          BoundOffsetX = targetAction.BoundingOffsetX;
            float          BoundOffsetY = targetAction.BoundingOffsetY;
            float          BoundOffsetZ = targetAction.BoundingOffsetZ;

            MathUtility.Rotate(ref BoundOffsetX, ref BoundOffsetZ, target.Orientation);

            Vector3 AttackeePos = target.Position + new Vector3(
                BoundOffsetX, BoundOffsetY, BoundOffsetZ) * 0.01f;

            bool hitSuccess = false;

            switch (mAttackDef.FramType)
            {
            case ActData.HitDefnitionFramType.CuboidType:
            case ActData.HitDefnitionFramType.SomatoType:
                // 四面体求交。
                if (MathUtility.RectangleHitDefineCollision(
                        mPos, mOrientation,
                        mCubeHitDefSize,
                        AttackeePos, target.Orientation,
                        targetActionStatus.Bounding))
                {
                    hitSuccess = true;
                }
                break;

            case ActData.HitDefnitionFramType.CylinderType:
                // 圆柱求交
                if (MathUtility.CylinderHitDefineCollision(
                        mPos, mOrientation,
                        mCylinderSize.x, mCylinderSize.y,
                        AttackeePos, target.Orientation,
                        targetActionStatus.Bounding))
                {
                    hitSuccess = true;
                }
                break;

            case ActData.HitDefnitionFramType.RingType:
                if (MathUtility.RingHitDefineCollision(
                        mPos, mOrientation,
                        mRingSize.x, mRingSize.y, mRingSize.z,
                        AttackeePos, target.Orientation,
                        targetActionStatus.Bounding))
                {
                    hitSuccess = true;
                }
                break;

            case ActData.HitDefnitionFramType.FanType:
                if (MathUtility.FanDefineCollision(
                        mPos, mOrientation,
                        mFanSize.x, mFanSize.y, mFanSize.z, mFanSize.w,
                        AttackeePos, target.Orientation,
                        targetActionStatus.Bounding))
                {
                    hitSuccess = true;
                }
                break;
            }

            if (hitSuccess)
            {
                return(ProcessHit(target));
            }

            return(false);
        }
Пример #23
0
 public void ClearFlags()
 {
     mHitTarget = null;
 }
Пример #24
0
 public void OnHitTarget(IActUnit target)
 {
     mHitTarget = target;
 }
Пример #25
0
 public virtual ECombatResult Combat(IActUnit target, ISkillItem skillItem)
 {
     return(ECombatResult.ECR_Normal);
 }
Пример #26
0
        void Hit(IActUnit self, IActUnit target)
        {
            ActionStatus targetActionStatus = target.ActStatus;

            // hit target.
            self.OnHitTarget(target);

            // sound.

            /*
             * if (!string.IsNullOrEmpty(mData1.HitedSound) && mHitSoundCount < MAX_HIT_SOUND)
             * {
             *  if (mData1.HitedSoundIndex == -2)
             *  {
             *      mData1.HitedSoundIndex = SoundManager.Instance.GetSoundIndex(mData1.HitedSound);
             *      if (mData1.HitedSoundIndex < 0)
             *          Debug.LogError(string.Format("Fail to load hit sound: [{0}/{1}]", mOwner.UnitID, mData1.HitedSound));
             *  }
             *  if (mData1.HitedSoundIndex > 0)
             *      SoundManager.Instance.Play3DSound(mData1.HitedSoundIndex, mOwner.Position, 1.0f);
             *  mHitSoundCount++;
             * }*/

            // effect
            if (!string.IsNullOrEmpty(mAttackDef.HitedEffect))
            {
                Vector3 effectPos = target.Position;
                effectPos.y += targetActionStatus.Bounding.y * 0.5f;

                ActionSystem.Instance.EffectMgr.PlayEffect(mAttackDef.HitedEffect, mAttackDef.HitedEffectDuration * 0.001f,
                                                           null, effectPos,
                                                           0 == mAttackDef.BaseGround ? Quaternion.identity : Quaternion.Euler(0f, 0f, UnityEngine.Random.Range(0f, 360f)));
            }

            // do not process my hit result in pvp mode.
            //if (PvpClient.Instance != null && self.UnitType == EUnitType.EUT_LocalPlayer)
            //    return;

            HitData tmpHitData = new HitData();

            tmpHitData.TargetUUID = target.UUID;

            // 击中转向
            float targetRotate = target.Orientation;
            bool  rotateOnHit  = targetActionStatus.RotateOnHit;

            if (rotateOnHit)
            {
                if (mAttackDef.FramType == ActData.HitDefnitionFramType.CylinderType)
                {
                    float x      = target.Position.x - mPos.x;
                    float z      = target.Position.z - mPos.z;
                    float modify = Mathf.Atan2(x, 0);
                    targetRotate = modify + Mathf.PI;
                }
                else
                {
                    targetRotate = self.Orientation + Mathf.PI;
                }
            }

            NetCommon.Encode(
                target.Position,
                targetRotate,
                ref tmpHitData.HitX,
                ref tmpHitData.HitY,
                ref tmpHitData.HitZ,
                ref tmpHitData.HitDir);

            // 单位在墙边上的时候,近战攻击者需要反弹。
            bool bounceBack = mAttackDef.IsRemoteAttacks == 0 && target.OnTouchWall;

            // 单位处于非霸体状态,需要被击中移动~
            bool processLash = true;

            //受击动作
            ActData.HeightStatusFlag targetHeightStatus = targetActionStatus.HeightState;

            if (targetActionStatus.ActiveAction.SuperArmor || target.IsPabodyState)
            {
                // 设置受击者的霸体硬直时间?
                tmpHitData.HitAction = byte.MaxValue;

                // 单位处于霸体状态,不需要移动~
                processLash = false;

                // 攻击结果为霸体的情况系,非远程攻击的冲击速度转换为攻击者。受击者不受冲击速度影响
                bounceBack = mAttackDef.IsRemoteAttacks == 0;
            }
            else if (targetActionStatus.OnHit(mAttackDef.HitResult, mAttackDef.IsRemoteAttacks != 0))
            {
                tmpHitData.HitAction = (byte)targetActionStatus.ActiveAction.ActionCache;
            }

            // 处理buff的东东
            if (targetActionStatus.SkillItem != null && targetActionStatus.SkillItem.SkillInput != null)
            {
                targetActionStatus.SkillItem.SkillInput.OnHit(self);
            }

            // 设置攻击者的冲击速度及冲击时间。
            int     attackerLashTime = mAttackDef.AttackerTime;
            Vector3 attackerLash     = attackerLashTime == 0 ? self.ActStatus.Velocity : new Vector3(
                mAttackDef.AttackerLash.X * 0.01f,
                mAttackDef.AttackerLash.Y * 0.01f,
                mAttackDef.AttackerLash.Z * 0.01f);

            if (bounceBack)
            {
                attackerLash.x   = mAttackDef.AttackeeLash.X * 0.01f;
                attackerLash.z   = mAttackDef.AttackeeLash.Z * 0.01f;
                attackerLashTime = mAttackDef.AttackeeTime;
            }

            if (attackerLashTime > 0)
            {
                self.ActStatus.SetLashVelocity(
                    attackerLash.x,
                    attackerLash.y,
                    attackerLash.z,
                    attackerLashTime);
            }

            // 处理受击者的冲击速度~
            LashProcess(mAttackDef, ref tmpHitData, target, targetHeightStatus, processLash, rotateOnHit);

            // I was hited, tell the others.
            //if (self.UnitType == EUnitType.EUT_OtherPlayer && target.UnitType == EUnitType.EUT_LocalPlayer)
            //{
            //    if (target.ActStatus.Listener != null)
            //        target.ActStatus.Listener.OnHitData(tmpHitData);
            //}

            target.OnHit(tmpHitData, false);
        }