コード例 #1
0
    void MeSpawn(Data_PlayerFile player)
    {
        GameObject camera = GameObject.FindGameObjectWithTag("MainCamera");
        GameObject Me     = (GameObject)Instantiate(Player, player.position, player.rotate);

        Me.name = player.nick;
        SphereCollider sphere = Me.AddComponent <SphereCollider>();

        sphere.isTrigger   = true;
        sphere.radius      = 1.5f;
        Data_MyData.roomID = player.sceneID;

        Player_AnimateControl controll = Me.GetComponent <Player_AnimateControl>();

        controll.index = player.charID;
        controll.canvas.SetNick(player.nick);
        controll.canvas.SetTitle(player.title);
        controll.canvas.SetRang(player.rang);

        camera.GetComponent <Camera>().enabled        = true;
        camera.GetComponent <AudioListener>().enabled = true;
        Player_PlayerLocate locate = camera.GetComponent <Player_PlayerLocate>();

        locate.enabled = true;
        locate.GameStart(Me.transform);

        Data_ListPlayerOnScene.WriteGameObject(Me, player.charID);
        Data_MyData.charID = player.charID;
        Data_MyData.Me     = player;
    }
コード例 #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!");
     }
 }
コード例 #3
0
 // This method would be generated
 public override void Deserialize(NetworkReader reader)
 {
     try
     {
         number = reader.ReadInt32();
         for (int a = 0; a < number; a++)
         {
             yes = reader.ReadBoolean();
             if (yes)
             {
                 Data_PlayerFile player = ScriptableObject.CreateInstance <Data_PlayerFile>();
                 player.sceneID  = reader.ReadInt32();
                 player.charID   = reader.ReadInt32();
                 player.rang     = reader.ReadInt32();
                 player.nick     = reader.ReadString();
                 player.title    = reader.ReadString();
                 player.position = reader.ReadVector3();
                 player.rotate   = reader.ReadQuaternion();
                 player.death    = reader.ReadBoolean();
                 Data_ListPlayerOnScene.AddPlayer(player);
                 Debug.Log("Add player index " + player.charID);
             }
             else
             {
                 Data_ListPlayerOnScene.AddPlayer(null);
                 Debug.Log("Add null player");
             }
         }
     }
     catch
     {
         Debug.Log("Load list fail!");
     }
 }
コード例 #4
0
    void HandleZombieAttack(NetworkMessage netMsg)
    {
        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(netMsg.reader.ReadInt32());

        if (controll != null)
        {
            controll.ZombieAttack();
        }
    }
コード例 #5
0
    void HandleRemoveItemOnScene(NetworkMessage netMsg)
    {
        int indexItem = netMsg.reader.ReadInt32();

        if (indexItem > -1)
        {
            Data_ListPlayerOnScene.RemoveItem(indexItem);
        }
    }
コード例 #6
0
    void HandleUpdateItemPosition(NetworkMessage netMsg)
    {
        Message.ItemPositionUpdate update = netMsg.ReadMessage <Message.ItemPositionUpdate>();

        Player_Item item = Data_ListPlayerOnScene.GetItem(update.itemIndex);

        if (item)
        {
            item.SyncPosition(update.vect, update.rotate);
        }
    }
コード例 #7
0
    void HandleDropWeapon(NetworkMessage netMsg)
    {
        Message.DropWeapon drop = netMsg.ReadMessage <Message.DropWeapon>();

        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(drop.index);

        if (controll)
        {
            controll.DropWeapon();
        }
    }
コード例 #8
0
    void HandleNewPlayerRang(NetworkMessage netMsg)
    {
        int index = netMsg.reader.ReadInt32();
        int rang  = netMsg.reader.ReadInt32();

        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(index);

        if (controll)
        {
            controll.canvas.SetRang(rang);
        }
    }
コード例 #9
0
 void HandleOnMovePlayer(NetworkMessage netMsg)
 {
     Message.PlayerGoTo go = netMsg.ReadMessage <Message.PlayerGoTo> ();
     if (go.vect != Vector3.zero)
     {
         Player_AnimateControl pl = Data_ListPlayerOnScene.GetPlayerControll(go.index);
         if (pl != null)
         {
             pl.Move(go.vect, go.rotate);
         }
     }
 }
コード例 #10
0
    void HandleNewPlayerTitle(NetworkMessage netMsg)
    {
        int    index = netMsg.reader.ReadInt32();
        string title = netMsg.reader.ReadString();

        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(index);

        if (controll)
        {
            controll.canvas.SetTitle(title);
        }
    }
コード例 #11
0
    void HandleFire(NetworkMessage netMsg)
    {
        Message.Shot          shot     = netMsg.ReadMessage <Message.Shot>();
        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(shot.index);

        if (controll)
        {
            controll.Fire(shot.vect, shot.type);
        }
        if (shot.thisPlayer)
        {
            Chat.AmmoValue(shot.ammo);
        }
    }
コード例 #12
0
    void HandleReload(NetworkMessage netMsg)
    {
        int   id   = netMsg.reader.ReadInt32();
        float time = (float)netMsg.reader.ReadDouble();
        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(id);

        if (controll)
        {
            controll.Reload(time);
            if (controll.index == Data_MyData.charID)
            {
                Chat.ReloadStart(time);
            }
        }
    }
コード例 #13
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!");
     }
 }
コード例 #14
0
 void HandleOnNewPlayerConnect(NetworkMessage netMsg)
 {
     Message.NewPlayerOnScene player = netMsg.ReadMessage <Message.NewPlayerOnScene>();
     try
     {
         if (player.player.nick != Data_MyData.PlayerSelect)
         {
             Data_ListPlayerOnScene.WritePlayer(player.player);
             Spawn(player.player);
         }
     }
     catch
     {
         Debug.Log("Player load fail!");
     }
 }
コード例 #15
0
    void HandleRespawn(NetworkMessage netMsg)
    {
        int id = netMsg.reader.ReadInt32();
        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(id);

        if (controll != null)
        {
            controll.transform.position = netMsg.reader.ReadVector3();
            controll.transform.rotation = netMsg.reader.ReadQuaternion();
            controll.gameObject.SetActive(true);
            controll.Respawn();
            if (id == Data_MyData.charID)
            {
                Player_PlayerLocate.death = false;
            }
        }
    }
コード例 #16
0
    void Spawn(Data_PlayerFile player)
    {
        GameObject Enemy = (GameObject)Instantiate(Player, player.position, player.rotate);

        Data_ListPlayerOnScene.WriteGameObject(Enemy, player.charID);
        Enemy.name = player.nick;
        Player_AnimateControl en = Enemy.GetComponent <Player_AnimateControl>();

        en.index = player.charID;
        en.canvas.SetNick(player.nick);
        en.canvas.SetTitle(player.title);
        en.canvas.SetRang(player.rang);
        en.enabled = true;
        if (player.death)
        {
            en.Death();
        }
    }
コード例 #17
0
 void OnDisconnect(NetworkMessage netmsg)
 {
     try {
         int ID = netmsg.reader.ReadInt32();
         if (ID != Data_MyData.sessionID)
         {
             ID = Data_ListPlayerOnScene.FindPlayerID(ID);
             Destroy(Data_ListPlayerOnScene.PlayersOnScene[ID]);
             Data_ListPlayerOnScene.DisconnectPlayer(ID);
         }
         else
         {
             DisconnectMe();
         }
     } catch {
         Debug.Log("Disconnect fail.");
     }
 }
コード例 #18
0
    void HandlePickUpItem(NetworkMessage netMsg)
    {
        Message.PickUpItem up = netMsg.ReadMessage <Message.PickUpItem>();

        Player_AnimateControl controll = Data_ListPlayerOnScene.GetPlayerControll(up.index);

        if (controll)
        {
            Player_Item item = Data_ListPlayerOnScene.GetItem(up.itemIndex);
            if (item)
            {
                item.TakeWeapon(controll.rightHand, controll);
            }
            if (up.thisPlayer)
            {
                Chat.AmmoMax(up.ammo, up.ammoMax);
            }
        }
    }
コード例 #19
0
    void ZombieSpawn(Data_PlayerFile zombie)
    {
        GameObject model = null;

        switch (zombie.nick)
        {
        case "zombie":
            model = (GameObject)Resources.Load("Zombie/Zombie");
            break;

        case "policezombie":
            model = (GameObject)Resources.Load("Zombie/PoliceZombie");
            break;

        case "sickzombie":
            model = (GameObject)Resources.Load("Zombie/SickZombie");
            break;

        case "mutantzombie":
            model = (GameObject)Resources.Load("Zombie/MutantZombie");
            break;

        case "strongzombie":
            model = (GameObject)Resources.Load("Zombie/StrongZombie");
            break;
        }
        if (model != null)
        {
            GameObject Zombie = (GameObject)Instantiate(model, zombie.position, zombie.rotate);
            Data_ListPlayerOnScene.WriteGameObject(Zombie, zombie.charID);
            Zombie.name = zombie.nick;
            Player_AnimateControl zm = Zombie.GetComponent <Player_AnimateControl>();
            zm.index  = zombie.charID;
            zm.zombie = true;
            if (zombie.death)
            {
                Zombie.SetActive(false);
            }
        }
    }
コード例 #20
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);
 }
コード例 #21
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);
 }
コード例 #22
0
 void MeDisconnect()
 {
     Destroy(map);
     Data_ListPlayerOnScene.DisconnectAll();
 }