Exemplo n.º 1
0
    static void PickUpWeapon(Player_Item_Sr item, Player_MovePlayer controll)
    {
        Player_Weapon_Sr weap = null;

        weap = item.gameObject.GetComponent <Player_Weapon_Sr>();

        if (weap)
        {
            weap.TakeWeapon(controll.weapon, controll.index);
        }
    }
Exemplo n.º 2
0
    public Player_Item_Sr GetItem(int id)
    {
        Player_Item_Sr item = null;

        if (id > -1 && ItemsList.Count > id)
        {
            item = ItemsList[id];
        }

        return(item);
    }
Exemplo n.º 3
0
 public void AddNewItemOnScene(Player_Item_Sr item)
 {
     if (nullItem.Count > 0)
     {
         ItemsList[nullItem[0]] = item;
         item.index             = nullItem[0];
         item.roomID            = roomID;
         nullItem.RemoveAt(0);
     }
     else
     {
         item.index  = ItemsList.Count;
         item.roomID = roomID;
         ItemsList.Add(item);
     }
 }
Exemplo n.º 4
0
    /// <summary>
    /// Disconnect and destroy all player, item and room
    /// </summary>
    public void DestroyRoom()
    {
        //Disconnect and destroy all player at room
        for (int index = 0; index < playersData.Count; index++)
        {
            int         sessionID = playersData[index].sessionID;
            AccountData acc       = Networking_OnConnect.GetAccountData(sessionID);
            if (acc != null)
            {
                //Remove rooms data at account data
                acc.indexInRoom = -1;
                acc.roomID      = -1;

                Message_Sr.DisconnectPlayer disc = new Message_Sr.DisconnectPlayer();
                disc.ID = sessionID;
                RoomsManager.SendToThisPlayer(Networking_msgType_Sr.DisconnectPlayer, disc, sessionID);
                //Remove player weapon
                Player_MovePlayer controll = playersData[index].playerMoveScript;
                if (controll.weaponOnMe)
                {
                    RoomsManager.SendIntToAllRoom(Networking_msgType_Sr.RemoveItemOnScene, controll.weaponOnMe.index, roomID);
                    RemoveItem(controll.weaponOnMe.index);
                }
                //Remove player data
                Destroy(playersData[index].playerObj);
            }
        }
        playersData.Clear();
        playerListNULLVALLUE.Clear();
        //Destroy all item in room
        for (int index = 0; index < ItemsList.Count; index++)
        {
            Player_Item_Sr item = ItemsList[index];

            if (item)
            {
                Destroy(item.gameObject);
            }
        }
        ItemsList.Clear();
        nullItem.Clear();

        Destroy(gameObject);
    }
Exemplo n.º 5
0
    static void PickUpItem(int itemIndex, Player_MovePlayer controll)
    {
        AccountData acc  = Networking_OnConnect.GetAccountData(controll.index);
        Room        room = GetRoom(acc.roomID);

        if (room)
        {
            Player_Item_Sr item = room.GetItem(itemIndex);

            if (item)
            {
                switch (item.ItemType)
                {
                case ItemType_Sr.weapon:
                    PickUpWeapon(item, controll);
                    break;
                }
            }
        }
    }
    public static void SendItems(NetworkConnection con, int sessionID)
    {
        AccountData acc  = Networking_OnConnect.GetAccountData(sessionID);
        Room        room = GetRoom(acc.roomID);

        if (room)
        {
            itemsSend  = packetItem;
            itemsSends = 0;
            if (room.itemListCount > 0)
            {
                while (!allItems)
                {
                    if (itemsSends != room.itemListCount)
                    {
                        lastItems = room.itemListCount - itemsSends;

                        NetworkWriter writer = new NetworkWriter();
                        writer.StartMessage(Networking_msgType_Sr.ItemList);

                        if (lastItems < itemsSend)
                        {
                            allItems  = true;
                            itemsSend = lastItems;
                            writer.Write(itemsSend);
                            writer.Write(true);
                        }
                        else
                        {
                            writer.Write(itemsSend);
                            writer.Write(false);
                        }
                        for (int k = 0; k < itemsSend; k++)
                        {
                            Player_Item_Sr data = room.GetItem(itemsSends);
                            if (data != null)
                            {
                                writer.Write(true);
                                writer.Write(data.index);
                                writer.Write((int)data.ItemType);

                                switch (data.ItemType)
                                {
                                case ItemType_Sr.weapon:
                                    writer.Write((int)data.WeaponType);
                                    Player_Weapon_Sr weap = data.gameObject.GetComponent <Player_Weapon_Sr>();
                                    writer.Write(weap.Dropped);
                                    if (weap.Dropped)
                                    {
                                        writer.Write(data.transform.position);
                                        writer.Write(data.transform.rotation);
                                    }
                                    else
                                    {
                                        writer.Write(weap.ShoterIndex);
                                        if (weap.ShoterIndex == sessionID)
                                        {
                                            writer.Write(true);
                                            writer.Write(weap.maxAmmo);
                                        }
                                        else
                                        {
                                            writer.Write(false);
                                        }
                                    }
                                    break;
                                }
                            }
                            else
                            {
                                writer.Write(false);
                            }
                            itemsSends++;
                        }
                        writer.FinishMessage();
                        con.SendWriter(writer, 0);
                    }
                    else
                    {
                        allItems = true;
                    }
                }
            }
            else
            {
                NetworkWriter writer = new NetworkWriter();
                writer.StartMessage(Networking_msgType_Sr.ItemList);
                writer.Write(0);
                writer.Write(true);
                writer.FinishMessage();
                con.SendWriter(writer, 0);
            }
            allItems = false;
        }
    }