Beispiel #1
0
    void SpawnWeapon(Data_ItemFile data)
    {
        switch (data.weaponType)
        {
        case weaponType.Machine:
            GameObject obj = Resources.Load <GameObject>("Weapons/Machine");
            InstantiateWeapon(obj, data);
            break;

        case weaponType.ShotGun:
            obj = Resources.Load <GameObject>("Weapons/ShotGun");
            InstantiateWeapon(obj, data);
            break;

        case weaponType.Rifle:
            obj = Resources.Load <GameObject>("Weapons/Rifle");
            InstantiateWeapon(obj, data);
            break;

        case weaponType.GaussGun:
            obj = Resources.Load <GameObject>("Weapons/GaussGun");
            InstantiateWeapon(obj, data);
            break;
        }
    }
Beispiel #2
0
 void InstantiateWeapon(GameObject obj, Data_ItemFile data)
 {
     if (obj)
     {
         GameObject    go   = Instantiate(obj);
         Player_Weapon weap = go.GetComponent <Player_Weapon>();
         if (data.droped)
         {
             go.transform.position = data.pos;
             go.transform.rotation = data.rotate;
         }
         else
         {
             if (data.owner != -1)
             {
                 Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(data.owner);
                 if (controll)
                 {
                     weap.TakeWeapon(controll.rightHand, controll);
                 }
             }
         }
         weap.index = data.index;
         Data_ListPlayerOnScene.WriteNewItem(weap, data.index);
     }
     else
     {
         Debug.Log("mobel not found!");
     }
 }
Beispiel #3
0
    public static Data_ItemFile GetItemData(int id)
    {
        Data_ItemFile item = null;

        if (id >= 0 && ItemList.Count > id)
        {
            item = ItemList[id];
        }

        return(item);
    }
Beispiel #4
0
 /// <summary>
 /// Before writing data find null item in list
 /// </summary>
 /// <param name="data"></param>
 public static void WriteItemData(Data_ItemFile data)
 {
     if (nullItem.Count > 0)
     {
         ItemList[nullItem[0]] = data;
         ItemObj.Add(null);
         nullItem.RemoveAt(0);
     }
     else
     {
         ItemList.Add(data);
         ItemObj.Add(null);
     }
 }
Beispiel #5
0
 // This method would be generated
 public override void Deserialize(NetworkReader reader)
 {
     try
     {
         number  = reader.ReadInt32();
         dataEnd = reader.ReadBoolean();
         for (int a = 0; a < number; a++)
         {
             yes = reader.ReadBoolean();
             if (yes)
             {
                 Data_ItemFile item = ScriptableObject.CreateInstance <Data_ItemFile>();
                 item.index    = reader.ReadInt32();
                 item.ItemType = (ItemType)reader.ReadInt32();
                 switch (item.ItemType)
                 {
                 case ItemType.weapon:
                     item.weaponType = (weaponType)reader.ReadInt32();
                     break;
                 }
                 item.droped = reader.ReadBoolean();
                 if (item.droped)
                 {
                     item.pos    = reader.ReadVector3();
                     item.rotate = reader.ReadQuaternion();
                 }
                 else
                 {
                     item.owner = reader.ReadInt32();
                     bool me = reader.ReadBoolean();
                     if (me)
                     {
                         Chat.ammoMax = reader.ReadInt32();
                     }
                 }
                 Data_ListPlayerOnScene.AddNewItem(item);
             }
             else
             {
                 Data_ListPlayerOnScene.AddNewItem(null);
             }
         }
     }
     catch
     {
         Debug.Log("Load list fail!");
     }
 }
Beispiel #6
0
 void SpawnScene()
 {
     for (int i = 0; i < Data_ListPlayerOnScene.PlayerListCount; i++)
     {
         Data_PlayerFile player = Data_ListPlayerOnScene.playerList[i];
         if (player)
         {
             string name = player.nick;
             if (name == "zombie" || name == "policezombie" || name == "sickzombie" || name == "mutantzombie" || name == "strongzombie")
             {
                 ZombieSpawn(player);
             }
             else if (player.nick != Data_MyData.PlayerSelect)
             {
                 Spawn(player);
             }
             else
             {
                 MeSpawn(player);
             }
         }
     }
     for (int s = 0; s < Data_ListPlayerOnScene.ItemListCount; s++)
     {
         Data_ItemFile data = Data_ListPlayerOnScene.GetItemData(s);
         if (data)
         {
             switch (data.ItemType)
             {
             case ItemType.weapon:
                 SpawnWeapon(data);
                 break;
             }
         }
     }
     Message.OnPlayerReady ready = new Message.OnPlayerReady();
     Networking_client.net.Send(Networking_msgType.MeReady, ready);
 }
Beispiel #7
0
 public override void Deserialize(NetworkReader reader)
 {
     item          = ScriptableObject.CreateInstance <Data_ItemFile>();
     item.index    = reader.ReadInt32();
     item.ItemType = (ItemType)reader.ReadInt32();
     switch (item.ItemType)
     {
     case ItemType.weapon:
         item.weaponType = (weaponType)reader.ReadInt32();
         break;
     }
     item.droped = reader.ReadBoolean();
     if (item.droped)
     {
         item.pos    = reader.ReadVector3();
         item.rotate = reader.ReadQuaternion();
     }
     else
     {
         item.owner = reader.ReadInt32();
     }
     Data_ListPlayerOnScene.AddNewItem(item);
 }
Beispiel #8
0
 /// <summary>
 /// Ignore null Item list
 /// </summary>
 /// <param name="data"></param>
 public static void AddNewItem(Data_ItemFile data)
 {
     ItemList.Add(data);
     ItemObj.Add(null);
 }