Exemple #1
0
    public void OnUpdate(IEntity entity, object param = null)
    {
        if (IsTrigger)
        {
            //如果过了2秒还存在 说明没有捡起
            if (UnityEngine.Time.realtimeSinceStartup - m_fTriggerTime > 2.5f)
            {
                IsTrigger = false;
            }
            return;
        }

        Client.IEntity mainPlayer = Client.ClientGlobal.Instance().MainPlayer;
        if (mainPlayer == null || mainPlayer.IsDead() || entity == null)
        {
            return;
        }


        IBox box = entity as IBox;

        if (box == null)
        {
            return;
        }

        UnityEngine.Vector3 dis = mainPlayer.GetPos() - entity.GetPos();
        if (dis.sqrMagnitude < SQRMagnitude)
        {
            IsTrigger = true;
            if (box.CanPick())
            {
                m_fTriggerTime = UnityEngine.Time.realtimeSinceStartup;
                NetService.Instance.Send(new GameCmd.stPickUpItemPropertyUserCmd_C()
                {
                    qwThisID = entity.GetID()
                });
//                 if (box.CanAutoPick())
//                 {
//                     Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ROBOTCOMBAT_PICKUPITEM,
//                         new Client.stPickUpItem() { itemid = entity.GetID(), state = 1 });
//                 }
                // UnityEngine.Debug.Log("捡起道具 " + entity.GetID());
            }
        }
    }