//Add a skill to the control. private void AddSkill(Skill skill) { //Check if skill button hasn't already been added. if (!this._skillButtons.ContainsKey(skill)) { //Create the button. ButtonSkill btn = new ButtonSkill(skill); btn.Padding = new Padding(3); btn.Text = skill.ToString(); btn.BackColor = SystemColors.ButtonFace; btn.Click += SkillBtn_Click; btn.Padding = new Padding(3); btn.AutoEllipsis = false; btn.AutoSizeMode = AutoSizeMode.GrowAndShrink; btn.AutoSize = true; //Add the button to the control and dictionary. this.flowLayoutPanelSkillButtons.Controls.Add(btn); this._skillButtons.Add(skill, btn); //Print out to the chatlog to alert the player of a //newly acquired skill. this._chatlog.WriteLine(string.Format("{0} learns the skill: ", this._player.Name), Color.Yellow); this._chatlog.WriteString(string.Format("{0}", skill.Name), Color.LimeGreen); this._chatlog.WriteString("!", Color.Yellow); } }
//Trigger the skill against the enemy. private void SkillBtn_Click(object sender, EventArgs e) { ButtonSkill btn = sender as ButtonSkill; this._game.BattleSimulator.ProcessSkill(btn.Skill); }