void FixedUpdate()
    {
        if (MoveSpeed <= 0)
        {
            return;
        }
        float   disMove = MoveSpeed * Time.deltaTime;
        Vector3 dirMove = Vector3.Normalize(MarkCom.transform.position - transform.position);

        //transform.position += new Vector3(0f, 0f, disMove);
        transform.position += dirMove * disMove;

        if (Mathf.Abs(MarkCom.transform.position.z - transform.position.z) <= disMove * 1.25f)
        {
            //虚拟主角到达路径点.
            if (MarkCom.mNextMark != null)
            {
                MarkCom   = MarkCom.mNextMark.GetComponent <AiMark>();
                MoveSpeed = MarkCom.MvSpeed;
            }
            else
            {
                //没有下一个路径点了.
                MoveSpeed = 0f;
            }
        }
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        int count = transform.childCount;

        for (int i = 0; i < count; i++)
        {
            Transform mark       = transform.GetChild(i);
            AiMark    markScript = mark.GetComponent <AiMark>();
            markScript.setMarkCount(i);
            if (i < (count - 1))
            {
                markScript.mNextMark = transform.GetChild(i + 1);
            }
            else
            {
                if (mNextPath1 != null && mNextPath1.childCount > 0)
                {
                    markScript.mNextMark = mNextPath1.GetChild(0);
                }
                else if (mNextPath2 != null && mNextPath2.childCount > 0)
                {
                    markScript.mNextMark = mNextPath2.GetChild(0);
                }
            }
        }

        AiPathCtrl aiPath = gameObject.GetComponent <AiPathCtrl>();

        aiPath.enabled = false;
    }
    public void SetAimTranInfo(AiMark markScript)
    {
        if (AimNpcObj != null)
        {
//			Debug.Log("Unity:"+"SetAimTranInfo -> AimNpcObj should be null");
            return;
        }

        Transform aimVal = markScript.PlayerCamAimTran;

        if (aimVal == null)
        {
            if (AimTran != null)
            {
                IsOutAim = true;
            }
            else
            {
                IsOutAim = false;
            }
        }
        else
        {
            SpeedIntoAim = markScript.SpeedIntoAim;
            SpeedOutAim  = markScript.SpeedOutAim;
            //Debug.Log("Unity:"+"111*************SpeedOutAim "+SpeedOutAim);
        }

        AimTran = aimVal;
    }
Example #4
0
    void InitMovePlayerByMarkSpeed()
    {
        Transform tran = AiPathScript.transform;

        Transform[] tranArray = new Transform[2];
        tranArray[0] = transform;
        tranArray[1] = tran.GetChild(MarkCount);

        EndPos = tranArray[1].position;
        AiMark markScript = tranArray[1].GetComponent <AiMark>();

//		AimMvToMarkTran = markScript.transform;
        if (EndPos == tranArray[0].position)
        {
            //move to next mark point
            SpeedA = markScript.MvSpeed;
            MovePlayerOnCompelteITween();
            return;
        }

        PathNodes = AiPathScript.GetPathNodes(MarkCount);
        if (PathNodes == null)
        {
            Debug.Log("PathNodes is null! MarkCount " + MarkCount);
            return;
        }

        EndPos         = PathNodes[1];
        ForwardMoveVal = Vector3.Normalize(EndPos - tranArray[0].position);
        SpeedB         = markScript.MvSpeed;
        float disVal   = 0f;
        int   maxNodes = PathNodes.Length;

        for (int i = 1; i < maxNodes; i++)
        {
            disVal += Vector3.Distance(PathNodes[i - 1], PathNodes[i]);
        }

        float timeVal = (2f * disVal) / (SpeedA + SpeedB);

        TimeRotation = timeVal;
        if (SpeedB != SpeedA)
        {
            JiaSuDuVal = ((SpeedB - SpeedA) * (SpeedA + SpeedB)) / (2f * disVal);
        }
        else
        {
            JiaSuDuVal = 0f;
        }
        RotationStart = tranArray[0].rotation;
        RotationEnd   = tranArray[1].rotation;
//		Debug.LogError("SpeedA *** "+SpeedA+", MarkCount "+MarkCount+", maxNodes "+maxNodes);
//		Debug.LogWarning("SpeedA *** "+SpeedA+", SpeedB "+SpeedB);
        if (!IsStartMovePlayerByMark)
        {
            gameObject.SetActive(true);
            StartCoroutine(MovePlayerByMarkSpeed());
            IsStartMovePlayerByMark = true;
        }
    }
    public void SetHuanWeiFuActiveInfo(int countPath, int countMark)
    {
        if (IsActiveHuanWeiPos)
        {
            return;
        }
        IsActiveHuanWeiPos = true;
        AiPathCtrlTran     = AiPathGroupCtrl.FindAiPathTran(countPath);
        StartMarkCount     = countMark;

        if (AiPathCtrlTran != null)
        {
            AimMarkTran = AiPathCtrlTran.GetChild(StartMarkCount);

            AiMark     markAimScript = AimMarkTran.GetComponent <AiMark>();
            AiPathCtrl pathScript    = AiPathCtrlTran.GetComponent <AiPathCtrl>();
            SetPlayerAimMarkData(pathScript.PathIndex, markAimScript.getMarkCount(), PlayerTran.name);
        }

        iTween itweenScript = GetComponent <iTween>();

        if (itweenScript != null)
        {
            itweenScript.isRunning = false;
            Destroy(itweenScript);
        }
        Invoke("MoveAiPlayerByItween", 0.05f);
    }
Example #6
0
    void SetIsPlayerTingLiu(AiMark markScript)
    {
        if (markScript.PlayerAni != ZhiShengJiAction.Null)
        {
            return;
        }

        IsPlayerTingLiu = markScript.TimePlayerAni > 0f ? true : false;
        TimeTingLiuVal  = markScript.TimePlayerAni;
    }
    void checkPlayerMoveDir()
    {
        if (IsActiveHuanWeiPos)
        {
            return;
        }

        if (AimMarkTran == null)
        {
            return;
        }

        Vector3 posA = AimMarkTran.position;
        Vector3 posB = PlayerTran.position;

        posA.y = posB.y = 0f;
        Vector3 vecB = posA - posB;

        if (Vector3.Distance(posA, posB) > 18f)
        {
            return;
        }

        Vector3 vecA = AimMarkTran.forward;

        vecA.y = vecB.y = 0f;
        float cosAB = Vector3.Dot(vecA, vecB);

        if (cosAB <= 0f)
        {
            AiMark markScript = AimMarkTran.GetComponent <AiMark>();
            if (markScript == null)
            {
                return;
            }
            int conutTmp  = AimMarkTran.parent.childCount - 1;
            int markCount = markScript.getMarkCount();

            if (markCount != conutTmp)
            {
                AimMarkTran = markScript.mNextMark;
            }

            if (AimMarkTran != null)
            {
                AiMark     markAimScript = AimMarkTran.GetComponent <AiMark>();
                AiPathCtrl pathScript    = AiPathCtrlTran.GetComponent <AiPathCtrl>();
                SetPlayerAimMarkData(pathScript.PathIndex, markAimScript.getMarkCount(), PlayerTran.name);
                UpdateAiPlayerAction();
            }
        }
    }
Example #8
0
    public void MakePlayerMoveToAiMark(AiMark script)
    {
        IsMoveToAiMark = true;
        Transform markTran = script.transform;

        transform.position = markTran.position;
        transform.rotation = markTran.rotation;

        MarkCount    = script.getMarkCount();
        AiPathScript = markTran.parent.GetComponent <AiPathCtrl>();
        InitMovePlayerByMarkSpeed();
        IsMoveToAiMark = false;
    }
Example #9
0
    public void SetCameraMarkInfo(AiMark script)
    {
        if (script == null)
        {
            return;
        }

        if (script.IsAimPlayer)
        {
            ZiYouCamera.ChangeAimTran(AimTran, script);
        }
        else
        {
            ZiYouCamera.ChangeAimTran(null, null);
        }
    }
    // Use this for initialization
    void Start()
    {
//		MeshRenderer mesh = GetComponent<MeshRenderer>();
//		if(mesh)
//		{
//			//mesh.enabled = false;
//		}
        Vector3 scale = transform.localScale;

        scale.y = 2f;
        transform.localScale = scale;

        tag = "mark";

        AiMark aiMark = gameObject.GetComponent <AiMark>();

        aiMark.enabled = false;
    }
    public void SetCameraMarkInfo(AiMark script)
    {
        Debug.Log("SetCameraMarkInfo...");
        if (script == null)
        {
            return;
        }

        if (script.IsAimPlayer)
        {
            GameObject playerObj = XkGameCtrl.GetInstance().GetRandAimPlayerObj();
            AimTran = playerObj == null ? null : playerObj.transform;
            ZiYouCamera.ChangeAimTran(AimTran, script);
        }
        else
        {
            ZiYouCamera.ChangeAimTran(null, null);
        }
    }
    void Start()
    {
        IsActiveOpenPlayerUI = false;
        AiMarkComStatic      = AiMarkCom;

        MeshRenderer mesh = gameObject.GetComponent <MeshRenderer>();

        if (mesh != null)
        {
            Destroy(mesh);
        }

        MeshFilter meshFt = gameObject.GetComponent <MeshFilter>();

        if (meshFt != null)
        {
            Destroy(meshFt);
        }
    }
Example #13
0
    public void SetAimTranInfo(AiMark markScript)
    {
//		if (XkGameCtrl.GetInstance().IsOpenVR) {
//			return;
//		}

        if (AimNpcObj != null)
        {
//			Debug.Log("SetAimTranInfo -> AimNpcObj should be null");
            return;
        }

        Transform aimVal = markScript.PlayerCamAimTran;

//		PlayerStopTimeVal = markScript.TimePlayerAni;
//		if (PlayerStopTimeVal > 0f && markScript.PlayerAni == ZhiShengJiAction.Null) {
//			IsHandleCameraAimArray = true;
//			CamAimArrayIndex = 0;
        //CameraAimArray = markScript.CameraAimArray;
        //Invoke("StopCameraAimTranArray", PlayerStopTimeVal);
//		}

        if (aimVal == null)
        {
            if (AimTran != null)
            {
                IsOutAim = true;
            }
            else
            {
                IsOutAim = false;
            }
        }
        else
        {
            SpeedIntoAim = markScript.SpeedIntoAim;
            SpeedOutAim  = markScript.SpeedOutAim;
            //Debug.Log("111*************SpeedOutAim "+SpeedOutAim);
        }

        AimTran = aimVal;
    }
Example #14
0
    public void ChangeAimTran(Transform aimVal, AiMark markScript)
    {
//		string info = "ChangeAimTran...";
//		info += aimVal != null ? "aim "+aimVal.name : "";
//		Debug.Log(info);
        if (aimVal == null)
        {
            if (AimTran != null)
            {
                IsOutAim = true;
            }
            else
            {
                IsOutAim = false;
            }
        }
        else
        {
            SpeedIntoAim = markScript.SpeedIntoAim;
            SpeedOutAim  = markScript.SpeedOutAim;
        }
        AimTran = aimVal;
    }
    void OnFinishMoveAiPlayerByPath()
    {
        AiPathCtrl pathScript = AimMarkTran.parent.GetComponent <AiPathCtrl>();
        int        rv         = pathScript.GetNextPathNum();

        if (rv > 0)
        {
            int       key        = 0;
            Transform trNextPath = null;
            while (trNextPath == null)
            {
                int randVal = Random.Range(0, 1000) % 3;
                switch (randVal)
                {
                case 0:
                    trNextPath = pathScript.mNextPath1;
                    break;

                case 1:
                    trNextPath = pathScript.mNextPath2;
                    break;

                case 2:
                    trNextPath = pathScript.mNextPath3;
                    break;
                }

                key++;
                if (key > 2)
                {
                    if (pathScript.mNextPath1 != null)
                    {
                        trNextPath = pathScript.mNextPath1;
                    }
                    else if (pathScript.mNextPath2 != null)
                    {
                        trNextPath = pathScript.mNextPath2;
                    }
                    else if (pathScript.mNextPath3 != null)
                    {
                        trNextPath = pathScript.mNextPath3;
                    }
                    break;
                }
            }

            if (trNextPath != null)
            {
                AimMarkTran = trNextPath.GetChild(0);
            }
        }
        else
        {
            Invoke("MoveAiPlayerToEndPos", 0.05f);
            return;
        }
        SetPlayerPathCount();

        AiPathCtrlTran = AimMarkTran.parent;

        if (AimMarkTran != null)
        {
            AiMark markAimScript = AimMarkTran.GetComponent <AiMark>();
            pathScript = AiPathCtrlTran.GetComponent <AiPathCtrl>();
            SetPlayerAimMarkData(pathScript.PathIndex, markAimScript.getMarkCount(), PlayerTran.name);
            UpdateAiPlayerAction();
        }
        Invoke("MoveAiPlayerByItween", 0.05f);
    }
Example #16
0
    void CheckNetPlayerRank()
    {
        if (IsStopCheckRank)
        {
            CancelInvoke("CheckNetPlayerRank");
            return;
        }

        /*if (Time.frameCount % 100 == 0) {
         *      Debug.Log("*****************");
         * }*/

        int        j             = 0;
        bool       isContinue    = false;
        AiPathCtrl pathScriptPar = null;
        AiPathCtrl pathScriptCh  = null;

        for (int i = 0; i < MaxPlayerRankNum; i++)
        {
            if (IsStopCheckRank)
            {
                break;
            }

            if (mRankPlayer[i].IsRunToEndPoint)
            {
                continue;
            }

            if (mRankPlayer[i].AimMarkDataScript != null)
            {
                mRankPlayer[i].IsPlayer = mRankPlayer[i].AimMarkDataScript.GetIsPlayer();
                isContinue = mRankPlayer[i].AimMarkDataScript.GetIsGameOver();
            }
            else
            {
                isContinue = true;
                mRankPlayer[i].IsPlayer = false;
            }

            if (isContinue)
            {
                isContinue = false;
                continue;
            }

            j = i + 1;
            if (j > 7)
            {
                break;
            }

            parentPlayer = mRankPlayer[i].Player;
            childPlayer  = mRankPlayer[j].Player;
            aimMarkPar   = mRankPlayer[i].mPlayerAimMark;
            aimMarkCh    = mRankPlayer[j].mPlayerAimMark;
            if (parentPlayer == null || childPlayer == null || aimMarkPar == null || aimMarkCh == null)
            {
                continue;
            }

            int pathKeyP = mRankPlayer[i].mBikePathKey;
            int pathKeyC = mRankPlayer[j].mBikePathKey;
            if (pathKeyP < pathKeyC)
            {
                /*if(mRankPlayer[i].IsPlayer || mRankPlayer[j].IsPlayer)
                 * {
                 *      Debug.Log("***************************1111, IsPlayer_1 " + mRankPlayer[i].IsPlayer
                 + ", IsPlayer_2 " + mRankPlayer[j].IsPlayer);
                 + }*/
                UpdateNetPlayerRank(j);
                break;
            }
            else if (pathKeyP > pathKeyC)
            {
                continue;
            }

            int pathIdPar = aimMarkPar.parent.GetInstanceID();
            int pathIdCh  = aimMarkCh.parent.GetInstanceID();
            if (pathIdPar == pathIdCh)
            {
                AiMark markScriptP = aimMarkPar.GetComponent <AiMark>();
                AiMark markScriptC = aimMarkCh.GetComponent <AiMark>();
                int    markCountP  = markScriptP.getMarkCount();
                int    markCountC  = markScriptC.getMarkCount();
                if (markCountP < markCountC)
                {
                    /*if(mRankPlayer[i].IsPlayer || mRankPlayer[j].IsPlayer)
                     * {
                     *      Debug.Log("***************************2222, IsPlayer_1 " + mRankPlayer[i].IsPlayer
                     + ", IsPlayer_2 " + mRankPlayer[j].IsPlayer);
                     + }*/
                    UpdateNetPlayerRank(j);
                    break;
                }
                else if (markCountP > markCountC)
                {
                    continue;
                }
            }
            else
            {
                pathScriptPar = aimMarkPar.parent.GetComponent <AiPathCtrl>();
                pathScriptCh  = aimMarkCh.parent.GetComponent <AiPathCtrl>();
                if (pathScriptPar.KeyState > pathScriptCh.KeyState)
                {
                    continue;
                }
                else if (pathScriptPar.KeyState < pathScriptCh.KeyState)
                {
                    UpdateNetPlayerRank(j);
                    break;
                }
            }

            Vector3 vecA = parentPlayer.transform.position - childPlayer.transform.position;
            Vector3 vecB = aimMarkPar.position - parentPlayer.transform.position;
            Vector3 vecC = childPlayer.transform.forward;
            Vector3 vecD = parentPlayer.transform.forward;
            vecA.y = 0f;
            vecB.y = 0f;
            vecC.y = 0f;
            vecD.y = 0f;
            vecA   = vecA.normalized;
            vecB   = vecB.normalized;
            vecC   = vecC.normalized;
            vecD   = vecD.normalized;

            float cosDB = Vector3.Dot(vecD, vecB);
            float cosDC = Vector3.Dot(vecD, vecC);
            float cosAC = Vector3.Dot(vecA, vecC);
            if ((cosDB > 0f && cosDC > 0f && cosAC < 0f) ||
                (cosDB <= 0f && cosDC > 0f && cosAC > 0f) ||
                (cosDB <= 0f && cosDC <= 0f && cosAC < 0f))
            {
                /*if(mRankPlayer[i].IsPlayer || mRankPlayer[j].IsPlayer)
                 * {
                 *      Debug.Log("*********33333, IsPlayer_1 " + mRankPlayer[i].IsPlayer
                 + ", IsPlayer_2 " + mRankPlayer[j].IsPlayer
                 + ", pathIdPar " + pathIdPar + ", pathIdCh " + pathIdCh);
                 + }*/
                UpdateNetPlayerRank(j);
                break;
            }
            //Debug.Log("i = " + i + ", j = " + j);
        }
        return;
    }
    void InitMovePlayerByMarkSpeed()
    {
        Transform tran = AiPathScript.transform;

        Transform[] tranArray = new Transform[2];
        tranArray[0] = transform;
        tranArray[1] = tran.GetChild(MarkCount);
        //		Debug.Log("Unity:"+"InitMovePlayerByMarkSpeed -> path "+AiPathScript.name
        //		          +", mark "+tranArray[1].name);

        //if (tranArray[1] == XkGameCtrl.GetInstance().GmCamMark.transform)
        //{
        //    QuanShuCount++;
        //    if (QuanShuCount > 1)
        //    {
        //        XkGameCtrl.GetInstance().AddPlayerQuanShu();
        //    }
        //}

        EndPos = tranArray[1].position;
        AiMark markScript = tranArray[1].GetComponent <AiMark>();

        AimMvToMarkTran = markScript.transform;
        if (EndPos == tranArray[0].position)
        {
            //move to next mark point
            SpeedA = markScript.GetMvSpeed();
            MovePlayerOnCompelteITween();
            return;
        }

        PathNodes = AiPathScript.GetPathNodes(MarkCount);
        if (PathNodes == null)
        {
            Debug.Log("Unity:" + "PathNodes is null! MarkCount " + MarkCount);
            return;
        }

        EndPos         = PathNodes[1];
        ForwardMoveVal = Vector3.Normalize(EndPos - tranArray[0].position);
        SpeedB         = markScript.GetMvSpeed();
        float disVal   = 0f;
        int   maxNodes = PathNodes.Length;

        for (int i = 1; i < maxNodes; i++)
        {
            disVal += Vector3.Distance(PathNodes[i - 1], PathNodes[i]);
        }

        float timeVal = (2f * disVal) / (SpeedA + SpeedB);

        TimeRotation = timeVal;
        if (SpeedB != SpeedA)
        {
            JiaSuDuVal = ((SpeedB - SpeedA) * (SpeedA + SpeedB)) / (2f * disVal);
        }
        else
        {
            JiaSuDuVal = 0f;
        }
        RotationStart = tranArray[0].rotation;
        RotationEnd   = tranArray[1].rotation;
//		Debug.LogError("Unity:"+"SpeedA *** "+SpeedA+", MarkCount "+MarkCount+", maxNodes "+maxNodes);
//		Debug.LogWarning("Unity:"+"SpeedA *** "+SpeedA+", SpeedB "+SpeedB);
        if (!IsStartMovePlayerByMark)
        {
            StartCoroutine(MovePlayerByMarkSpeed());
            IsStartMovePlayerByMark = true;

            if (PlayerSt == PlayerTypeEnum.FeiJi)
            {
                if (m_SpawnNpcManage != null)
                {
                    m_SpawnNpcManage.MakeAllCreatNpcPointsToLand();
                }
                XkGameCtrl.GetInstance().OpenAllAiPlayerTank();
            }
        }
    }
 public void InitXuNiPlayerInfo(AiMark mark)
 {
     MarkCom   = mark;
     MoveSpeed = mark.MvSpeed;
 }
    // Use this for initialization
    void Start()
    {
        ChuanShenScript  = GetComponentInChildren <ChuanShenCtrl>();
        ZhuJiaoNanScript = GetComponentInChildren <ZhuJiaoNan>();

        netView = GetComponent <NetworkView>();
        if (AimMarkDataScript == null)
        {
            AimMarkDataScript = gameObject.AddComponent <PlayerAimMarkData>();
        }

        PlayerObj          = gameObject;
        PlayerTran         = transform;
        RigObj             = GetComponent <Rigidbody>();
        RigObj.isKinematic = true;

        SetRankPlayerArray();

        mGameTime = 1000;
        CreatePlayerNeedObj();

        AiPathCtrlTran = GameCtrlXK.GetInstance().AiPathCtrlTran.GetChild(0);
        AimMarkTran    = AiPathCtrlTran.GetChild(0);
        if (AimMarkTran != null)
        {
            AiMark     markAimScript = AimMarkTran.GetComponent <AiMark>();
            AiPathCtrl pathScript    = AiPathCtrlTran.GetComponent <AiPathCtrl>();
            SetPlayerAimMarkData(pathScript.PathIndex, markAimScript.getMarkCount(), PlayerTran.name);
        }

        mBakeTimePointPos  = AimMarkTran.position;
        mBakeTimePointPos += Vector3.up * 0.5f;
        mBakeTimePointRot  = AimMarkTran.forward;

        if (GameCtrlXK.GetInstance().PlayerMarkTest != null)
        {
            AiPathCtrlTran = GameCtrlXK.GetInstance().PlayerMarkTest.parent;
            AiMark markScript = GameCtrlXK.GetInstance().PlayerMarkTest.GetComponent <AiMark>();
            AimMarkTran = markScript.mNextMark;
            if (AimMarkTran != null)
            {
                AiMark     markAimScript = AimMarkTran.GetComponent <AiMark>();
                AiPathCtrl pathScript    = AiPathCtrlTran.GetComponent <AiPathCtrl>();
                SetPlayerAimMarkData(pathScript.PathIndex, markAimScript.getMarkCount(), PlayerTran.name);
            }
            TestPosCount++;

            Transform posTran = GameCtrlXK.GetInstance().PlayerMarkTest;
            mBakeTimePointRot   = posTran.forward;
            mBakeTimePointRot.y = 0f;
            switch (TestPosCount)
            {
            case 1:
                mBakeTimePointPos = posTran.position - posTran.right * 9f + mBakeTimePointRot;
                break;

            case 2:
                mBakeTimePointPos = posTran.position + posTran.right * 9f + mBakeTimePointRot;
                break;

            case 3:
                mBakeTimePointPos = posTran.position - posTran.right * 6f + mBakeTimePointRot * 4f;
                break;

            case 4:
                mBakeTimePointPos = posTran.position + posTran.right * 6f + mBakeTimePointRot * 4f;
                break;

            case 5:
                mBakeTimePointPos = posTran.position - posTran.right * 3f + mBakeTimePointRot * 7f;
                break;

            case 6:
                mBakeTimePointPos = posTran.position + posTran.right * 3f + mBakeTimePointRot * 7f;
                break;

            case 7:
                mBakeTimePointPos = posTran.position + mBakeTimePointRot * 10f;
                TestPosCount      = 0;
                break;
            }
            mBakeTimePointPos  += Vector3.up * 0.5f;
            PlayerTran.position = mBakeTimePointPos;
            PlayerTran.forward  = mBakeTimePointRot;
        }
    }
    void CheckMoreNextPathDir()
    {
        if (AiParentPathScript == null)
        {
            return;
        }

        bool isDirRight = false;

        //int [] DirTag = new int[3]; //DirTag: 0 -> dir is wrong, 1 -> dir is right.
        Transform [] aimMarkTranArray = new Transform[3];
        aimMarkTranArray[0] = AiParentPathScript.mNextPath1;
        aimMarkTranArray[1] = AiParentPathScript.mNextPath2;
        aimMarkTranArray[2] = AiParentPathScript.mNextPath3;

        Transform aimMarkTran = null;
        Vector3   vecA        = Vector3.zero;
        Vector3   vecB        = Vector3.zero;
        Vector3   vecC        = Vector3.zero;
        float     cosAC       = 0f;
        float     cosAB       = 0f;
        float     cosBC       = 0f;

        for (int i = 0; i < 3; i++)
        {
            if (aimMarkTranArray[i] == null)
            {
                continue;
            }

            aimMarkTran = aimMarkTranArray[i].GetChild(0);
            if (aimMarkTran == null)
            {
                continue;
            }

            vecA   = aimMarkTran.forward;
            vecB   = aimMarkTran.position - PlayerTran.position;
            vecC   = PlayerTran.forward;
            vecA.y = vecB.y = vecC.y = 0f;
            cosAC  = Vector3.Dot(vecA, vecC);
            cosAB  = Vector3.Dot(vecA, vecB);
            cosBC  = Vector3.Dot(vecB, vecC);

            if (cosAC < 0f && cosBC < 0f)
            {
                //dir is wrong.
            }
            else
            {
                isDirRight = true;
                float disAB = Vector3.Distance(vecB, Vector3.zero);
                if (cosAB <= 0f && disAB < 15f)
                {
                    IsCheckMoreNextPath = false;
                    ParentPath          = aimMarkTran.parent;
                    AimMarkTran         = aimMarkTran;

                    AiMark markScript = AimMarkTran.GetComponent <AiMark>();
                    if (markScript == null)
                    {
                        continue;
                    }
                    mBakeTimePointPos = AimMarkTran.position;
                    mBakeTimePointRot = AimMarkTran.forward;
                    AutoFireScript.SetPlayerPreMark(AimMarkTran);

                    int conutTmp  = AimMarkTran.parent.childCount - 1;
                    int markCount = markScript.getMarkCount();
                    AimMarkTran    = markScript.mNextMark;
                    AiPathCtrlTran = AimMarkTran.parent;
                    AutoFireScript.SetPathKeyState(AiPathCtrlTran.GetComponent <AiPathCtrl>());

                    if (markCount == conutTmp)
                    {
                        if (AimMarkTran == null)
                        {
                            //player run to end
                            this.enabled = false;

                            DaoJiShiCtrl.GetInstance().StopDaoJiShi();
                            GameOverCtrl.GetInstance().HiddenContinueGame();
                            FinishPanelCtrl.GetInstance().ShowFinishPanel();

                            AutoFireScript.SetPlayerMvSpeed(0f);
                            //AutoFireScript.CloseWaterParticle();
                            return;
                        }
                        AiPathCtrlTran = AimMarkTran.parent;                         //next path
                        AutoFireScript.SetPathKeyState(AiPathCtrlTran.GetComponent <AiPathCtrl>());

                        if (ParentPath != null)
                        {
                            AiParentPathScript = ParentPath.GetComponent <AiPathCtrl>();
                            if (AiParentPathScript.GetNextPathNum() > 1)
                            {
                                IsCheckMoreNextPath = true;
                            }
                        }
                    }
                    return;
                }
            }
        }

        if (isDirRight && !AutoFireScript.CheckPlayerIsMoveDirWrong())
        {
            IsDonotTurnRight = false;
            IsDonotTurnLeft  = false;
            SetIsDirWrong(false);
        }
        else
        {
            if (!IsDonotTurnRight && !IsDonotTurnLeft &&
                (AutoFireScript.PathKeyState == 0 ||
                 IntoPuBuCtrl.IsIntoPuBu ||
                 PlayerAutoFire.IsRestartMove))
            {
                if (bIsTurnRight)
                {
                    IsDonotTurnRight = true;
                    IsDonotTurnLeft  = false;
                }
                else if (bIsTurnLeft)
                {
                    IsDonotTurnRight = false;
                    IsDonotTurnLeft  = true;
                }
            }
            SetIsDirWrong(true);
        }
    }
    void checkPlayerMoveDir()
    {
        if (IsCheckMoreNextPath)
        {
            CheckMoreNextPathDir();
            return;
        }

        if (AimMarkTran == null)
        {
            return;
        }

        Vector3 vecA = AimMarkTran.forward;
        Vector3 vecB = AimMarkTran.position - PlayerTran.position;
        Vector3 vecC = PlayerTran.forward;

        vecA.y = vecB.y = vecC.y = 0f;
        float cosAC = Vector3.Dot(vecA, vecC);
        float cosAB = Vector3.Dot(vecA, vecB);
        float cosBC = Vector3.Dot(vecB, vecC);

        if (cosAC < 0f && cosBC < 0f && !GameOverCtrl.GetInstance().CheckIsActiveOver())
        {
            if (!IsDonotTurnRight && !IsDonotTurnLeft &&
                (AutoFireScript.PathKeyState == 0 ||
                 IntoPuBuCtrl.IsIntoPuBu ||
                 PlayerAutoFire.IsRestartMove))
            {
                if (bIsTurnRight)
                {
                    IsDonotTurnRight = true;
                    IsDonotTurnLeft  = false;
                }
                else if (bIsTurnLeft)
                {
                    IsDonotTurnRight = false;
                    IsDonotTurnLeft  = true;
                }
            }
            SetIsDirWrong(true);
        }
        else
        {
            IsDonotTurnRight = false;
            IsDonotTurnLeft  = false;

            SetIsDirWrong(false);
            if (cosBC <= 0f && cosAB <= 0f)
            {
                ParentPath = AimMarkTran.parent;                 //next path
                AiMark markScript = AimMarkTran.GetComponent <AiMark>();
                if (markScript == null)
                {
                    return;
                }
                mBakeTimePointPos = AimMarkTran.position;
                mBakeTimePointRot = AimMarkTran.forward;
                AutoFireScript.SetPlayerPreMark(AimMarkTran);

                int conutTmp  = AimMarkTran.parent.childCount - 1;
                int markCount = markScript.getMarkCount();
                AimMarkTran = markScript.mNextMark;
                if (markCount == conutTmp)
                {
                    if (AimMarkTran == null)
                    {
                        //player run to end
                        this.enabled = false;
//						IsRunToEndPoint = true;

                        DaoJiShiCtrl.GetInstance().StopDaoJiShi();
                        GameOverCtrl.GetInstance().HiddenContinueGame();
                        FinishPanelCtrl.GetInstance().ShowFinishPanel();

                        AutoFireScript.SetPlayerMvSpeed(0f);
                        //AutoFireScript.CloseWaterParticle();
                        return;
                    }
                    AiPathCtrlTran = AimMarkTran.parent;                     //next path
                    AutoFireScript.SetPathKeyState(AiPathCtrlTran.GetComponent <AiPathCtrl>());

                    if (ParentPath != null)
                    {
                        AiParentPathScript = ParentPath.GetComponent <AiPathCtrl>();
                        if (AiParentPathScript.GetNextPathNum() > 1)
                        {
                            IsCheckMoreNextPath = true;
                        }
                    }
                }
            }
        }
    }
Example #22
0
 void Start()
 {
     IsActiveOpenPlayerUI = false;
     AiMarkComStatic      = AiMarkCom;
 }
Example #23
0
 public void PlayZhuJiaoMarkAction(AiMark markScript)
 {
     SetIsPlayerTingLiu(markScript);
     //PlayerCamera.SetAimTranInfo(markScript);
 }
Example #24
0
    void checkNetPlayerRank()
    {
        if (IsStopCheckRank)
        {
            CancelInvoke("checkNetPlayerRank");
            return;
        }

        if (mRankPlayer == null)
        {
            return;
        }

        int  j          = 0;
        bool isContinue = false;

        for (int i = 0; i < 8; i++)
        {
            if (mRankPlayer[i].NetScript != null)
            {
                mRankPlayer[i].IsPlayer = mRankPlayer[i].NetScript.CheckObjIsPlayer();
                isContinue = mRankPlayer[i].NetScript.GetIsGameOver();
            }
            else if (mRankPlayer[i].AiNetScript != null)
            {
                mRankPlayer[i].IsPlayer = false;
                isContinue = mRankPlayer[i].AiNetScript.GetIsStopMoveAi();
            }
            else
            {
                isContinue = true;
                mRankPlayer[i].IsPlayer = false;
            }

            if (isContinue)
            {
                isContinue = false;
                continue;
            }

            j = i + 1;
            if (j > 7)
            {
                break;
            }

            parentPlayer = mRankPlayer[i].player;
            childPlayer  = mRankPlayer[j].player;
            aimMarkPar   = mRankPlayer[i].mBikeAimMark;
            aimMarkCh    = mRankPlayer[j].mBikeAimMark;
            if (parentPlayer == null || childPlayer == null || aimMarkPar == null || aimMarkCh == null)
            {
                continue;
            }

            int pathKeyP = mRankPlayer[i].mBikePathKey;
            int pathKeyC = mRankPlayer[j].mBikePathKey;
            if (pathKeyP < pathKeyC)
            {
//				if(mRankPlayer[i].IsPlayer || mRankPlayer[j].IsPlayer)
//				{
//					Debug.Log("***************************1111, IsPlayer_1 " + mRankPlayer[i].IsPlayer
//					          + ", IsPlayer_2 " + mRankPlayer[j].IsPlayer);
//				}
                updateNetPlayerRank(j);
                break;
            }
            else if (pathKeyP > pathKeyC)
            {
                continue;
            }

            int pathIdPar = aimMarkPar.parent.GetInstanceID();
            int pathIdCh  = aimMarkCh.parent.GetInstanceID();
            if (pathIdPar == pathIdCh)
            {
                AiMark markScriptP = aimMarkPar.GetComponent <AiMark>();
                AiMark markScriptC = aimMarkCh.GetComponent <AiMark>();
                int    markCountP  = markScriptP.getMarkCount();
                int    markCountC  = markScriptC.getMarkCount();
                if (markCountP < markCountC)
                {
//					if(mRankPlayer[i].IsPlayer || mRankPlayer[j].IsPlayer)
//					{
//						Debug.Log("***************************2222, IsPlayer_1 " + mRankPlayer[i].IsPlayer
//						          + ", IsPlayer_2 " + mRankPlayer[j].IsPlayer);
//					}
                    updateNetPlayerRank(j);
                    break;
                }
                else if (markCountP > markCountC)
                {
                    continue;
                }
            }

            Vector3 vecA = parentPlayer.transform.position - childPlayer.transform.position;
            Vector3 vecB = aimMarkPar.position - parentPlayer.transform.position;
            Vector3 vecC = childPlayer.transform.forward;
            Vector3 vecD = parentPlayer.transform.forward;
            vecA.y = 0f;
            vecB.y = 0f;
            vecC.y = 0f;
            vecD.y = 0f;
            vecA   = vecA.normalized;
            vecB   = vecB.normalized;
            vecC   = vecC.normalized;
            vecD   = vecD.normalized;

            float cosDB = Vector3.Dot(vecD, vecB);
            float cosDC = Vector3.Dot(vecD, vecC);
            float cosAC = Vector3.Dot(vecA, vecC);
            if ((cosDB > 0f && cosDC > 0f && cosAC < 0f) ||
                (cosDB <= 0f && cosDC > 0f && cosAC > 0f) ||
                (cosDB <= 0f && cosDC <= 0f && cosAC < 0f))
            {
//				if(mRankPlayer[i].IsPlayer || mRankPlayer[j].IsPlayer)
//				{
//					Debug.Log("*********33333, IsPlayer_1 " + mRankPlayer[i].IsPlayer
//					          + ", IsPlayer_2 " + mRankPlayer[j].IsPlayer
//					          + ", pathIdPar " + pathIdPar + ", pathIdCh " + pathIdCh);
//				}
                updateNetPlayerRank(j);
                break;
            }
            //Debug.Log("i = " + i + ", j = " + j);
        }
        return;
    }