You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.2 KiB
69 lines
2.2 KiB
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 多点测距脚本
|
||
|
/// </summary>
|
||
|
public class MorePointsRanging : RangingLineType
|
||
|
{
|
||
|
private void Start()
|
||
|
{
|
||
|
variableX = 5f;
|
||
|
variableY = 18f;
|
||
|
variableZ = 5f;
|
||
|
}
|
||
|
public override void HandleOther(bool flag)
|
||
|
{
|
||
|
if (flag)
|
||
|
{
|
||
|
MorePointDistance = 0;
|
||
|
//存储hit点
|
||
|
MorePointList.Add(placementPos2);
|
||
|
//计算多点线段的长度
|
||
|
for (int i = 0; i < MorePointList.Count - 1; i++)
|
||
|
{
|
||
|
MorePointDistance += Vector3.Distance(MorePointList[i], MorePointList[i + 1]);
|
||
|
}
|
||
|
InstanceMeshText(placementPos, placementPos2, flag, MorePointDistance);
|
||
|
placementPos = placementPos2;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MorePointList.Add(placementPos);
|
||
|
RangSpecialTreat();
|
||
|
InstanceMeshText(placementPos, placementPos2, flag, MorePointDistance);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 显示米数
|
||
|
/// </summary>
|
||
|
/// <param name="placementPos">第一个碰撞点</param>
|
||
|
/// <param name="placementPos2">第二个碰撞点</param>
|
||
|
/// <param name="flag">标记起点米数</param>
|
||
|
/// <param name="MorePointDistance"></param>
|
||
|
public void InstanceMeshText(Vector3 placementPos, Vector3 placementPos2, bool flag, float MorePointDistance)
|
||
|
{
|
||
|
GameObject MorePointMeshText = Instantiate(Resources.Load<GameObject>("Prefab/Lines/Ranging"), placementPos, Quaternion.identity) as GameObject;
|
||
|
RangList.Add(MorePointMeshText);
|
||
|
MorePointMeshText.transform.parent = this.transform;
|
||
|
MorePointMeshText.transform.localScale = new Vector3(2, 2, 1);
|
||
|
if (!flag)
|
||
|
{
|
||
|
MorePointMeshText.transform.Find("text").GetComponent<TextMesh>().text = "0";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
float TheDistance = MorePointDistance;
|
||
|
MorePointMeshText.transform.position = placementPos2;
|
||
|
MorePointMeshText.transform.Find("text").GetComponent<TextMesh>().text = Math.Round(TheDistance, 2).ToString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|