|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
|
|
|
namespace DisComputer
|
|
|
{
|
|
|
/*
|
|
|
*@func 零件控制器
|
|
|
* @author lz
|
|
|
* @date 2020/06/01
|
|
|
*/
|
|
|
public class SpareItemControl : MonoBehaviour
|
|
|
{
|
|
|
//类型
|
|
|
public SpareType type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//零件详细信息
|
|
|
public SpareInfo spareInfo;
|
|
|
|
|
|
|
|
|
[Header("拆卸触发器")]
|
|
|
public GameObject triggerGo;
|
|
|
|
|
|
[Header("零件主体")]
|
|
|
public GameObject[] mainSpareGos;
|
|
|
|
|
|
[Header("外发光颜色")]
|
|
|
public Color outLineColor;
|
|
|
|
|
|
[Header("安装指引发光颜色")]
|
|
|
public Color loadOutLineColor;
|
|
|
|
|
|
//零件动画
|
|
|
public SpareAnimationBase spareAnimation;
|
|
|
|
|
|
//箭头指引标注体
|
|
|
public Transform arrowTagTargte;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
void Start()
|
|
|
{
|
|
|
|
|
|
triggerGo.SetActive(false);
|
|
|
InitColor();
|
|
|
DisableAllOutLine();
|
|
|
}
|
|
|
|
|
|
|
|
|
void InitColor()
|
|
|
{
|
|
|
if (isMainNull())
|
|
|
{
|
|
|
for (int i = 0; i < mainSpareGos.Length; i++)
|
|
|
{
|
|
|
Outline outline = mainSpareGos[i].AddComponent<Outline>();
|
|
|
outline.OutlineColor = outLineColor;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Outline triggerLine = triggerGo.AddComponent<Outline>();
|
|
|
triggerLine.OutlineColor = loadOutLineColor;
|
|
|
triggerLine.OutlineWidth = 3;
|
|
|
triggerLine.enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 显示箭头提示
|
|
|
/// </summary>
|
|
|
public void ShowArrowTip()
|
|
|
{
|
|
|
if (arrowTagTargte != null)
|
|
|
{
|
|
|
MessageContainer.SendMessage(arrowTagTargte, this, MsgName.TipViewShowArrow);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 隐藏箭头提示
|
|
|
/// </summary>
|
|
|
public void HideArrowTip()
|
|
|
{
|
|
|
if(arrowTagTargte != null)
|
|
|
{
|
|
|
//MessageContainer.SendMessage(arrowTagTargte, this, MsgName.TipViewHideArrow);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 显示安装外发光轮廓
|
|
|
/// </summary>
|
|
|
public void EnableLoadColor()
|
|
|
{
|
|
|
Outline triggerLine = triggerGo.GetComponent<Outline>();
|
|
|
if (triggerLine)
|
|
|
{
|
|
|
triggerLine.enabled = true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 隐藏安装外发光轮廓
|
|
|
/// </summary>
|
|
|
public void DisableLoadColor()
|
|
|
{
|
|
|
Outline triggerLine = triggerGo.GetComponent<Outline>();
|
|
|
if (triggerLine)
|
|
|
{
|
|
|
triggerLine.enabled = false;
|
|
|
}
|
|
|
triggerGo.SetActive(false);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 取消拆除外发光
|
|
|
/// </summary>
|
|
|
public void DisableAllOutLine()
|
|
|
{
|
|
|
if (isMainNull())
|
|
|
{
|
|
|
for (int i = 0; i < mainSpareGos.Length; i++)
|
|
|
{
|
|
|
Outline outline = mainSpareGos[i].GetComponent<Outline>();
|
|
|
if (outline != null)
|
|
|
{
|
|
|
outline.enabled = false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 显示拆除外发光
|
|
|
/// </summary>
|
|
|
public void ShowOutline()
|
|
|
{
|
|
|
if (isMainNull())
|
|
|
{
|
|
|
for (int i = 0; i < mainSpareGos.Length; i++)
|
|
|
{
|
|
|
Outline outline = mainSpareGos[i].GetComponent<Outline>();
|
|
|
if (outline != null)
|
|
|
{
|
|
|
outline.enabled = true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 激活注册类型
|
|
|
/// </summary>
|
|
|
/// <param name="_type"></param>
|
|
|
public void ActiveRegistType(SpareType _type)
|
|
|
{
|
|
|
//Debug.LogFormat(">>>>>>>>>> 注册当前零件类型成功 {0}",_type);
|
|
|
triggerGo.SetActive(true);
|
|
|
if(GameConfig.state == GameState.Load)
|
|
|
{
|
|
|
EnableLoadColor();
|
|
|
ShowOutline();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ShowOutline();
|
|
|
}
|
|
|
type = _type;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接收安装零件信息
|
|
|
/// @sender MouseControl
|
|
|
/// </summary>
|
|
|
public void OnRecSpareColliderMessage(Grid grid)
|
|
|
{
|
|
|
|
|
|
if (isBaseOnReced)
|
|
|
return;
|
|
|
|
|
|
if (grid.spareInfo.fitId == GameDataConfig.Instance.pcId) {
|
|
|
if (grid.chectSpareTag.Contains(type.ToString()))
|
|
|
{
|
|
|
//Debug.LogFormat("{0}与{1}当前目标匹配成功", grid.chectSpareTag, type);
|
|
|
if (spareAnimation.IsCompareTag(grid))
|
|
|
{
|
|
|
MouseControl.Instance.SpareLoading(() =>
|
|
|
{
|
|
|
|
|
|
spareAnimation.OnLoadAct();
|
|
|
DisableLoadColor();
|
|
|
HideArrowTip();
|
|
|
triggerGo.SetActive(false);
|
|
|
type = SpareType.Null;
|
|
|
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// Debug.LogFormat("{0}与{1}当前目标不匹配", grid.chectSpareTag, type);
|
|
|
}
|
|
|
}
|
|
|
}else
|
|
|
{
|
|
|
//Debug.Log("型号不匹配,请选择别的零件!!!");
|
|
|
MessageContainer.SendMessage(unFitTipStr(grid), this, MsgName.TipViewShowPoint);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接收子物体发射的消息
|
|
|
/// @sender MouseControl
|
|
|
/// </summary>
|
|
|
public void OnRecChildColliderMessage(ToolItem item)
|
|
|
{
|
|
|
|
|
|
if (isBaseOnReced)
|
|
|
return;
|
|
|
|
|
|
if (item.chectSpareTag.Contains(type.ToString()))
|
|
|
{
|
|
|
|
|
|
//Debug.LogFormat("{0}与{1}当前目标匹配成功", item.chectSpareTag, type);
|
|
|
|
|
|
if (spareAnimation.IsCompareTag(item))
|
|
|
{
|
|
|
MouseControl.Instance.ToolLoading(()=>
|
|
|
{
|
|
|
spareAnimation.OnUnLoadAct();
|
|
|
triggerGo.SetActive(false);
|
|
|
HideArrowTip();
|
|
|
type = SpareType.Null;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//Debug.LogFormat("{0}与{1}当前目标不匹配", item.chectSpareTag, type);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 是否已接收消息
|
|
|
/// </summary>
|
|
|
protected bool isBaseOnReced;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接收拆除消息
|
|
|
/// @sender MouseControl
|
|
|
/// </summary>
|
|
|
/// <param name="item"></param>
|
|
|
public virtual void OnRecUnloadColliderMsg(ToolItem item)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接收按照消息
|
|
|
/// @sender MouseControl
|
|
|
/// </summary>
|
|
|
/// <param name="grid"></param>
|
|
|
public virtual void OnRecLoadColliderMsg(Grid grid)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 发光体是否为空
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
protected bool isMainNull()
|
|
|
{
|
|
|
if (mainSpareGos.Length > 0) return true;
|
|
|
else
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
protected string unFitTipStr(Grid grid)
|
|
|
{
|
|
|
string val = "";
|
|
|
switch (grid.type)
|
|
|
{
|
|
|
case SpareType.Cpu:
|
|
|
val = "当前所选cpu接口与主板不匹对,请选择其他型号";
|
|
|
break;
|
|
|
case SpareType.DianYuan:
|
|
|
val = "当前所选电源与主板功耗不匹对,请选择其他型号";
|
|
|
break;
|
|
|
case SpareType.GuangQu:
|
|
|
val = "当前所选光驱不支持该机型,请选择其他型号";
|
|
|
break;
|
|
|
case SpareType.JiXiang:
|
|
|
val = "当前所选机箱不支持该机型,请选择其他型号";
|
|
|
break;
|
|
|
case SpareType.NeiCun:
|
|
|
val = "当前所选内存条与主板接口不匹对,请选择其他型号";
|
|
|
break;
|
|
|
case SpareType.XianKa:
|
|
|
val = "当前所选显卡与主板接口不匹对,请选择其他型号";
|
|
|
break;
|
|
|
case SpareType.YingPan:
|
|
|
val = "当前所选硬盘,主板不支持,请选择其他型号";
|
|
|
break;
|
|
|
case SpareType.ZhuBan:
|
|
|
val = "当前所选主板不匹对该机箱,请选择其他型号";
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
return val;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|