Пример #1
0
    public override void OnEvent(EventData eventData)
    {
        string        droppeItemXml   = (string)PureDictTool.GetValue <byte, object>(eventData.Parameters, eventData.Code);
        DroppedItem   d               = PureXmlTool.Deserializer <DroppedItem>(droppeItemXml);
        GameObject    dropWeaponModel = Instantiate(Resources.Load("Prefab/w_Weapon/" + d.Bw.WeaponName) as GameObject); //读取掉落武器
        DroppedWeapon temp            = dropWeaponModel.GetComponent <DroppedWeapon>();                                  //获取丢弃武器信息脚本

        temp.SetBaseWeapon(d.Bw);                                                                                        //设置武器信息]
        dropWeaponModel.transform.position = new Vector3(d.Trans.PosX, d.Trans.PosY, d.Trans.PosZ);
        WeaponDictionary.Instance.droppedItems.Add(d.UniqueName, dropWeaponModel);
    }
Пример #2
0
 //丢弃武器
 void DropWeapon()
 {
     if (Input.GetKeyDown(KeyCode.G) && (curWeapon == WeaponType.Rifle || curWeapon == WeaponType.Pistol || curWeapon == WeaponType.Bomb))
     {
         int           i = PureTranslateTool.WeaponTypeToInt(curWeapon);
         GameObject    dropWeaponModel = Instantiate(Resources.Load("Prefab/w_Weapon/" + weapon[i].bw.WeaponName) as GameObject); //读取掉落武器
         DroppedWeapon temp            = dropWeaponModel.GetComponent <DroppedWeapon>();                                          //获取丢弃武器信息脚本
         temp.throwDir = transform.forward;
         temp.SetBaseWeapon(weapon[i].bw);                                                                                        //设置武器信息]
         PanelManager.Instance.playerInfoPanel.OnWeaponLose(temp.bw);                                                             //更新UI
         dropWeaponModel.transform.position = transform.localPosition + transform.forward * 2f;
         RequestSender.Instance.SendSyncDropWeaponRequest(temp, dropWeaponModel.transform.position);                              //向服务器发送
         Destroy(weapon[i].gameObject);                                                                                           //销毁扔掉的武器
         weaponPostion[i].gameObject.SetActive(false);                                                                            //关闭武器点
         isHaveWeapon[i] = false;                                                                                                 //标识武器没有了
         BIndWeaponControl();                                                                                                     //更新武器控制脚本
         //查找第一个还有的武器并切换出来
         SwitchFirstHave();
     }
 }