Click here to Skip to main content
15,880,608 members
Articles / Artificial Intelligence

XNA Snooker Club

Rate me:
Please Sign up or sign in to vote.
4.99/5 (132 votes)
8 Mar 2010CPOL17 min read 313.7K   8.4K   210  
WCF-enabled multi-player XNA game for the Windows platform.
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace SnookerCore
{
    /// <summary>
    /// Represents a single snooker team participating in the game.
    /// This class is one of the Data Contracts (hence DataContract attribute) 
    /// exposed by the service that can be understood by the client.
    /// </summary>
    [DataContract]
    public class ContractTeam
    {
        #region private members
        int id = 0;
        int ballOnIndex = -1;
        int points = 0;
        List<int> foulList = new List<int>();
        int strength = 0;
        bool justSwapped = true;
        int shotCount = 0;
        List<ContractPerson> players = new List<ContractPerson>();
        int currentPlayerIndex = 0;
        #endregion

        #region constructor
        public ContractTeam() { }

        public ContractTeam(int id)
        {
            this.id = id;
        }
        #endregion constructor

        #region properties
        [DataMember]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        [DataMember]
        public int BallOnIndex
        {
            get { return ballOnIndex; }
            set { ballOnIndex = value; }
        }
        [DataMember]
        public int Points
        {
            get { return points; }
            set { points = value; }
        }
        [DataMember]
        public List<int> FoulList
        {
            get { return foulList; }
            set { foulList = value; }
        }
        [DataMember]
        public int Strength
        {
            get { return strength; }
            set { 
                strength = value; 
            }
        }
        [DataMember]
        public bool JustSwapped
        {
            get { return justSwapped; }
            set { justSwapped = value; }
        }
        [DataMember]
        public int ShotCount
        {
            get { return shotCount; }
            set { shotCount = value; }
        }
        [DataMember]
        public List<ContractPerson> Players { get { return players; } set { players = value; } }
        
        public ContractPerson CurrentPlayer { get { return players[currentPlayerIndex]; } set { players[currentPlayerIndex] = value; } }

        public void NextPlayer()
        {
            currentPlayerIndex++;

            if (currentPlayerIndex >= players.Count)
                currentPlayerIndex = 0;
        }

        #endregion properties
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer Alura Cursos Online
Brazil Brazil

Comments and Discussions