Click here to Skip to main content
11,705,763 members (52,171 online)
Click here to Skip to main content
Add your own
alternative version

Game Attack Combos : WPF Hybrid Smart Client for Combo Calculations

, 23 May 2009 CPOL 48K 2.9K 47
A WPF hybrid smart client for calculating attack combos in the Prince of Persia game.
GameAttackCombos_Src.zip
ComboServices
App_Data
ComboPackagesService.svc
GameAttackCombos.snk
Properties
GameAttackCombos.mdf
GameAttackCombos_log.LDF
Packages
PrinceOfPersia2008.gcp
PrinceOfPersia2010.gcp
PackageComboFiles
Properties
ServiceData
GameAttackCombosModel.edmx
Properties
GameAttackCombos.snk
Assets
Button Icons.design
Game Attack Combos Icon.design
Game Attack Combos Icon.ico
Prince of Persia 2008
Prince of Persia 2010
PrinceOfPersia2010Background.png
PrinceOfPersia2010Icon.png
PrinceOfPersia2008Background.png
PrinceOfPersia2008Icon.png
ComboClient
Game Attack Combos Icon.ico
Properties
Resources
Service References
Supporting
Themes
ComboServices
ComboPackagesService.disco
ComboPackagesService.wsdl
ComboPackagesService1.wsdl
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
app.manifest
ComboLogic
Properties
GameAttackCombos_Standalone.zip
Packages
PrinceOfPersia2008.gcp
PrinceOfPersia2010.gcp
Resources
PresentationFramework.Aero.dll
GameAttackCombos.exe
GameAttackCombos.Logic.dll
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace GG.GameAttackCombos.Logic {

	/// <summary>
	/// Represents a flattened combo.
	/// </summary>
	public class FlattenedCombo : INotifyPropertyChanged {

		// Caches any recently calculated display sequence for this flattened combo.
		private string _displaySequence;
		
		// Holds the current value of the IsCompleted property.
		private bool _isCompleted;


		#region Properties

		/// <summary>
		/// A list of the aspects this flattened combo has within the game
		/// (e.g. Xbox 360 Achievement, Playstation 3 Trophy, complete chain, etc.).
		/// </summary>
		public List<string> Aspects { get; private set; }

		/// <summary>
		/// The sequence of commands that make up this flattened combo.
		/// </summary>
		public List<Command> CommandSequence { get; private set; }

		/// <summary>
		/// The sequence of commands for display.
		/// </summary>
		public string DisplaySequence {
			get {
				if (_displaySequence == null) {
					// Build a comma-separated string of command IDs.
					StringBuilder CommandIds = new StringBuilder(CommandSequence[0].Id);
					for (int i = 1; i < CommandSequence.Count; i++) {
						CommandIds.Append(",").Append(CommandSequence[i].Id);
					}
					_displaySequence = CommandIds.ToString();
				}
				return _displaySequence;
			}
		}

		/// <summary>
		/// A flag indicating whether or not this flattened combo is completed.
		/// </summary>
		public bool IsCompleted {
			get { return _isCompleted; }
			set {
				_isCompleted = value;
				OnPropertyChanged(new PropertyChangedEventArgs("IsCompleted"));
			}
		}

		#endregion

		#region Constructors

		/// <summary>
		/// Initializes an instance of FlattenedCombo.
		/// </summary>
		public FlattenedCombo() {
			Aspects = new List<string>();
		}

		/// <summary>
		/// Initializes an instance of FlattenedCombo with a sequence of commands and a list of aspects.
		/// </summary>
		public FlattenedCombo(List<Command> commandSequence, params string[] aspects)
			: this() {
			CommandSequence = commandSequence;
			if (aspects != null && aspects.Length > 0) {
				Aspects.AddRange(aspects);
			}
		}

		/// <summary>
		/// Initializes an instance of FlattenedCombo with a sequence of commands.
		/// </summary>
		public FlattenedCombo(List<Command> commandSequence)
			: this(commandSequence, null) {
		}

		#endregion

		#region INotifyPropertyChanged Members

		/// <summary>
		/// Notifies subscribers of a property change.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		#endregion

		/// <summary>
		/// Raises the PropertyChanged event.
		/// </summary>
		/// <param name="e">The event arguments to raise with.</param>
		protected void OnPropertyChanged(PropertyChangedEventArgs e) {
			PropertyChangedEventHandler Handler = PropertyChanged;
			if (Handler != null) {
				Handler(this, e);
			}
		}

	}


	/// <summary>
	/// A comparer of FlattenedCombos by their DisplaySequence properties.
	/// </summary>
	public class DisplaySequenceComparer : IComparer<FlattenedCombo> {

		#region IComparer<FlattenedCombo> Members

		public int Compare(FlattenedCombo x, FlattenedCombo y) {
			return x.DisplaySequence.CompareTo(y.DisplaySequence);
		}

		#endregion

	}

}

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)

Share

About the Author

Matt Sollars
Web Developer
United States United States
I began programming on my Commodore 64 at around the age of 12. After migrating to DOS and then Windows, I decided to take on the Web. Several languages and platforms later, I have settled in with .NET nicely. I am currently the owner of a software consulting company and lead application developer for a learning-based technology consultation company.

The love of a finished application is usually at war with the desire to improve it as soon as it's released (they're never really finished).

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 23 May 2009
Article Copyright 2009 by Matt Sollars
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid