コード例 #1
0
    public void SendMyPlayerUpdate()
    {
        if (!networkEnabled)
            return;

        PlayerUpdate update = new PlayerUpdate();
        update.WorldMatrix		= playerShip.Position.WorldMatrix;
        update.State			= (int)playerShip.State;
        update.WaitCount		= playerShip.WaitCount;
        update.DeathCount		= playerShip.DeathCount;
        update.Sounds			= (int)playerShip.Sounds;
        update.Score			= playerShip.Score;

        ShotUpdate shotUpdate = new ShotUpdate();
        shotUpdate.ShotAge = new float[Constants.NumShots];
        shotUpdate.ShotPosition = new Vector3[Constants.NumShots];
        shotUpdate.ShotAlive = new bool[Constants.NumShots];

        Photon[] shotArray = playerShip.ShotHandler.GetShotArray();
        for (int i = 0; i < Constants.NumShots; i++) {
            shotUpdate.ShotPosition[i] = shotArray[i].Location;
            shotUpdate.ShotAge[i] = shotArray[i].Age;
            shotUpdate.ShotAlive[i] = shotArray[i].Alive;
        }
        peer.SendPlayerUpdate(update, shotUpdate);
    }
コード例 #2
0
        //  These routines handle the communication between the game peers.
        public void SendPlayerUpdate(PlayerUpdate update, ShotUpdate shotUpdate)
        {
            if (inSession) {
                NetworkPacket packet = new NetworkPacket();
                packet.Write((byte)MessageType.PlayerUpdateID);
                packet.Write(update);

                for (int i = 0; i < Constants.NumShots; i++) {
                    packet.Write(shotUpdate.ShotPosition[i]);
                    packet.Write(shotUpdate.ShotAge[i]);
                }

                peerObject.SendTo((int)PlayerID.AllPlayers, packet, 0, SendFlags.NoComplete | SendFlags.NoLoopback);
            }
        }
コード例 #3
0
        public void SendMyPlayerUpdate()
        {
            PlayerUpdate update = new PlayerUpdate();
            update.ShipPosition		= ship.Position;
            update.Outline			= ship.Outline;
            update.ShipVelocity		= ship.Velocity;
            update.State			= ship.State;
            update.WaitCount		= ship.WaitCount;
            update.DeathCount		= ship.DeathCount;
            update.FlameIndex		= ship.FlameIndex;
            update.Sounds			= (int)ship.Sounds;
            update.Score			= ship.Score;

            ShotUpdate shotUpdate = new ShotUpdate();
            shotUpdate.ShotAge = new int[Constants.NumShots];
            shotUpdate.ShotPosition = new Vector2[Constants.NumShots];

            Shot[] shotArray = ship.ShotHandler.GetShotArray();
            for (int i = 0; i < Constants.NumShots; i++) {
                shotUpdate.ShotPosition[i] = shotArray[i].Position;
                shotUpdate.ShotAge[i] = shotArray[i].Age;
            }
            netPeer.SendPlayerUpdate(update, shotUpdate);
        }