コード例 #1
0
        void PlayBulletToTarget(BulletStruct es, Transform firePoint, Transform target)
        {
            GameObject  beHitObject = target.gameObject;
            NFBodyIdent bodyIdent   = target.GetComponent <NFBodyIdent>();

            if (bodyIdent && bodyIdent.xBeHitPoint)
            {
                beHitObject = bodyIdent.xBeHitPoint.gameObject;
            }

            Vector3    pos     = firePoint.position;
            GameObject _bullet = GameObject.Instantiate <GameObject>(es.Bullet, pos, Quaternion.identity);

            _bullet.transform.position = firePoint.position;
            _bullet.SetActive(true);
            _bullet.transform.LookAt(target.transform.position);

            Destroy(_bullet, es.StartEffLifeTime);

            if (es.StartEffect)
            {
                GameObject _startEff = GameObject.Instantiate <GameObject>(es.StartEffect, pos, Quaternion.identity);
                _startEff.SetActive(true);
                Destroy(_startEff, es.StartEffLifeTime);
            }
            if (es.StartAudio)
            {
                AudioClip _startEff = GameObject.Instantiate <AudioClip>(es.StartAudio, pos, Quaternion.identity);
                AudioSource.PlayClipAtPoint(_startEff, transform.position);

                Destroy(_startEff, es.StartEffLifeTime);
            }

            StartCoroutine(WaitMoveBulletToTarget(es, _bullet, beHitObject));
        }
コード例 #2
0
        private void OnClassNPCEventHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
        {
            if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE)
            {
                string    strConfigID = mKernelModule.QueryPropertyString(self, NFrame.NPC.ConfigID);
                NFVector3 vec3        = mKernelModule.QueryPropertyVector3(self, NFrame.NPC.Position);

                Vector3 vec = new Vector3();
                vec.x = vec3.X();
                vec.y = vec3.Y();
                vec.z = vec3.Z();

                string strPrefabPath = "";
                if (strConfigID.Length <= 0)
                {
                    strPrefabPath = mElementModule.QueryPropertyString("Enemy", NPC.Prefab);
                }
                else
                {
                    strPrefabPath = mElementModule.QueryPropertyString(strConfigID, NPC.Prefab);
                }

                GameObject xNPC = CreateObject(self, strPrefabPath, vec, strClassName);
                if (xNPC == null)
                {
                    Debug.LogError("Create GameObject fail in " + strConfigID + "  " + strPrefabPath);

                    return;
                }

                xNPC.name = strConfigIndex;
                xNPC.transform.Rotate(new Vector3(0, 90, 0));

                NFBodyIdent xBodyIdent = xNPC.GetComponent <NFBodyIdent>();
                if (null != xBodyIdent)
                {//不能没有
                    xBodyIdent.enabled = true;
                    xBodyIdent.SetObjectID(self);
                    xBodyIdent.cnfID = strConfigID;
                }
                else
                {
                    Debug.LogError("No 'BodyIdent' component in " + strConfigID + "  " + strPrefabPath);
                }

                InitPlayerComponent(self, xNPC, false);
            }
            else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_LOADDATA)
            {
            }
            else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_DESTROY)
            {
                DestroyObject(self);
            }
            else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH)
            {
                //NFCKernelModule.Instance.RegisterPropertyCallback(self, NFrame.Player.PrefabPath, OnClassPrefabEventHandler);
            }
        }
コード例 #3
0
ファイル: NFNormalSkill5.cs プロジェクト: zli1989/NFUnitySDK
 public NFNormalSkill5(GameObject gameObject, NFAnimaStateType eState, NFAnimaStateMachine xStateMachine, float fHeartBeatTime, float fExitTime, bool input = false)
     : base(gameObject, eState, xStateMachine, fHeartBeatTime, fExitTime, input)
 {
     xBodyIdent = gameObject.GetComponent <NFBodyIdent>();
     xInput     = gameObject.GetComponent <NFHeroInput>();
     xHeroMotor = gameObject.GetComponent <NFHeroMotor>();
     xHeroSync  = gameObject.GetComponent <NFHeroSync>();
 }
コード例 #4
0
 private void Awake()
 {
     mBodyIdent = GetComponent <NFBodyIdent>();
     if (mBodyIdent.xRenderObject)
     {
         mAnimator = mBodyIdent.xRenderObject.GetComponent <Animator>();
     }
 }
コード例 #5
0
        private void OnConfigChangeHandler(NFGUID self, string strProperty, NFDataList.TData oldVar, NFDataList.TData newVar)
        {
            Vector3 vec = GetRenderObjectPosition(self);

            DestroyObject(self);

            if (vec.Equals(Vector3.zero))
            {
                NFVector3 vec3 = mKernelModule.QueryPropertyVector3(self, NPC.Position);
                vec.x = vec3.X();
                vec.y = vec3.Y();
                vec.z = vec3.Z();
            }

            string strHeroCnfID  = newVar.StringVal();
            string strPrefabPath = mElementModule.QueryPropertyString(strHeroCnfID, NPC.Prefab);

            if (strPrefabPath.Length <= 0)
            {
                strPrefabPath = mElementModule.QueryPropertyString("Enemy", NPC.Prefab);
            }
            GameObject xPlayer = CreateObject(self, strPrefabPath, vec, NFrame.Player.ThisName);

            if (xPlayer)
            {
                xPlayer.name = NFrame.Player.ThisName;
                xPlayer.transform.Rotate(new Vector3(0, 90, 0));

                NFBodyIdent xBodyIdent = xPlayer.GetComponent <NFBodyIdent>();
                if (null != xBodyIdent)
                {//不能没有
                    xBodyIdent.enabled = true;
                    xBodyIdent.SetObjectID(self);
                    xBodyIdent.cnfID = strHeroCnfID;
                }
                else
                {
                    Debug.LogError("No 'BodyIdent' component in " + strPrefabPath);
                }

                if (self == mLoginModule.mRoleID)
                {
                    InitPlayerComponent(self, xPlayer, true);
                }
                else
                {
                    InitPlayerComponent(self, xPlayer, false);
                }

                Debug.Log("Create Object successful" + NFrame.Player.ThisName + " " + vec.ToString() + " " + self.ToString());
            }
            else
            {
                Debug.LogError("Create Object failed" + NFrame.Player.ThisName + " " + vec.ToString() + " " + self.ToString());
            }
        }
コード例 #6
0
ファイル: NFJumpingState.cs プロジェクト: zli1989/NFUnitySDK
    public override void Enter(GameObject gameObject, int index)
    {
        xBodyIdent = gameObject.GetComponent <NFBodyIdent>();
        xInput     = gameObject.GetComponent <NFHeroInput>();
        xHeroAnima = gameObject.GetComponent <NFAnimatStateController>();
        xHeroMotor = gameObject.GetComponent <NFHeroMotor>();


        base.Enter(gameObject, index);
    }
コード例 #7
0
    public override void Enter(GameObject gameObject, int index)
    {
        xBodyIdent = gameObject.GetComponent <NFBodyIdent> ();
        xHeroAnima = gameObject.GetComponent <NFAnimatStateController> ();
        xHeroMotor = gameObject.GetComponent <NFHeroMotor> ();

        base.Enter(gameObject, index);

        xHeroMotor.speed = xHeroMotor.runSpeed;
        standCount       = 0;
    }
コード例 #8
0
    private void Start()
    {
        mxHeroMotor        = GetComponent <NFHeroMotor>();
        mxSyncBuffer       = GetComponent <NFHeroSyncBuffer>();
        mxBodyIdent        = GetComponent <NFBodyIdent>();
        mAnimaStateMachine = GetComponent <NFAnimaStateMachine>();

        mxNetModule  = NFPluginManager.Instance().FindModule <NFNetModule>();
        mLoginModule = NFPluginManager.Instance().FindModule <NFLoginModule>();
        mHelpModule  = NFPluginManager.Instance().FindModule <NFHelpModule>();
    }
コード例 #9
0
ファイル: NFHeroMotor.cs プロジェクト: sl-sandy/NFUnitySDK
    void Start()
    {
        mAnima             = GetComponent <NFAnimatStateController>();
        mBodyIdent         = GetComponent <NFBodyIdent>();
        mAnimaStateMachine = GetComponent <NFAnimaStateMachine>();
        mHeroInput         = GetComponent <NFHeroInput>();
        mHeroSync          = GetComponent <NFHeroSync>();

        mxGUID        = mBodyIdent.GetObjectID();
        moveDirection = new Vector3();

        mKernelModule.RegisterPropertyCallback(mxGUID, NFrame.Player.MOVE_SPEED, PropertyEventHandler);
    }
コード例 #10
0
    private void Start()
    {
        mxHeroMotor            = GetComponent <NFHeroMotor>();
        mxSyncBuffer           = GetComponent <NFHeroSyncBuffer>();
        mxBodyIdent            = GetComponent <NFBodyIdent>();
        mAnimaStateMachine     = GetComponent <NFAnimaStateMachine>();
        mAnimatStateController = GetComponent <NFAnimatStateController>();

        mNetModule    = NFRoot.Instance().GetPluginManager().FindModule <NFNetModule>();
        mLoginModule  = NFRoot.Instance().GetPluginManager().FindModule <NFLoginModule>();
        mHelpModule   = NFRoot.Instance().GetPluginManager().FindModule <NFHelpModule>();
        mKernelModule = NFRoot.Instance().GetPluginManager().FindModule <NFIKernelModule>();
    }
コード例 #11
0
ファイル: NFJumpLandState.cs プロジェクト: zli1989/NFUnitySDK
    public override void Enter(GameObject gameObject, int index)
    {
        xBodyIdent = gameObject.GetComponent <NFBodyIdent>();
        xInput     = gameObject.GetComponent <NFHeroInput>();
        xHeroAnima = gameObject.GetComponent <NFAnimatStateController>();
        xHeroMotor = gameObject.GetComponent <NFHeroMotor>();

        mCharacterMovement = gameObject.GetComponent <CharacterMovement>();

        base.Enter(gameObject, index);

        Vector3 v = new Vector3(gameObject.transform.position.x, mCharacterMovement.groundHit.groundPoint.y, gameObject.transform.position.z);

        gameObject.transform.position = v;
    }
コード例 #12
0
    void Start()
    {
        mStateMachineMng = GetComponent <NFAnimaStateMachine>();
        mBodyIdent       = GetComponent <NFBodyIdent>();
        mHeroMotor       = GetComponent <NFHeroMotor>();

        mUIModule    = NFPluginManager.Instance().FindModule <NFUIModule>();
        mLoginModule = NFPluginManager.Instance().FindModule <NFLoginModule>();

        mKernelModule = NFPluginManager.Instance().FindModule <NFIKernelModule>();

        mKernelModule.RegisterPropertyCallback(mBodyIdent.GetObjectID(), NFrame.Player.MOVE_SPEED, PropertyMoveSpeedHandler);
        mKernelModule.RegisterPropertyCallback(mBodyIdent.GetObjectID(), NFrame.Player.ATK_SPEED, PropertyAttackSpeedHandler);

        mHeroMotor.angularSpeed = 0f;
    }
コード例 #13
0
    public void Awake()
    {
        NFIPluginManager pluginManager = NFRoot.Instance().GetPluginManager();

        xBodyIdent = GetComponent <NFBodyIdent>();

        mKernelModule  = pluginManager.FindModule <NFIKernelModule>();
        mElementModule = pluginManager.FindModule <NFIElementModule>();
        mLoginModule   = pluginManager.FindModule <NFLoginModule>();

        AddState(NFAnimaStateType.Idle, new NFIdleState(this.gameObject, NFAnimaStateType.Idle, this, 1f, 0f, true));
        AddState(NFAnimaStateType.Idle1, new NFIdleState(this.gameObject, NFAnimaStateType.Idle, this, 1f, 0f, true));
        AddState(NFAnimaStateType.Idle2, new NFIdleState(this.gameObject, NFAnimaStateType.Idle, this, 1f, 0f, true));

        AddState(NFAnimaStateType.Run, new NFRunState(this.gameObject, NFAnimaStateType.Run, this, 1f, 0f, true));
        AddState(NFAnimaStateType.Walk, new NFWalkState(this.gameObject, NFAnimaStateType.Walk, this, 1f, 0f, true));
        AddState(NFAnimaStateType.Dizzy, new NFDizzyState(this.gameObject, NFAnimaStateType.Dizzy, this, 1f, 0f));
        AddState(NFAnimaStateType.Freeze, new NFFreezeState(this.gameObject, NFAnimaStateType.Freeze, this, 1f, 0f));
        AddState(NFAnimaStateType.Block, new NFBlockState(this.gameObject, NFAnimaStateType.Block, this, 1f, 0f));
        AddState(NFAnimaStateType.Fall, new NFFallState(this.gameObject, NFAnimaStateType.Fall, this, 1f, 0f));
        AddState(NFAnimaStateType.Dead, new NFDeadState(this.gameObject, NFAnimaStateType.Dead, this, 1f, 0f));
        AddState(NFAnimaStateType.JumpStart, new NFJumpStartState(this.gameObject, NFAnimaStateType.JumpStart, this, 1f, 0f));
        AddState(NFAnimaStateType.Jumping, new NFJumpingState(this.gameObject, NFAnimaStateType.Jumping, this, 1f, 0f));
        AddState(NFAnimaStateType.JumpLand, new NFJumpLandState(this.gameObject, NFAnimaStateType.JumpLand, this, 0.1f, 0.4f));
        AddState(NFAnimaStateType.BeHit1, new NFBeHitState(this.gameObject, NFAnimaStateType.BeHit1, this, 1f, 0f));
        AddState(NFAnimaStateType.BeHit2, new NFBeHitState(this.gameObject, NFAnimaStateType.BeHit2, this, 1f, 0f));
        AddState(NFAnimaStateType.HitFly, new NFHitFlyState(this.gameObject, NFAnimaStateType.HitFly, this, 1f, 0f));
        AddState(NFAnimaStateType.Stun, new NFHitFlyState(this.gameObject, NFAnimaStateType.Stun, this, 1f, 0f));

        AddState(NFAnimaStateType.DashForward, new NFDashForwardState(this.gameObject, NFAnimaStateType.DashForward, this, 1f, 0f));
        AddState(NFAnimaStateType.DashJump, new NFDashForwardState(this.gameObject, NFAnimaStateType.DashJump, this, 1f, 0f));

        AddState(NFAnimaStateType.Buff1, new NFBuff1(this.gameObject, NFAnimaStateType.Buff1, this, 1f, 0f));

        AddState(NFAnimaStateType.NormalSkill1, new NFNormalSkill1(this.gameObject, NFAnimaStateType.NormalSkill1, this, 1f, 0f));
        AddState(NFAnimaStateType.NormalSkill2, new NFNormalSkill2(this.gameObject, NFAnimaStateType.NormalSkill2, this, 1f, 0f));
        AddState(NFAnimaStateType.NormalSkill3, new NFNormalSkill3(this.gameObject, NFAnimaStateType.NormalSkill3, this, 1f, 0f));
        AddState(NFAnimaStateType.NormalSkill4, new NFNormalSkill4(this.gameObject, NFAnimaStateType.NormalSkill4, this, 1f, 0f));
        AddState(NFAnimaStateType.NormalSkill5, new NFNormalSkill5(this.gameObject, NFAnimaStateType.NormalSkill5, this, 1f, 0f));

        AddState(NFAnimaStateType.SpecialSkill1, new NFSpecialSkill1(this.gameObject, NFAnimaStateType.SpecialSkill1, this, 1f, 0f));
        AddState(NFAnimaStateType.SpecialSkill2, new NFSpecialSkill2(this.gameObject, NFAnimaStateType.SpecialSkill2, this, 1f, 0f));
        AddState(NFAnimaStateType.SkillThump, new NFSkillThump(this.gameObject, NFAnimaStateType.SkillThump, this, 1f, 0f));
    }
コード例 #14
0
    public override void Enter(GameObject gameObject, int index)
    {
        xBodyIdent = gameObject.GetComponent <NFBodyIdent>();
        xHeroMotor = gameObject.GetComponent <NFHeroMotor>();
        xHeroSync  = gameObject.GetComponent <NFHeroSync>();

        base.Enter(gameObject, index);

        if (mStateMachine.IsMainRole())
        {
            //xHeroSync.SendSyncMessage();
        }
        //看是否还按住移动选项,如果按住,则继续walk

        if (!xHeroMotor.isOnGround)
        {
            mAnimatStateController.PlayAnimaState(NFAnimaStateType.Fall, -1);
        }
    }
コード例 #15
0
        public bool MoveTo(NFGUID ident, Vector3 vTar, float fSpeed, bool bRun)
        {
            if (fSpeed <= 0.01f)
            {
                return(false);
            }

            if (mhtObject.ContainsKey(ident))
            {
                GameObject  xGameObject = (GameObject)mhtObject[ident];
                NFHeroMotor xMotor      = xGameObject.GetComponent <NFHeroMotor>();
                NFBodyIdent xBodyIdent  = xGameObject.GetComponent <NFBodyIdent>();
                if (xMotor && xBodyIdent)
                {
                    xBodyIdent.LookAt(vTar);
                    xMotor.movement.Move(vTar - xGameObject.transform.position, Vector3.Distance(vTar, xGameObject.transform.position));
                }
            }

            return(false);
        }
コード例 #16
0
        public int PlayAnimaState(NFAnimaStateType eAnimaType, int index, bool force = false)
        {
            foreach (GameObject go in effectList)
            {
                if (go != null)
                {
                    Destroy(go);
                }
            }

            effectList.Clear();

            if (eAnimaType == NFAnimaStateType.Idle)
            {
                float f = Random.Range(0, 100);
                if (f < 15.0f)
                {
                    for (int i = 0; i < mxSkillData.AnimationSkillList.Count; ++i)
                    {
                        AnimationSkillStruct xAnimationSkillStruct = mxSkillData.AnimationSkillList[i];
                        if (xAnimationSkillStruct.Type == NFAnimaStateType.Idle1)
                        {
                            if (xAnimationSkillStruct.AnimationClip != null)
                            {
                                eAnimaType = NFAnimaStateType.Idle1;
                                break;
                            }
                        }
                    }
                }
                else if (f < 30.0f)
                {
                    for (int i = 0; i < mxSkillData.AnimationSkillList.Count; ++i)
                    {
                        AnimationSkillStruct xAnimationSkillStruct = mxSkillData.AnimationSkillList[i];
                        if (xAnimationSkillStruct.Type == NFAnimaStateType.Idle1)
                        {
                            if (xAnimationSkillStruct.AnimationClip != null)
                            {
                                eAnimaType = NFAnimaStateType.Idle2;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                if (eAnimaType == meLastPlayID && !force)
                {
                    return(-1);
                }
            }

            if (mBodyIdent == null)
            {
                mBodyIdent = GetComponent <NFBodyIdent>();
                if (mBodyIdent.xRenderObject)
                {
                    mAnimator = mBodyIdent.xRenderObject.GetComponent <Animator>();
                }
            }

            mxAnimationEvent.OnEndAnimaEvent(this.gameObject, meLastPlayID, index);

            meLastPlayID = eAnimaType;

            mxAnimationEvent.OnStartAnimaEvent(this.gameObject, eAnimaType, index);

            for (int i = 0; i < mxSkillData.AnimationSkillList.Count; ++i)
            {
                AnimationSkillStruct xAnimationSkillStruct = mxSkillData.AnimationSkillList[i];
                if (xAnimationSkillStruct.Type == eAnimaType)
                {
                    if (mBodyIdent.xRenderObject)
                    {
                        mBodyIdent.xRenderObject.gameObject.SetActive(xAnimationSkillStruct.visible);
                    }

                    if (xAnimationSkillStruct.AnimationClip != null)
                    {
                        //mAnimator.Play(eAnimaType.ToString());
                        if (mAnimator)
                        {
                            mAnimator.CrossFade(eAnimaType.ToString(), 0.1f);
                        }
                    }
                    else
                    {
                        //continue;
                        //Debug.LogWarning(eAnimaType.ToString() + " The AnimationClip is null!");
                        //UnityEditor.EditorUtility.DisplayDialog ("Warning", "The AnimationClip is null!", "OK", "Cancel");
                    }

                    foreach (EffectStruct es in xAnimationSkillStruct.EffectStructList)
                    {
                        if (es.Effect != null)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayEffect(es));
                        }
                    }
                    foreach (AudioStruct es in xAnimationSkillStruct.AudioStructList)
                    {
                        if (es.Audio != null)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayAudio(es));
                        }
                    }

                    foreach (BulletStruct es in xAnimationSkillStruct.BulletStructList)
                    {
                        if (es.Bullet != null)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayBullet(es));
                        }
                    }

                    foreach (MovementStruct es in xAnimationSkillStruct.MovementStructList)
                    {
                        es.Index = index;
                        StartCoroutine(WaitPlayMovement(es));
                    }

                    if (xAnimationSkillStruct.ActiveStructList.Count > 0)
                    {
                        foreach (ActiveStruct es in xAnimationSkillStruct.ActiveStructList)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayActive(es));
                        }
                    }

                    if (xAnimationSkillStruct.DamageStructList.Count > 0)
                    {
                        foreach (DamageStruct es in xAnimationSkillStruct.DamageStructList)
                        {
                            es.Index = index;
                            StartCoroutine(WaitPlayDamage(es));
                        }
                    }
                    else
                    {
                        // no bullet
                        if (xAnimationSkillStruct.BulletStructList.Count <= 0)
                        {
                            for (int j = 0; j < EnemyList.Count; ++j)
                            {
                                if (EnemyList[j] != null)
                                {
                                    mxAnimationEvent.NoDamageEvent(this.gameObject, EnemyList[j], eAnimaType, index);
                                }
                            }
                        }
                    }

                    foreach (CameraStruct es in xAnimationSkillStruct.CameraStructList)
                    {
                        es.Index = index;
                        StartCoroutine(WaitPlayCamera(es));
                    }

                    if (xAnimationSkillStruct.Type != NFAnimaStateType.Idle)
                    {
                        if (xAnimationSkillStruct.AnimationClip)
                        {
                            if (!xAnimationSkillStruct.AnimationClip.isLooping)
                            {
                                StartCoroutine(WaitPlayNextAnim(xAnimationSkillStruct.fTime, xAnimationSkillStruct.NextType, -1));
                            }
                        }
                        else if (xAnimationSkillStruct.Type != xAnimationSkillStruct.NextType)
                        {
                            StartCoroutine(WaitPlayNextAnim(xAnimationSkillStruct.fTime, xAnimationSkillStruct.NextType, -1));
                        }
                    }

                    //get time
                    if (eAnimaType != NFAnimaStateType.Idle)
                    {
                    }

                    break;
                }
            }

            return(index);
        }