贺州人民医院电子沙盘
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.
 
 
 
 

103 lines
3.0 KiB

using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
[RequireComponent(typeof(CloneGameObjInfo))]
public class ArrowScaleControl : MonoBehaviour {
private DateTime t1;
private DateTime t2;
public long gameObjID;
public CloneObjType gameObjType;
private void Awake()
{
gameObjID = GetComponent<CloneGameObjInfo>().gameObjID;
gameObjType = GetComponent<CloneGameObjInfo>().gameObjType;
MessageDispatcher.AddListener("ArrowSizeChange", ChangeSize);
//MessageDispatcher.AddListener("ReplayEvent", ExecuteEvent);
}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("ArrowSizeChange", ChangeSize);
//MessageDispatcher.RemoveListener("ReplayEvent", ExecuteEvent);
}
protected virtual void OnMouseDown()
{
if (!EventSystem.current.IsPointerOverGameObject())
{
t2 = DateTime.Now;
if (t2 - t1 < new TimeSpan(0, 0, 0, 0, 500))
{
StartCoroutine(OpenAttributePanel());
}
t1 = t2;
}
}
IEnumerator OpenAttributePanel()
{
yield return new WaitForSeconds(0.1f);
ArrowScalePanel.Instance.OpenPanel(this.gameObjID, getCurrentSacle());
}
private float getCurrentSacle()
{
float value = 0;
float ori = 0;
var cloneType = GetComponent<CloneGameObjInfo>().gameObjType;
switch (cloneType)
{
case CloneObjType.AttackLine:
ori = 35;
break;
case CloneObjType.EvacuateLine:
ori = 35;
break;
case CloneObjType.BrokenLine:
ori = 1;
break;
case CloneObjType.BlockLine:
ori = 1;
break;
default:
break;
}
float c = transform.localScale.x;
value = c / ori - 1;
return value;
}
void ChangeSize(IMessage obj)
{
var data = (ArrowSizeData)obj.Data;
if (data.id == this.gameObjID)
{
var cloneType = GetComponent<CloneGameObjInfo>().gameObjType;
float ori = 0;
switch (cloneType)
{
case CloneObjType.AttackLine:
ori = 35;
break;
case CloneObjType.EvacuateLine:
ori = 35;
break;
case CloneObjType.BrokenLine:
ori = 1;
break;
case CloneObjType.BlockLine:
ori = 1;
break;
default:
break;
}
transform.localScale = Vector3.one * ori * (1 + data.value);
}
}
}
[Serializable]
public class RecordArrowSize
{
public long gameObjID;
public float sizeValue;
}