Ejemplo n.º 1
0
    public void SendSyncDropWeaponRequest(DroppedWeapon droppedWeapon, Vector3 pos)
    {
        print(PureXmlTool.Serializer <BaseWeapon>(droppedWeapon.bw));
        DroppedItem d = new DroppedItem();

        d.UniqueName            = droppedWeapon.uniqueName;
        d.Bw.BackBulletQuantity = droppedWeapon.bw.BackBulletQuantity;
        d.Bw.CurBulletQuantity  = droppedWeapon.bw.CurBulletQuantity;
        d.Bw.IsHaveSpecial      = droppedWeapon.bw.IsHaveSpecial;
        d.Bw.MaxBulletQuantity  = droppedWeapon.bw.MaxBulletQuantity;
        d.Bw.Price       = droppedWeapon.bw.Price;
        d.Bw.WeaponClass = droppedWeapon.bw.WeaponClass;
        d.Bw.WeaponName  = droppedWeapon.bw.WeaponName;
        d.Trans.PosX     = pos.x;
        d.Trans.PosY     = pos.y;
        d.Trans.PosZ     = pos.z;
        string           droppedItemXml = PureXmlTool.Serializer <DroppedItem>(d);
        OperationRequest opRequest      = new OperationRequest()
        {
            Parameters = new Dictionary <byte, object>(), OperationCode = (byte)OperationCode.SyncDropWeapon
        };

        opRequest.Parameters.Add(opRequest.OperationCode, droppedItemXml);
        syncDropWeaponRequest.OnOperationRequest(opRequest);
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
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();
     }
 }
Ejemplo n.º 4
0
    public void DeleteDropWeaponRequest(DroppedWeapon droppedWeapon)
    {
        DroppedItem d = new DroppedItem();

        d.UniqueName            = droppedWeapon.uniqueName;
        d.Bw.BackBulletQuantity = droppedWeapon.bw.BackBulletQuantity;
        d.Bw.CurBulletQuantity  = droppedWeapon.bw.CurBulletQuantity;
        d.Bw.IsHaveSpecial      = droppedWeapon.bw.IsHaveSpecial;
        d.Bw.MaxBulletQuantity  = droppedWeapon.bw.MaxBulletQuantity;
        d.Bw.Price       = droppedWeapon.bw.Price;
        d.Bw.WeaponClass = droppedWeapon.bw.WeaponClass;
        d.Bw.WeaponName  = droppedWeapon.bw.WeaponName;
        d.UniqueName     = droppedWeapon.uniqueName;
        string           droppedItemXml = PureXmlTool.Serializer <DroppedItem>(d);
        OperationRequest opRequest      = new OperationRequest()
        {
            Parameters = new Dictionary <byte, object>(), OperationCode = (byte)OperationCode.DeleteDropWeapon
        };

        opRequest.Parameters.Add(opRequest.OperationCode, droppedItemXml);
        syncDropWeaponRequest.OnOperationRequest(opRequest);
    }
Ejemplo n.º 5
0
    public void Display()
    {
        for (int j = 0; j < GameManagerScript.statDisplay.Count; j++)
        {
            GameManagerScript.statDisplay[j].gameObject.SetActive(true);
            GameManagerScript.statDisplay[j].GetComponent <Outline>().effectColor = Color.HSVToRGB(.585f, 1, 1);
        }
        DroppedWeapon droppedWeapon = gameObject.GetComponent <DroppedWeapon>();
        int           i             = 0;

        GameManagerScript.statDisplay[i].text = "[" + droppedWeapon.WeaponStats.WeaponTypes.ToString() + "]";
        i++;
        GameManagerScript.statDisplay[i].text = "\"" + droppedWeapon.WeaponStats.ItemName + "\"";
        i++;
        if (droppedWeapon.WeaponStats.LevelRestriction > 0)
        {
            GameManagerScript.statDisplay[i].text = "Level Restriction: Level " + droppedWeapon.WeaponStats.LevelRestriction.ToString();
            if (droppedWeapon.WeaponStats.LevelRestriction > PlayerStats.curLevel)
            {
                GameManagerScript.statDisplay[i].GetComponent <Outline>().effectColor = Color.red;
            }
            i++;
        }
        if (droppedWeapon.WeaponStats.RequiredStrength > 0)
        {
            GameManagerScript.statDisplay[i].text = "Required Strength: " + droppedWeapon.WeaponStats.RequiredStrength.ToString();
            if (droppedWeapon.WeaponStats.RequiredStrength > PlayerStats.strength)
            {
                GameManagerScript.statDisplay[i].GetComponent <Outline>().effectColor = Color.red;
            }
            i++;
        }
        if (droppedWeapon.WeaponStats.RequiredDexterity > 0)
        {
            GameManagerScript.statDisplay[i].text = "Required Dexterity: " + droppedWeapon.WeaponStats.RequiredDexterity.ToString();
            if (droppedWeapon.WeaponStats.RequiredDexterity > PlayerStats.dexterity)
            {
                GameManagerScript.statDisplay[i].GetComponent <Outline>().effectColor = Color.red;
            }
            i++;
        }
        GameManagerScript.statDisplay[i].text = "Weight: " + droppedWeapon.WeaponStats.Weight.ToString() + " lbs";
        if (droppedWeapon.WeaponStats.Weight + PlayerStats.curWeight > PlayerStats.maxWeight)
        {
            GameManagerScript.statDisplay[i].GetComponent <Outline>().effectColor = Color.red;
        }
        i++;
        GameManagerScript.statDisplay[i].text = "Value: $" + droppedWeapon.WeaponStats.SellValue.ToString();
        i++;
        GameManagerScript.statDisplay[i].text = " ";
        i++;
        GameManagerScript.statDisplay[i].text = "Damage: " + droppedWeapon.WeaponStats.Damage.ToString();
        i++;
        GameManagerScript.statDisplay[i].text = "Firerate: " + droppedWeapon.WeaponStats.Firerate.ToString() + " Secs";
        i++;
        GameManagerScript.statDisplay[i].text = "Reload: " + droppedWeapon.WeaponStats.Reload.ToString() + " Secs";
        i++;
        GameManagerScript.statDisplay[i].text = "Capacity: " + droppedWeapon.WeaponStats.Capacity.ToString();
        i++;
        GameManagerScript.statDisplay[i].text = "Accuracy: " + (droppedWeapon.WeaponStats.Accuracy * 100).ToString() + "%";
        i++;
        GameManagerScript.statDisplay[i].text = "Critical Damage: " + (droppedWeapon.WeaponStats.CriticalDamage * 100).ToString() + "%";
        i++;
        GameManagerScript.statDisplay[i].text = "Critical Chance: " + (droppedWeapon.WeaponStats.CriticalChance * 100).ToString() + "%";
        i++;
        GameManagerScript.statDisplay[i].text = " ";
        i++;
        if (droppedWeapon.WeaponStats.ThreeRoundBurst)
        {
            GameManagerScript.statDisplay[i].text = "*Three Round Burst";
            i++;
        }
        if (droppedWeapon.WeaponStats.DoubleBarrel)
        {
            GameManagerScript.statDisplay[i].text = "*Double Barrel";
            i++;
        }
        if (droppedWeapon.WeaponStats.TrippleBarrel)
        {
            GameManagerScript.statDisplay[i].text = "*Tripple Barrel";
            i++;
        }
        if (droppedWeapon.WeaponStats.EnhancedDamage > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Enhanced Damage: +" + droppedWeapon.WeaponStats.EnhancedDamage.ToString();
            i++;
        }
        if (droppedWeapon.WeaponStats.ExtendedClip > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Extended Magazine: +" + droppedWeapon.WeaponStats.ExtendedClip.ToString();
            i++;
        }
        if (droppedWeapon.WeaponStats.ModifiedAccuracy > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Modified Accuracy: +" + (droppedWeapon.WeaponStats.ModifiedAccuracy * 100).ToString() + "%";
            i++;
        }
        if (droppedWeapon.WeaponStats.IncreasedCriticalChance > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Increased Critical Chance: +" + (droppedWeapon.WeaponStats.IncreasedCriticalChance * 100).ToString() + "%";
            i++;
        }
        if (droppedWeapon.WeaponStats.IgnoreArmor > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Armor Piercing: +" + droppedWeapon.WeaponStats.IgnoreArmor.ToString();
            i++;
        }
        if (droppedWeapon.WeaponStats.PoisonDamage > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Toxicant: +" + droppedWeapon.WeaponStats.PoisonDamage.ToString() + " Poison Damage";
            i++;
        }
        if (droppedWeapon.WeaponStats.FireDamage > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Incinerate: +" + droppedWeapon.WeaponStats.FireDamage.ToString() + " Fire Damage";
            i++;
        }
        if (droppedWeapon.WeaponStats.ColdDamage > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Frost Bite: +" + droppedWeapon.WeaponStats.ColdDamage.ToString() + " Cold Damage";
            i++;
        }
        if (droppedWeapon.WeaponStats.LightDamage > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Electricute: +" + droppedWeapon.WeaponStats.LightDamage.ToString() + " Shock Damage";
            i++;
        }
        if (droppedWeapon.WeaponStats.AimAssist > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Assisted Aim: +" + droppedWeapon.WeaponStats.AimAssist.ToString() + "%";
            i++;
        }
        if (droppedWeapon.WeaponStats.Leech > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Leeches " + droppedWeapon.WeaponStats.Leech.ToString() + " health per each kill";
            i++;
        }
        if (droppedWeapon.WeaponStats.AdditionalXP > 0)
        {
            GameManagerScript.statDisplay[i].text = "*+" + (droppedWeapon.WeaponStats.AdditionalXP * 100).ToString() + "% more experience after each kill";
            i++;
        }
        if (droppedWeapon.WeaponStats.AdditionalGold > 0)
        {
            GameManagerScript.statDisplay[i].text = "*+" + (droppedWeapon.WeaponStats.AdditionalGold * 100).ToString() + "% more gold after each kill";
            i++;
        }
        if (droppedWeapon.WeaponStats.ReducedWeight > 0)
        {
            GameManagerScript.statDisplay[i].text = "*Item's weight reduced by " + (droppedWeapon.WeaponStats.ReducedWeight * 100).ToString() + "%";
            i++;
        }
        while (i < (GameManagerScript.statDisplay.Count - 1))
        {
            GameManagerScript.statDisplay[i].gameObject.SetActive(false);
            i++;
        }
    } //end of display function