123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- using ShadowStudio.Tool;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- namespace ShadowStudio.Model
- {
- /// <summary>
- ///
- /// </summary>
- public class GoodsContainer : ArtContainerHandler
- {
- private TransferCell transfer;
- public virtual void Start()
- {
- if (Transfer)
- {
- //if (!CommonMethod.isLookRoom())
- //{
- // Transfer.EditTransfer += OnEditTransfer;
- // //Transfer.TransferSelect += OnTransferSelect;
- // Transfer.ZoomTransfer += OnZoomTransfer;
- //}
- //else
- //{
- // Transfer.IsCanEditor = false;
- //}
- //Transfer.TransferStateChange += OnTransferStateChange;
- //Transfer.Box.ScaleStopped.AddListener(OnStopScale);
- //Transfer.Box.ScaleStarted.AddListener(ScaleStarted);
- }
- }
- /// <summary>
- /// 缩放事件
- /// </summary>
- /// <param name="state"></param>
- public virtual void OnZoomTransfer(TransferState state)
- {
- if (state == TransferState.Stop)
- {
- if (transform.localScale.x < 0)
- {
- transform.localScale = -transform.localScale;
- }
- OnEditTransfer(state);
- }
- }
- /// <summary>
- /// 当编辑了物体时
- /// </summary>
- /// <param name="state"></param>
- public virtual void OnEditTransfer(TransferState state)
- {
- if (state == TransferState.Stop)
- {
- OnTransferSelect(true);
- }
- else if (state == TransferState.Over)
- {
- OnTransferSelect(false);
- }
- SendTransfer(2, (int)state);
- }
- /// <summary>
- /// 当某物体被选中或被释放
- /// </summary>
- /// <param name="arg1"></param>
- /// <param name="select"></param>
- public virtual void OnTransferSelect(bool select)
- {
- ArtInfoMgr.Instance.SetContainerSelect(this, select);
- }
- //public virtual void OnStopScale()
- //{
- // if (transform.localScale.x < 0)
- // {
- // transform.localScale = -transform.localScale;
- // }
- //}
- public override TransferCell Transfer
- {
- get
- {
- if (!transfer)
- {
- transfer = GetComponent<TransferCell>();
- }
- return transfer;
- }
- }
- public override void ResetEditorPosition()
- {
- if (EditorRoot)
- {
- //Vector3 point = Transfer.GetCastPoint(GameSession.Instance.gameHead.position);
- //point.y -= 0.05f;
- //EditorRoot.position = point;
- //Vector3 forwad = point - transform.position;
- //forwad.y = 0;
- //EditorRoot.forward = -forwad;
- }
- }
- public override void LockContainer()
- {
- base.LockContainer();
- if (Transfer)
- {
- Transfer.IsLock = true;
- }
- }
- public override void UnLockContainer()
- {
- base.UnLockContainer();
- if (Transfer)
- {
- Transfer.IsLock = false;
- }
- }
- public override void SetSelect()
- {
- base.SetSelect();
- if (Transfer && !Transfer.IsLock)
- {
- Transfer.IsDragEnable = true;
- }
- }
- public override void UnSetSelect()
- {
- base.UnSetSelect();
- if (Transfer && !Transfer.IsLock)
- {
- Transfer.IsDragEnable = false;
- //Transfer.DisActiveCell();
- }
- }
- public override int AheadCount()
- {
- if (Transfer)
- {
- return Transfer.PostureAhead.Count;
- }
- return base.AheadCount();
- }
- public override int BackCount()
- {
- if (Transfer)
- {
- return Transfer.PostureBack.Count;
- }
- return base.BackCount();
- }
- public override bool GoAhead()
- {
- if (Transfer)
- {
- return Transfer.PeekAheadNode();
- }
- return base.GoAhead();
- }
- public override bool GoBack()
- {
- if (Transfer)
- {
- return Transfer.PeekBackNode();
- }
- return base.GoBack();
- }
- }
- }
|