コード例 #1
0
ファイル: HostWindow.cs プロジェクト: afaucher/LazerTagHost
        void HostChangedListener.GameStateChanged(HostGun.HostingState state)
        {
            //drop,rename,late,abort,next
            switch (state) {
            case HostGun.HostingState.HOSTING_STATE_ADDING:
            case HostGun.HostingState.HOSTING_STATE_CONFIRM_JOIN:
                //Disable Late Join
                playerselectionscreenMain.SetControlOptions(true,true,false,true,true,true);
                break;
            case HostGun.HostingState.HOSTING_STATE_PLAYING:
                playerselectionscreenMain.SetControlOptions(true,true,true,true,true,false);
                //disable pause, next
                break;
            case HostGun.HostingState.HOSTING_STATE_GAME_OVER:
            case HostGun.HostingState.HOSTING_STATE_SUMMARY:
                playerselectionscreenMain.SetControlOptions(false,true,false,true,true,false);
                //disable pause, late join, drop
                break;

            case HostGun.HostingState.HOSTING_STATE_COUNTDOWN:
                playerselectionscreenMain.SetControlOptions(true,true,false,true,false,false);
                //disable next, LateJoin, pause

                break;
            default:
                playerselectionscreenMain.SetControlOptions(false,false,false,true,true,false);
                break;
            }
            RefreshPlayerList();
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: afaucher/LazerTagHost
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        List<string> ports = LazerTagSerial.GetSerialPorts();

        foreach (string port in ports) {
            this.comboboxentryArduinoPorts.AppendText(port);
        }

        hg = new HostGun(null, null);

        foreach (string port in ports) {
            if (hg.SetDevice(port)) {
                comboboxentryArduinoPorts.Entry.Text = port;
                buttonStartHost.Sensitive = true;
                SetTranscieverStatusImage("gtk-apply");
                break;
            }
        }

        this.ShowAll();

        hw = new HostWindow(hg);
        hw.Modal = true;
        hw.Hide();

        UpdateGameType();
    }
コード例 #3
0
 public LazerTagProtocol(HostGun hostGun, string portName)
 {
     _hostGun = hostGun;
     _serial = new LazerTagSerial();
     _serial.IoError += Serial_IoError;
     _serial.DataReceived += Serial_DataReceived;
     _serial.Connect(portName);
     _serial.Enqueue(new[] {(byte) '\r', (byte) '\n'});
 }
コード例 #4
0
ファイル: Main.cs プロジェクト: afaucher/LazerTagHost
        public static void Main(string[] args)
        {
            if (args.Length == 0) {
                Console.WriteLine("Format: LaserTagHost.exe <serial port>");
                return;
            }

            HostGun hg = new HostGun(args[0], null);
            //hg.StartGameNow();

            while (true) {

                hg.Update();

            }
        }
コード例 #5
0
ファイル: HostWindow.cs プロジェクト: afaucher/LazerTagHost
        public HostWindow(HostGun hg)
            : base(Gtk.WindowType.Toplevel)
        {
            this.Build ();

            GLib.TimeoutHandler th = new GLib.TimeoutHandler(HostUpdate);
            GLib.Timeout.Add(100,th);

            this.hg = hg;

            hg.AddListener(this);

            PlayerSelector ps = playerselectionscreenMain.GetPlayerSelector();

            if (hg.IsTeamGame()) {
                ps.SetColumnLabels("Team 1", "Team 2", "Team 3");
            } else {
                ps.SetColumnLabels("","","");
            }
            playerselectionscreenMain.SubscribeEvents(this);

            RefreshPlayerList();
        }
コード例 #6
0
ファイル: PacketPacker.cs プロジェクト: afaucher/LazerTagHost
        //Entirely untested
        public static UInt16[] packGameDefinition(
            HostGun.CommandCode game_type,
            UInt16 game_id,
            int game_time_minutes,
            int tags,
            int reloads,
            int sheild,
            int mega,

            bool extended_tagging,
            bool unlimited_ammo,
            bool unlimited_mega,
            bool friendly_fire,
            bool medic_mode,
            bool rapid_tags,
            bool hunters_hunted,
            bool hunters_hunted_direction,

            bool zones,
            bool bases_are_teams,
            bool tagged_players_are_disabled,
            bool base_areas_revive_players,
            bool base_areas_are_hospitals,
            bool base_areas_fire_at_players,
            int number_of_teams_in_game,
            char[] game_type_name)
        {
            //assert(game_type_name.Length == 4);
            Debug.Assert(number_of_teams_in_game >= 0 && number_of_teams_in_game <= 3);
            byte flags =
                (byte)((extended_tagging ? 1 : 0) << 7
                    | (unlimited_ammo ? 1 : 1) << 6
                    | (unlimited_mega ? 1 : 1) << 5
                    | (friendly_fire ? 1 : 0) << 4
                    | (medic_mode ? 1 : 0) << 3
                    | (rapid_tags ? 1 : 0) << 2
                    | (hunters_hunted ? 1 : 0) << 1
                    | (hunters_hunted_direction ? 1 : 0) << 0);
            byte flags2 =
                (byte)((zones ? 1 : 0) << 7
                    | (bases_are_teams ? 1 : 0) << 6
                    | (tagged_players_are_disabled ? 1 : 0) << 5
                    | (base_areas_revive_players ? 1 : 0) << 4
                    | (base_areas_are_hospitals ? 1 : 0) << 3
                    | (base_areas_fire_at_players ? 1 : 0) << 2
                    | (number_of_teams_in_game & 0x03));
            String flags_string = String.Format("{0:x}{1:x}",flags,flags2);
            Console.WriteLine(flags_string);
            /*flags = 0x78;
            flags2 = 0xA3;
            flags_string = String.Format("{0:x}{1:x}",flags,flags2);
            Console.WriteLine(flags_string);*/

            UInt16[] values = new UInt16[] {
                (UInt16)game_type,
                game_id,//Game ID
                DecimalToDecimalHex((byte)game_time_minutes), //game time minutes
                DecimalToDecimalHex((byte)tags), //tags
                DecimalToDecimalHex((byte)reloads), //reloads
                DecimalToDecimalHex((byte)sheild), //sheild
                DecimalToDecimalHex((byte)mega), //mega
                flags,
                flags2,
            };
            if (game_type_name != null && game_type_name.Length > 0) {
                UInt16[] values2 = new UInt16[values.Length + game_type_name.Length];

                values.CopyTo(values2,0);
                game_type_name.CopyTo(values2,values.Length);
            }

            return values;
        }
コード例 #7
0
 public static Signature ZoneBeacon(int teamNumber, HostGun.ZoneType zoneType)
 {
     var flags = (byte) (((teamNumber & 0x3) << 3) | ((byte) zoneType & 0x3));
     return new Signature(SignatureType.Beacon, flags, 5);
 }