using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
///
/// 多点测距脚本
///
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);
}
}
///
/// 显示米数
///
/// 第一个碰撞点
/// 第二个碰撞点
/// 标记起点米数
///
public void InstanceMeshText(Vector3 placementPos, Vector3 placementPos2, bool flag, float MorePointDistance)
{
GameObject MorePointMeshText = Instantiate(Resources.Load("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().text = "0";
}
else
{
float TheDistance = MorePointDistance;
MorePointMeshText.transform.position = placementPos2;
MorePointMeshText.transform.Find("text").GetComponent().text = Math.Round(TheDistance, 2).ToString();
}
}
}