Пример #1
0
 public void LateUpdate()
 {
     //LocalSpeed = transform.InverseTransformDirection(m_Rigidbody.velocity);
     Speed                  = (this.transform.position - LastPosition) / Time.deltaTime;
     LocalSpeed             = transform.InverseTransformDirection(Speed);
     carController.Skidding = Vector3.Angle(this.transform.forward, Speed) > 2;
     if (ValueAdjust.JudgeRange(Speed.magnitude, LastSpeed, 1f))
     {
         AccelInput = ValueAdjust.Lerp(AccelInput, 0, Time.deltaTime);
         BrakeInput = ValueAdjust.Lerp(BrakeInput, 0, Time.deltaTime);
     }
     else
     {
         if (Speed.magnitude > LastSpeed)
         {
             AccelInput = ValueAdjust.Lerp(AccelInput, 1, Time.deltaTime);
         }
         else
         {
             AccelInput = ValueAdjust.Lerp(AccelInput, 0, Time.deltaTime);
         }
         BrakeInput = ValueAdjust.Lerp(BrakeInput, 1 - AccelInput, Time.deltaTime);
     }
     CalculateRevs();
     carController.Revs = RevsPercent;
     LastPosition       = this.transform.position;
     LastSpeed          = Speed.magnitude;
 }
Пример #2
0
 /// <summary>
 /// 渲染成图
 /// </summary>
 void Rendering()
 {
     Time.timeScale = 0;
     fileName       = curFrame.ToString("D" + ValueAdjust.GetNumDigit(renderTime * frameRate));
     ScreenShot.PrintScreen(outPutPath + fileName);
     Time.timeScale = timeScale; Debug.Log(curFrame);
 }
Пример #3
0
 /// <summary>
 /// 刷新参考线
 /// </summary>
 void UpdateReferenceLine()
 {
     if (ReferenceValue.Length != ReferenceLine.Count)
     {
         ClearList(ReferenceLine);
         for (int i = 0; i < ReferenceValue.Length; i++)
         {
             RectTransform go = Instantiate(DataImage_Prefab, DataImageParent);
             go.name = "参考线 " + ReferenceValue[i].ToString();
             ReferenceLine.Add(go);
         }
     }
     if (DataImageParent.gameObject.activeInHierarchy)
     {
         for (int i = 0; i < ReferenceValue.Length; i++)
         {
             float value = ValueAdjust.ToPercent01(ReferenceValue[i], DataRange.x, DataRange.y) * DataImageParent.sizeDelta.y;
             ReferenceLine[i].offsetMax = new Vector2(DataImageParent.sizeDelta.x, value + 1);
             ReferenceLine[i].offsetMin = new Vector2(0, value - 1);
             Color newColor = new HSVColor(360f * i / ReferenceValue.Length, 1, 1, 1).ToColor();
             if (ReferenceLine[i].GetComponent <Image>())
             {
                 ReferenceLine[i].GetComponent <Image>().color = newColor;
             }
         }
     }
 }
Пример #4
0
 void Update()
 {
     if (Input.GetKey(Key_Left) || Input.GetKey(Key_Right))
     {
         if (Input.GetKey(Key_Left))
         {
             m_SliderX = ValueAdjust.Lerp(m_SliderX, -1, Time.deltaTime);
         }
         else if (Input.GetKey(Key_Right))
         {
             m_SliderX = ValueAdjust.Lerp(m_SliderX, 1, Time.deltaTime);
         }
     }
     else
     {
         m_SliderX = ValueAdjust.Lerp(m_SliderX, 0, Time.deltaTime);
     }
     if (Input.GetKey(Key_Up) || Input.GetKey(Key_Down))
     {
         if (Input.GetKey(Key_Up))
         {
             m_SliderY = ValueAdjust.Lerp(m_SliderY, 1, Time.deltaTime);
         }
         else if (Input.GetKey(Key_Down))
         {
             m_SliderY = ValueAdjust.Lerp(m_SliderY, -1, Time.deltaTime);
         }
     }
     else
     {
         m_SliderY = ValueAdjust.Lerp(m_SliderY, 0, Time.deltaTime);
     }
     if (Input.GetKey(Key_Forward) || Input.GetKey(Key_Back))
     {
         if (Input.GetKey(Key_Forward))
         {
             m_SliderZ = ValueAdjust.Lerp(m_SliderZ, 1, Time.deltaTime);
         }
         else if (Input.GetKey(Key_Back))
         {
             m_SliderZ = ValueAdjust.Lerp(m_SliderZ, -1, Time.deltaTime);
         }
     }
     else
     {
         m_SliderZ = ValueAdjust.Lerp(m_SliderZ, 0, Time.deltaTime);
     }
     if (Input.GetMouseButtonDown(1))
     {
         MousePositon_Start = Input.mousePosition;
     }
     if (Input.GetMouseButton(1) && m_Controller)
     {
         Vector2 MouseOnScreen = new Vector2((Input.mousePosition.x - MousePositon_Start.x) / Screen.width, (Input.mousePosition.y - MousePositon_Start.y) / Screen.height) * 2;
         m_Text[0].text = "Mouse:" + MouseOnScreen;
         //m_Camera.transform.RotateAround(m_Controller.transform.position, Vector3.up, MouseOnScreen.x * Time.deltaTime * 10);
         //m_Camera.transform.RotateAround(m_Controller.transform.position, Vector3.right, MouseOnScreen.y * Time.deltaTime * 10);
     }
 }
Пример #5
0
 /// <summary>
 /// 装填完成
 /// </summary>
 internal virtual void ReloadFinish()
 {
     if (ContinualReload)
     {
         Capasity = ValueAdjust.Clamp(Capasity + 1, 0, Capasity_Max);
     }
     else
     {
         Capasity = Capasity_Max;
     }
 }
 /// <summary>
 /// 限位
 /// </summary>
 void Clamp()
 {
     if (Count < 0)
     {
         Count = 0;
     }
     if (Step <= 0)
     {
         Step = ValueAdjust.Clamp(Step, 1);
     }
 }
Пример #7
0
 private void Update()
 {
     //m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, Mathf.Clamp(m_Rigidbody.velocity.y, -0.05f, 10f), m_Rigidbody.velocity.z).normalized * m_Rigidbody.velocity.magnitude;//限制向下的速度向量
     if (!isTouched)
     {
         if (Quaternion.Angle(HitEffectPos.rotation, this.transform.rotation) < 15 && (HitEffectPos.position - Target.position).magnitude > 0.5f)//初期朝向角度过大时不进行跟踪
         {
             //改变自身朝向
             this.transform.forward = ValueAdjust.Lerp(this.transform.forward, (Target.transform.position - this.transform.position).normalized, Time.deltaTime, (this.transform.forward - (Target.transform.position - this.transform.position).normalized) * 15);
         }
         m_Rigidbody.velocity = this.transform.forward.normalized * (m_Rigidbody.velocity.magnitude + 30 * Time.deltaTime);//改变速度方向为目标方向
     }
 }
Пример #8
0
    void SmoothingLines()
    {
        float[][] result = new float[lineRenderers.Length][];
        int       count  = 100;

        for (int i = 0; i < lineRenderers.Length; i++)
        {
            result[i] = new float[count];
            lineRenderers[i].positionCount = count;
        }
        for (int i = 0; i < count; i++)
        {
            lineRenderers[0].SetPosition(i, new Vector3(i, Random.Range(0f, 10f), 0));
            result[0][i] = lineRenderers[0].GetPosition(i).y;
        }

        int size = 10;

        result[1] = ValueAdjust.Smoothing(result[0], 1);
        result[2] = ValueAdjust.Smoothing(ValueAdjust.Smoothing(result[0], 1), 1);
        result[3] = ValueAdjust.Smoothing(result[0], 5, size, true);
        float[] index = new float[(count - 1) * size + 1];
        for (int i = 0; i < (count - 1) * size + 1; i++)
        {
            index[i] = i * 1f / size;
        }
        result[4] = ValueAdjust.Smoothing(result[0], 5, size);

        lineRenderers[3].positionCount = (count - 1) * size + 1;
        for (int j = 1; j < 5; j++)
        {
            for (int i = 0; i < count; i++)
            {
                lineRenderers[j].SetPosition(i, new Vector3(i, result[j][i], 0 /*-j*/));
            }
        }
        for (int i = 0; i < 5; i++)
        {
            Debug.Log("Ave" + i + "  " + ValueAdjust.GetAverage(result[i]));
        }
        //int k = 0;
        for (int i = 0; i < (count - 1) * size + 1; i++)
        {
            lineRenderers[3].SetPosition(i, new Vector3(i * 1f / size, result[3][i], 0));
            //if (Mathf.RoundToInt(result4[i].x) == result4[i].x)
            //{
            //    lineRenderers[4].SetPosition(k, new Vector3(result4[i].x, result4[i].y, -4));
            //    k++;
            //}
        }
    }
Пример #9
0
        /// <summary>
        /// 测试副屏是否在主屏下方
        /// </summary>
        void TestDown()
        {
            Vector2 mousePosition = Input.mousePosition;
            bool    result        = ValueAdjust.JudgeRange(Display.displays[0].systemHeight - mousePosition.y, TestMousePos[3].y, ErrorRange);
            string  info          = "Target:" + TestMousePos[3] + " Mouse:" + mousePosition + " 副屏在主屏下方:" + result + " \r\n";

            Debug_T.Log(info);
            if (result)
            {
                SetPosition(0, 1);//下
            }
            else
            {
                SetPosition(0, 0);//都不符合,放在主屏
            }
        }
Пример #10
0
        /// <summary>
        /// 测试副屏是否在主屏左方
        /// </summary>
        void TestLeft()
        {
            Vector2 mousePosition = Input.mousePosition;
            bool    result        = ValueAdjust.JudgeRange(mousePosition.x, TestMousePos[1].x, ErrorRange);
            string  info          = "Target:" + TestMousePos[1] + " Mouse:" + mousePosition + " 副屏在主屏左方:" + result + " \r\n";

            Debug_T.Log(info);
            SetOverrideMousePos(TestMousePos[2].x, TestMousePos[2].y, true);
            if (result)
            {
                SetPosition(-1, 0);//左
            }
            else
            {
                Invoke(nameof(TestUp), 0.1f);//判定上
            }
        }
Пример #11
0
        /// <summary>
        /// 测试副屏是否在主屏上方
        /// </summary>
        void TestUp()
        {
            Vector2 mousePosition = Input.mousePosition;
            bool    result        = ValueAdjust.JudgeRange(Display.displays[0].systemHeight - mousePosition.y, TestMousePos[2].y, ErrorRange);
            string  info          = "Target:" + TestMousePos[2] + " Mouse:" + mousePosition + " 副屏在主屏上方:" + result + " \r\n";

            Debug_T.Log(info);
            SetOverrideMousePos(TestMousePos[3].x, TestMousePos[3].y, true);
            if (result)
            {
                SetPosition(0, -1);//上
            }
            else
            {
                Invoke(nameof(TestDown), 0.1f);//判定下
            }
        }
Пример #12
0
        /// <summary>
        /// 计算转速
        /// </summary>
        private void CalculateRevs()
        {
            float CurrentFactor = 1;
            float wheelRevs;

            //wheelRevs = (carController.m_WheelColliders[0].rpm + carController.m_WheelColliders[1].rpm + carController.m_WheelColliders[2].rpm + carController.m_WheelColliders[3].rpm) / 4;
            wheelRevs = Speed.magnitude * 60f / carController.m_WheelColliders[0].radius;
            if (wheelRevs > WheelRevs && RevsPercent > 0.8f)
            {
                WheelRevs = ValueAdjust.Lerp(WheelRevs, wheelRevs, Time.deltaTime, 200);
            }
            else if (wheelRevs > WheelRevs && RevsPercent > 0.6f)
            {
                WheelRevs = ValueAdjust.Lerp(WheelRevs, wheelRevs, Time.deltaTime, 800);
            }
            else
            {
                WheelRevs = wheelRevs;
            }
            //计算引擎转速(用于显示和声音)
            EngineRevs = WheelRevs * CurrentFactor;
            if (EngineRevs > Revs)
            {
                if (RevsPercent > 0.8f)
                {
                    Revs = ValueAdjust.Lerp(Revs, EngineRevs, Time.deltaTime, 200);
                }
                else if (RevsPercent > 0.6f)
                {
                    Revs = ValueAdjust.Lerp(Revs, EngineRevs, Time.deltaTime, 1000);
                }
                else
                {
                    //Revs = Mathf.Lerp(Revs, EngineRevs, Time.deltaTime * 4f);
                    Revs = ValueAdjust.Lerp(Revs, EngineRevs, Time.deltaTime, 5000);
                }
            }
            else
            {
                Revs = ValueAdjust.Lerp(Revs, 0, Time.deltaTime, 2000);
                //Revs = Mathf.Lerp(Revs, 0, Time.deltaTime * 0.5f);
            }
            Revs        = ValueAdjust.Clamp(Revs, 0, TopRevs);
            RevsPercent = ValueAdjust.Clamp(Revs / TopRevs);
        }
Пример #13
0
        void SetCartPosition(float distanceAlongPath)
        {
            if (m_Path != null)
            {
                m_Distance = m_Path.StandardizeUnit(distanceAlongPath, CinemachinePathBase.PositionUnits.Distance);
                this.transform.position = m_Path.EvaluatePositionAtUnit(m_Distance, CinemachinePathBase.PositionUnits.Distance);
                //this.transform.rotation = m_Path.EvaluateOrientationAtUnit(m_Distance, CinemachinePathBase.PositionUnits.Distance);
                m_PathUnits             = m_Path.FindClosestPoint(this.transform.position, 0, -1, 2);
                this.transform.rotation = m_Path.EvaluateOrientation(m_PathUnits, true);
                m_Speed_KPH             = m_Path.EvaluateSpeed(m_PathUnits, out int indexA, out int indexB);
                m_Speed_MPS             = ValueAdjust.ConvertSpeed(SpeedType.KPH, SpeedType.MPS, m_Speed_KPH);
                m_CurrentRoadWidth      = m_Path.EvaluateWidth(m_PathUnits);
                m_CurrentYaw            = m_Path.EvaluateYaw(m_PathUnits);

                Vector3 nextPos = m_Path.EvaluatePosition(m_Path.FindClosestPoint(this.transform.position + WheelForward.normalized * m_Speed_MPS, 0, 1, 2));
                OutputSteerAngle = this.transform.DirectionToLocalEulerAngles(nextPos - this.transform.position).y;
                car.m_SteerAngle = OutputSteerAngle;
                UpdateWheels(OutputSteerAngle);
            }
        }
Пример #14
0
 /// <summary>
 /// 刷新数据绘制
 /// </summary>
 private void OnDraw()
 {
     if (DataImageParent.gameObject.activeInHierarchy)
     {
         for (int i = 0; i < DataImages.Count; i++)
         {
             if (RecordData.Count - DataImages.Count + i <= 0)
             {
                 //DataImages[i].sizeDelta = new Vector2(DataImage_Prefab.sizeDelta.x, 0);
                 DataImages[i].localScale = new Vector3(1, 0, 1);
             }
             else
             {
                 float data = RecordData[RecordData.Count - DataImages.Count + i];
                 //DataImages[i].sizeDelta = new Vector2(DataImage_Prefab.sizeDelta.x, RecordData[RecordData.Count - DataImages.Count + i] * 3);
                 DataImages[i].localScale = new Vector3(1, ValueAdjust.ToPercent01(data, DataRange.x, DataRange.y, 1, false), 1);
             }
         }
     }
 }
Пример #15
0
        /// <summary>
        /// 检查路径输入(Assets文件夹内)
        /// </summary>
        /// <param name="path">输入</param>
        /// <param name="fileType">文件类型</param>
        /// <param name="createPath">如无则创建目录</param>
        /// <param name="OutputPath">输出路径</param>
        /// <param name="OutputFileName">输出文件名</param>
        /// <returns>输出</returns>
        public static string CheckPathInAssets(string path, string fileType, bool createPath, out string OutputPath, out string OutputFileName)
        {
            string OutputFullName = "";

            OutputPath     = "";
            OutputFileName = "";

            List <string> tempString = ValueAdjust.SplitPath(path).ToList();

            if (tempString[0] != "Assets")
            {
                tempString.Insert(0, "Assets");
            }

            for (int i = 0; i < tempString.Count; i++)
            {
                if (i >= tempString.Count - 1)
                {
                    OutputFileName = tempString[i];
                    if (tempString[tempString.Count - 1].LastIndexOf("." + fileType, StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        OutputFileName += "." + fileType;
                    }
                    break;
                }
                else
                {
                    OutputPath += tempString[i] + "/";
                }
            }
            OutputFullName = OutputPath + OutputFileName;
            //Debug.Log(OutputFullName);

            if (!Directory.Exists(OutputPath) && createPath)
            {
                Directory.CreateDirectory(OutputPath);
            }

            return(OutputFullName);
        }
Пример #16
0
        void SetCartPosition(Vector3 nowPosition, Vector3 direction, float speed, float step)
        {
            if (m_Path != null)
            {
                m_PathUnits = m_Path.FindClosestPoint(nowPosition + direction.normalized * speed * step, 0, -1, 2);
                m_Speed_KPH = m_Path.EvaluateSpeed(m_PathUnits, out int indexA, out int indexB);
                m_Speed_MPS = ValueAdjust.ConvertSpeed(SpeedType.KPH, SpeedType.MPS, m_Speed_KPH);
                Vector3 pos = m_Path.EvaluatePosition(m_PathUnits);
                m_CurrentRoadWidth = m_Path.EvaluateWidth(m_PathUnits);
                Vector3 right = ForwardToRight(m_Path.EvaluateTangent(m_PathUnits));
                if (!ValueAdjust.InLine(this.transform.position, pos + right * m_CurrentRoadWidth, pos - right * m_CurrentRoadWidth, step))
                {
                    this.transform.position = pos;
                }
                this.transform.rotation = m_Path.EvaluateOrientation(m_PathUnits, true);// * Quaternion.Euler(Vector3.up * Random.Range(-1f, 1f));
                m_CurrentYaw            = m_Path.EvaluateYaw(m_PathUnits);

                Vector3 nextPos = m_Path.EvaluatePosition(m_Path.FindClosestPoint(this.transform.position + direction.normalized * speed, 0, 1, 2));
                OutputSteerAngle = this.transform.DirectionToLocalEulerAngles(nextPos - this.transform.position).y;
                car.m_SteerAngle = OutputSteerAngle;
                UpdateWheels(OutputSteerAngle);
            }
        }
Пример #17
0
 private void LateUpdate()
 {
     this.transform.localEulerAngles = new Vector3(ValueAdjust.Lerp(this.transform.localEulerAngles.x, isDie ? 90 : 0, Time.deltaTime, 90), this.transform.localEulerAngles.y, 0);
 }
Пример #18
0
        void Update()
        {
            if (useMouse)
            {
                fire = Input.GetMouseButton(0);
            }
            else
            {
                fire = Input.GetKey(KeyCode.Space);
            }

            if (useMouse)
            {
                curPos = new Vector2(Input.mousePosition.x / Screen.width * 2 - 1, Input.mousePosition.y / Screen.height * 2 - 1);
            }
            else
            {
                curPos = new Vector2(Mathf.Clamp(m_SliderX.value, -1, 1), Mathf.Clamp(m_SliderY.value, -1, 1));
                if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
                {
                    m_SliderX.value -= Time.deltaTime * 0.5f;
                }
                else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
                {
                    m_SliderX.value += Time.deltaTime * 0.5f;
                }
            }
            curPos                  = new Vector2(Mathf.Clamp(curPos.x, -1, 1), Mathf.Clamp(curPos.y, -1, 1));
            m_SliderX.value         = curPos.x;
            m_SliderY.value         = curPos.y;
            GameParameter.ControlXY = (curPos + lastPosM) / (lastPos.Length + 1);

            CrossBow.gameObject.SetActive(true);
            CrossBow.transform.localEulerAngles     = new Vector3(-GameParameter.ControlXY.y * 12f, GameParameter.ControlXY.x * 45f, 0);
            CrossBow.transform.position             = CrossBowStartPos; // + new Vector3(0, 0, 3.3f) * GameParameter.ControlXY.x;
            CameraParent.transform.localEulerAngles = new Vector3(-GameParameter.ControlXY.y * 10f, GameParameter.ControlXY.x * 40f, 0);
            CameraParent.transform.position         = CrossBowStartPos; // + new Vector3(0, 0, 3f) * GameParameter.ControlXY.x;
            if (CrossBow.Fire)
            {
                Camera.main.fieldOfView = ValueAdjust.Lerp(Camera.main.fieldOfView, 20, Time.deltaTime, 10);
            }
            else
            {
                Camera.main.fieldOfView = ValueAdjust.Lerp(Camera.main.fieldOfView, 60, Time.deltaTime, 40);
            }

            GameParameter.Fire = fire;
            lastPosM           = Vector2.zero;
            for (int i = lastPos.Length - 1; i >= 0; i--)
            {
                if (i == 0)
                {
                    lastPos[0] = curPos;
                }
                else
                {
                    lastPos[i] = lastPos[i - 1];
                }
                lastPosM += lastPos[i];
            }
        }
Пример #19
0
        /// <summary>
        /// 根据序号获取路径上的宽度
        /// </summary>
        /// <param name="pos">序号</param>
        /// <returns>速度</returns>
        public float EvaluateWidth(float pos)
        {
            float result = 0;

            if (m_Waypoints.Length > 0)
            {
                UpdateControlPoints();
                pos = GetBoundingIndices(pos, out int indexA, out int indexB);
                if (indexA == indexB)
                {
                    result = m_Waypoints[indexA].width;
                }
                else
                {
                    result = Mathf.Lerp(m_Waypoints[indexA].width, m_Waypoints[indexB].width, ValueAdjust.ToPercent01(pos, indexA, indexB));
                }
                //result = SplineHelpers.Bezier1(pos - indexA,
                //    m_Waypoints[indexA].width, m_ControlPoints1[indexA].width,
                //    m_ControlPoints2[indexA].width, m_Waypoints[indexB].width);
            }
            return(result);
        }
Пример #20
0
        /// <summary>
        /// 根据序号获取路径上的速度,忽略<0
        /// </summary>
        /// <param name="pos">序号</param>
        /// <param name="indexA">前点</param>
        /// <param name="indexB">后点</param>
        /// <returns>速度</returns>
        public float EvaluateSpeed(float pos, out int indexA, out int indexB)
        {
            float result = 0;

            pos = StandardizePos(pos);
            int numWaypoints = m_Waypoints.Length;

            if (numWaypoints < 2)
            {
                indexA = indexB = 0;
            }
            else if (IsAllSpeedNull())
            {
                indexA = indexB = 0;
                return(0);
            }
            else
            {
                indexA = Mathf.FloorToInt(pos);
                if (indexA >= numWaypoints)
                {
                    // Only true if looped
                    pos   -= MaxPos;
                    indexA = 0;
                }
                while (m_Waypoints[indexA].speed < 0)
                {
                    indexA--;
                    if (indexA < 0)
                    {
                        if (Looped)
                        {
                            indexA = numWaypoints - 1;
                        }
                        else
                        {
                            indexA = 0;
                            break;
                        }
                    }
                }
                indexB = indexA + 1;
                if (indexB == numWaypoints)
                {
                    if (Looped)
                    {
                        indexB = 0;
                    }
                    else
                    {
                        --indexB;
                        --indexA;
                    }
                }
                while (m_Waypoints[indexB].speed < 0)
                {
                    indexB++;
                    if (indexB >= numWaypoints)
                    {
                        if (Looped)
                        {
                            indexB -= numWaypoints;
                        }
                        else
                        {
                            indexB = numWaypoints - 1;
                            break;
                        }
                    }
                }
            }
            if (m_Waypoints[indexA].speed < 0 || m_Waypoints[indexB].speed < 0)
            {
                result = 0;
            }
            else
            {
                result = Mathf.Lerp(m_Waypoints[indexA].speed, m_Waypoints[indexB].speed, indexA > indexB ? ValueAdjust.ToPercent01(pos, indexA, indexB + numWaypoints) : ValueAdjust.ToPercent01(pos, indexA, indexB));
            }
            return(result);
        }
Пример #21
0
 void Update()
 {
     m_Text[1].text    = ValueAdjust.ShowTime(Time.time);
     drawer.RecordData = ValueAdjust.ToList(FPSShow.Data_FPS.ToArray());
 }
Пример #22
0
        public void Save()
        {
#if UNITY_EDITOR
            Mesh mesh = null;
            if (this.GetComponent <SkinnedMeshRenderer>())
            {
                mesh = new Mesh();
                this.GetComponent <SkinnedMeshRenderer>().BakeMesh(mesh);
            }
            else if (this.GetComponent <MeshFilter>())
            {
                mesh = this.GetComponent <MeshFilter>().mesh;
            }
            if (mesh == null)
            {
                Debug.LogError("找不到网格体");
                return;
            }
            string OutputFullName = "";
            string OutputPath     = "";
            string OutputFileName = "";

            List <string> tempString = ValueAdjust.SplitPath(fileName).ToList();
            if (tempString[0] != "Assets")
            {
                tempString.Insert(0, "Assets");
            }

            for (int i = 0; i < tempString.Count; i++)
            {
                if (i >= tempString.Count - 1)
                {
                    if (fileName[fileName.Length - 1] == '/' || fileName[fileName.Length - 1] == '\\')
                    {
                        OutputPath    += tempString[i] + "/";
                        OutputFileName = name;
                    }
                    else
                    {
                        OutputFileName = tempString[i];
                    }
                    if (tempString[tempString.Count - 1].LastIndexOf(".asset", StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        OutputFileName += ".asset";
                    }
                    break;
                }
                else
                {
                    OutputPath += tempString[i] + "/";
                }
            }
            if (!Directory.Exists(OutputPath))
            {
                Directory.CreateDirectory(OutputPath);
            }
            OutputFullName = OutputPath + OutputFileName;
            Debug.Log(OutputFullName);
            AssetDatabase.CreateAsset(mesh, OutputFullName);
#endif
        }
Пример #23
0
 public float GetSpeed(SpeedType type)
 {
     return(ValueAdjust.ConvertSpeed(SpeedType.MPS, type, m_Rigidbody.velocity.magnitude));
 }
Пример #24
0
 private void LateUpdate()
 {
     if (canPlayFireEffect)//发射
     {
         ColdDownTime = 0;
         ShotNum++;
         canPlayFireEffect = false;
         m_Audio.PlayOneShot(audioClips[Random.Range(1, audioClips.Length)]);//播放射出音效
         Arrow_Anim.GetComponent <Renderer>().enabled = false;
         Transform newArrow = Instantiate(Arrow_Prefab, Arrow_Anim.transform.position, this.transform.rotation);
         //newArrow.localScale = this.transform.localScale + Vector3.one * (Force - Force_Min) / (Force_Max - Force_Min);
         newArrow.GetComponent <Arrow>().m_Rigidbody.AddForce(this.transform.forward * Force);
         newArrow.name += ShotNum + "_" + Force.ToString("F2");
         Force          = Force_Min;
         BoresightTime  = 1f;
     }
     if (Holding)
     {
         if (!m_Audio.isPlaying)
         {
             m_Audio.PlayOneShot(audioClips[0]);//播放拉弦音效
         }
         Arrow_Anim.GetComponent <Renderer>().enabled = true;
     }
     if (canShowBoresight)
     {
         boresight.material.color = ColorAdjust.ColorAlphaChange(boresight.material.color, ValueAdjust.Lerp(boresight.material.color.a, 0.6f, Time.deltaTime, 5f));
     }
     else
     {
         boresight.material.color = ColorAdjust.ColorAlphaChange(boresight.material.color, ValueAdjust.Lerp(boresight.material.color.a, 0f, Time.deltaTime, 2f));
     }
 }