|
In order for the player class to see the .AvailableWeapons of a Team class instance, you need to pass a team class instance into the player, via a function call or constructor. Something like this:
Team team1 = new Team();
Player playerA = new Player(team1);
The player class would look like htis:
class Player
{
int CurrentWeaponIndex;
Weapon CurrentWeapon;
Team team;
public Player(Team theTeam)
{
this.team = theTeam;
}
Weapon GetNextWeapon()
{
++CurrentWeaponIndex;
CurrentWeapon = team.AvailableWeapons[CurrentWeaponIndex];
}
}
|
|
|
|
|
Oh, so... yeah, I get it, thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
|
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "explorer.exe";
p.StartArgument = "c:"
p.Start();
but p will exit after run these code. so I cann't get its handle by p.MainWindowHandle.
Do you know how to get its handle?
thank you first!
|
|
|
|
|
I need to split MSB and LSB from a short.
Thanks in advance.
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
Nevermind:
http://msdn2.microsoft.com/en-gb/library/system.bitconverter.getbytes.aspx
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
A alternative is to use bit shifting.
To get the MSB you could shift the bits right by 15.
eg msb = short >> 15;
To get the LSB you can always use a bit mask, by using the bitwise AND operator on the short.
eg. lsb = short & 0x0001;
|
|
|
|
|
Hello!
How can i find all emails in some text, using regular expressions...
Thank you.
|
|
|
|
|
Email addresses ? Sure. There are heaps of regex examples for email addresses. I can't recall all the rules for an email address, you'd do better to google for one, or download Expresso, it has one built in.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi every one...
I solved this problem... I just had a long day ..
I have a Two dimensional array (or matrix[i,j]).<br />
and I wanted to fill data grid view with this matrix.. how can i do it correctly??
REMAINS THIS
How to highlight a cell or multi cells in a data grid view???
any hint is very appreciated
Thanks in advance..
-- modified at 14:55 Sunday 26th November, 2006
|
|
|
|
|
Use DataGridViewCell.Selected Property.
Regards
|
|
|
|
|
Is there any way to output data in a table like structure in a console app without using Console.WriteLine("blah\t\t\tblah")?
|
|
|
|
|
You can use spaces instead. Other than that, no.
---
b { font-weight: normal; }
|
|
|
|
|
how can i create the text file in the streamwriter in ascii code,
file.createtext has just one argument which is path name and dont include the encoding argument so how could u create the file in any ascii code?
|
|
|
|
|
Posting the same question again will not get you a better answer
only two letters away from being an asset
|
|
|
|
|
|
I know this topic doesnt really fit this section.. but my program was written in C# and I didnt know where to put it
So the problem is I deleted accidently my main c# file from vs project and that way it was also deleted from the real file system. I used ontrack recovery and it doesnt seem to be in the deleted files.. nor is it in the trash. I made a test and after I deleted another file from the project it landed in the trash with a different random like name xs =]
Anyone one know how to recover this file ? or does the vs has anykind of after-deleter-change-name algorithm? Im really despered.. i spent alot of time on it =/
|
|
|
|
|
I'm afraid if it's deleted, it's deleted.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
yeah after hours of searching.. I started writing the code again.. well its a good lesson to me, to make backups of all precious data I have.. Sorry for the spam I just went mad
|
|
|
|
|
I have a user control that work as a parent and contains a collection that keep track of objects or child controls ..
I need a way to fire an event that is handeled within the user control or do some action "refresh for example" when a new object or Control is added to this Collection "ParentControl.Childs.Add(NewChild)"
Thanks in advance
|
|
|
|
|
Hello,
Maybe you could call a recursive methode in your usercontrols constructor, which goes threw the Controls Collection and links to all "ControlAdded" events.
<code>//constructor code
this.MyRecursiveMethode(this.Controls)
private void MyRecursiveMethode(ControlsCollection cc)
{
if(cc!=null)
{
foreach(Control c in cc)
{
//link to the event
c.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.Control_Added);
//Call the method again and again and ... , as long as neccessary
MyRecursiveMethode(c.Controls);
}
}
}
private void Control_Added(object sender, System.Windows.Forms.ControlEventArgs e)
{
//link the event of the new added Control
e.Control.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.Control_Added);
//here is your code
}</code>
Hope that helps you.
All the best,
Martin
|
|
|
|
|
thnks so much martin for your wonderful effort and help ..
i found the way and solution to my problem using the help of your thought specially the use of ControlAdded event .. i wired the event to the panel that hosts that ChildControls ..
my 1st idea was to try to hock this event to the System.Collection.Add method itself (i have a collection that keep track of the controls rather than the controls property of the panel)i thought i could respond when a new item or control is added to this collection .
.. but i really couldn't undersatnd the use of recursive method .. any way thanks again for your help Martin
|
|
|
|
|
Hello everyone,
I am using C# on a Pocket PC 2003 project based on .Net Compact Framework of Visual Studio 2005. I want to re-draw some controls of a Form (Window) at a regular interval (for example, change the title of some Label or something similar). The issues I met with are,
1. My application has several Forms/Windows. How to check whether the specific Form/Window (which I want to re-draw) is active? If the Form/Window is not active, I think I should not re-draw the Form/Window. Am I correct? Or, whether or not the Form/Window is active, I should always re-draw the Form/Window?
2. Any code samples specific for C# of .Net Compact Framework?
thanks in advance,
George
|
|
|
|
|
how can i convert utf-8 encoding text file into ascii encoding??
streamwrite write the text file in utf-8 encodinf the streamreader read it as utf-8 but if i want to deal with the file as ascii what to do?
|
|
|
|
|
The StreamReader and StreamWriter only uses UTF-8 as default if you don't specify an encoding when you create them.
---
b { font-weight: normal; }
|
|
|
|