void OnDrawGizmosSelected()
    {
        if (!enabled)
        {
            return;
        }
        CheckPathMarkScale();
        UpdateMeshFilter();

        Transform parTran    = transform.parent;
        NpcMark   markScript = parTran.GetComponent <NpcMark>();

        if (markScript != null)
        {
            markScript.DrawPath();
            return;
        }
        else
        {
            if (parTran.childCount > 1)
            {
                List <Transform> nodesTran = new List <Transform>(parTran.GetComponentsInChildren <Transform>())
                {
                };
                nodesTran.Remove(parTran);
                iTween.DrawPath(nodesTran.ToArray(), Color.blue);
                return;
            }
        }
    }
Пример #2
0
    void DelayMoveXieZiShouBi()
    {
        transform.parent = null;
        if (!NpcPathTr.gameObject.activeInHierarchy)
        {
            NpcPathTr.gameObject.SetActive(true);
        }

        List <Transform> markList = new List <Transform>(NpcPathTr.GetComponentsInChildren <Transform>());

        markList.RemoveAt(0);
        if (NpcPathTr.gameObject.activeInHierarchy)
        {
            NpcPathTr.gameObject.SetActive(false);
        }
        Transform[] tranArray  = markList.ToArray();
        NpcMark     markScript = tranArray[0].GetComponent <NpcMark>();
        float       mvSpeed    = markScript.MvSpeed;

        iTween.MoveTo(NpcObj, iTween.Hash("path", tranArray,
                                          "speed", mvSpeed,
                                          "orienttopath", true,
                                          "easeType", iTween.EaseType.linear,
                                          "oncomplete", "MoveNpcOnCompelteITween"));
    }
    void MoveNpcOnCompelteITween()
    {
        if (MarkCount >= NpcPathTran.childCount)
        {
            IsMoveEndPoint = true;
            if (NpcPathScript != null && NpcPathScript.IsMoveEndFire)
            {
                MakeNpcPlayFireAnimation();
            }
            else
            {
                MakeNpcPlayRootAnimation();
            }
            return;
        }

        Transform markTran   = NpcPathTran.GetChild(MarkCount - 1);
        NpcMark   markScript = markTran.GetComponent <NpcMark>();

        MvSpeed = markScript.MvSpeed;
        PlayNpcAnimation(markScript.AniName);

        //Debug.Log("MoveNpcOnCompelteITween...npc is "+NpcObj.name);
        if (markScript.AnimatorTime > 0f && markScript.AniName != AnimatorNameNPC.Null)
        {
            Invoke("DelayMoveNpcWaitAnimationEnd", markScript.AnimatorTime);
        }
        else
        {
            MoveNpcByItween();
        }
    }
Пример #4
0
    void MoveNpcOnCompelteITween()
    {
        if (MarkCount >= NpcPathTran.childCount)
        {
            //goto end point
            return;
        }

        Transform markTran   = NpcPathTran.GetChild(MarkCount - 1);
        NpcMark   markScript = markTran.GetComponent <NpcMark>();

        MvSpeed = markScript.MvSpeed;
        if (markScript.AniName != AnimatorNameNPC.Null)
        {
//			if (markScript.AniName == AnimatorNameNPC.TurnLeft || markScript.AniName == AnimatorNameNPC.TurnRight) {
//				AnimatorTran.parent = XkGameCtrl.MissionCleanup;
//				AnimatorTran.position = SpawnPointScript.HuoCheNpcTran.position;
//				AnimatorTran.rotation = SpawnPointScript.HuoCheNpcTran.rotation;
//			}
            PlayNpcAnimation(markScript.AniName.ToString());
            SendNpcPlayAnimation(markScript.AniName.ToString());
        }
        else
        {
            MoveNpcByItween();
        }
        //Debug.Log("MoveNpcOnCompelteITween...npc is "+NpcObj.name);
    }
Пример #5
0
    public void StartMoveHuoChe(Transform tranPath)
    {
        NpcObj       = gameObject;
        AnimatorTran = AnimatorCom.transform;
        NpcTran      = transform;
        NpcPathTran  = tranPath;
        Transform markTran   = NpcPathTran.GetChild(MarkCount);
        NpcMark   markScript = markTran.GetComponent <NpcMark>();

        MvSpeed = markScript.MvSpeed;
        Invoke("MoveNpcByItween", SpawnPointScript.TimeRootAni);
        //MoveNpcByItween();
    }
    void OnDrawGizmosSelected()
    {
        if (!enabled)
        {
            return;
        }

        if (AiPathMark != null)
        {
            Transform  AiPathTran = AiPathMark.transform.parent;
            AiPathCtrl pathScript = AiPathTran.GetComponent <AiPathCtrl>();
            pathScript.DrawPath();
        }

        if (NpcPathCtrl != null)
        {
            Transform NpcMarkTran   = NpcPathCtrl.transform.GetChild(0);
            NpcMark   NpcMarkScript = NpcMarkTran.GetComponent <NpcMark>();
            NpcMarkScript.DrawPath();
        }

        if (NpcPathCtrl != null || AiPathMark != null)
        {
            Transform [] tranArray = new Transform[2];
            if (NpcPathCtrl == null && AiPathMark != null)
            {
                tranArray[0] = transform;
                tranArray[1] = AiPathMark.transform;
                iTween.DrawPath(tranArray, Color.yellow);
            }
            else if (NpcPathCtrl != null)
            {
                tranArray[0] = transform;
                tranArray[1] = NpcPathCtrl.transform.GetChild(0);
                iTween.DrawPath(tranArray, Color.yellow);

                if (AiPathMark != null)
                {
                    tranArray[0] = NpcPathCtrl.transform.GetChild(NpcPathCtrl.transform.childCount - 1);
                    tranArray[1] = AiPathMark.transform;
                    iTween.DrawPath(tranArray, Color.yellow);
                }
            }
        }

        CheckTransformScale();
        UpdateMeshFilter();
    }
    public void SetNpcIsDoFire(NpcMark script)
    {
        //Debug.Log("SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
        if (!NpcScript.IsAniMove)
        {
            return;
        }

        if (SpawnPointScript == null)
        {
            return;
        }

        Transform npcPath = SpawnPointScript.NpcPath;
        Transform markPar = script.transform.parent;

        if (npcPath != markPar)
        {
            return;
        }
        //Debug.Log("***********SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
        NpcScript.SetIsDoFireAnimation(script.IsFireFeiJiNpc);
        NpcScript.SetFeiJiMarkInfo(script);
    }
Пример #8
0
//		public void SetIsStopMoveTarget(bool isStop)
//		{
//			IsStopMoveTarget = isStop;
//		}

        private void Update()
        {
            /*if (Input.GetKeyUp(KeyCode.P)) {
             *      SetCarPathInfo(circuit); //test
             * }*/

            if (IsStopMoveTarget)
            {
                return;
            }

            if (progressStyle == ProgressStyle.SmoothAlongRoute)
            {
                Vector3 vecA = circuit.Waypoints[progressNum].position - transform.position;
                Vector3 vecB = transform.forward;
                if (vecA.magnitude < 15f)
                {
                    vecA.y = vecB.y = 0f;
                    if (Vector3.Dot(vecA, vecB) < 0f)
                    {
                        NpcMark markScript = circuit.Waypoints[progressNum].GetComponent <NpcMark>();
                        if (markScript != null)
                        {
                            AiCarCom.SetAiCarTopMoveSpeed(markScript.MvSpeed);
                        }

                        progressNum++;
                        if (progressNum >= circuit.Waypoints.Length)
                        {
                            progressNum      = 0;
                            IsStopMoveTarget = true;
                            //stop move AiCar.
                            AiCarCom.SetIsStopMoveCar(true);
                            return;
                        }
                        //Debug.Log("Unity:"+"progressNum "+progressNum);
                    }
                }

                // determine the position we should currently be aiming for
                // (this is different to the current progress position, it is a a certain amount ahead along the route)
                // we use lerp as a simple way of smoothing out the speed over time.
                if (Time.deltaTime > 0)
                {
                    speed = Mathf.Lerp(speed, (lastPosition - transform.position).magnitude / Time.deltaTime,
                                       Time.deltaTime);
                }
                target.position =
                    circuit.GetRoutePoint(progressDistance + lookAheadForTargetOffset + lookAheadForTargetFactor * speed)
                    .position;
                target.rotation =
                    Quaternion.LookRotation(
                        circuit.GetRoutePoint(progressDistance + lookAheadForSpeedOffset + lookAheadForSpeedFactor * speed)
                        .direction);


                // get our current progress along the route
                progressPoint = circuit.GetRoutePoint(progressDistance);
                Vector3 progressDelta = progressPoint.position - transform.position;
                if (Vector3.Dot(progressDelta, progressPoint.direction) < 0)
                {
                    progressDistance += progressDelta.magnitude * 0.5f;
                }

                lastPosition = transform.position;
            }
            else
            {
                // point to point mode. Just increase the waypoint if we're close enough:

                Vector3 targetDelta = target.position - transform.position;
                if (targetDelta.magnitude < pointToPointThreshold)
                {
                    progressNum = (progressNum + 1) % circuit.Waypoints.Length;
                }

                target.position = circuit.Waypoints[progressNum].position;
                target.rotation = circuit.Waypoints[progressNum].rotation;

                // get our current progress along the route
                progressPoint = circuit.GetRoutePoint(progressDistance);
                Vector3 progressDelta = progressPoint.position - transform.position;
                if (Vector3.Dot(progressDelta, progressPoint.direction) < 0)
                {
                    progressDistance += progressDelta.magnitude;
                }
                lastPosition = transform.position;
            }
        }
Пример #9
0
    int AddCountFireAction()
    {
        if (IsDoHuanDanAction)
        {
//			Debug.LogWarning("Unity:"+"IsDoHuanDanAction is true");
            return(-1);
        }

        if (IsDoRunFireAction)
        {
//			Debug.LogWarning("Unity:"+"IsDoRunFireAction is true");
            return(-1);
        }

        CountFireAction++;
        FirePoint firePointScript = NpcScript.GetFirePointScript();

        if (firePointScript != null)
        {
            CountFireRun = firePointScript.CountFire;
            CountFireRunVal++;
//			Debug.Log("Unity:"+"CountFireAction "+CountFireAction+", CountFireRunVal "+CountFireRunVal);
            if (CountFireRun <= CountFireRunVal)
            {
                //Play Run_Fire Action
                CountFireRunVal = 0;
                MakeNpcDoActionRun3();
                NpcScript.MakeNpcMoveFirePoint();
                return(0);
            }
        }

        NpcMark markScript = NpcScript.GetMarkScriptVal();

        if (NpcScript != null && markScript != null && markScript.IsDoFireAction)
        {
            CountFireRun = markScript.FireCount;
            CountFireRunVal++;
            if (CountFireRun <= CountFireRunVal)
            {
                CountFireRunVal = 0;
                MakeNpcDoActionRun3();
                NpcScript.MoveNpcByItween();
                return(0);
            }
        }

        if (CountHuanDan <= 0)
        {
            return(0);
        }

        if (CountHuanDan <= CountFireAction)
        {
            //Stop Play Fire Action.
            CountFireAction = 0;
            DelayPlayFireAction();
            SetCountHuanDan(CountFirePL, TimeRootAni);
//			PlayNPCHuanDanAction();
        }
        return(0);
    }