Example #1
0
        void frmMain_MouseClick(object sender, MouseEventArgs e)
        {
            if (!CanIMove()) return;

            // cannot click if not my turn
            if (this._engine._turn._currentCharacter._playerId != this._playerIdMe) return;

            if (e.Button == MouseButtons.Left)
            {
                if (_rectRetreat.Contains(e.X, e.Y))
                {
                    this.Close();
                    return;
                }
                else if (_rectCastSpell.Contains(e.X, e.Y))
                {
                    Heroes.Core.Battle.Characters.Hero hero = GetCurrentHero();
                    ShowCastSpell(hero);
                    return;
                }
                else if (_rectWait.Contains(e.X, e.Y))
                {
                    _engine._turn.Wait();

                    CommandIssuedEventArg e2 = new CommandIssuedEventArg(e.X, e.Y, e.Button, true, (int)CommandTypeEnum.Wait, null);
                    OnCommandIssued(e2);
                    return;
                }
                else if (_rectDefend.Contains(e.X, e.Y))
                {
                    _engine._turn.Defend();

                    CommandIssuedEventArg e2 = new CommandIssuedEventArg(e.X, e.Y, e.Button, true, (int)CommandTypeEnum.Defend, null);
                    OnCommandIssued(e2);
                    return;
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                // cancel cast spell
                if (this.Cursor == Cursors.Hand)
                {
                    Heroes.Core.Battle.Characters.Hero hero = GetCurrentHero();
                    ShowCastSpell(hero);
                    return;
                }
            }

            {
                Heroes.Core.Battle.CommandTypeEnum cmdType = Heroes.Core.Battle.BattleEngine.GetCommandType(this.Cursor);
                _engine.ProcessMouseClick(e.X, e.Y, e.Button, false, cmdType, null);
            }
        }
Example #2
0
        void frmMain_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!CanIMove()) return;

            // cannot click if not my turn
            if (this._engine._turn._currentCharacter._playerId != this._playerIdMe) return;

            Heroes.Core.Battle.CommandTypeEnum cmdType = Heroes.Core.Battle.BattleEngine.GetCommandType(this.Cursor);

            Heroes.Core.Spell spell = null;
            if (cmdType == CommandTypeEnum.Spell)
            {
                Heroes.Core.Battle.Characters.Hero hero = GetCurrentHero();
                spell = hero._currentSpell;
            }

            _engine.ProcessMouseClick(e.X, e.Y, e.Button, true, cmdType, spell);

            // reset cursor
            this.Cursor = Cursors.Default;

            CommandIssuedEventArg e2 = new CommandIssuedEventArg(e.X, e.Y, e.Button, true, (int)cmdType, spell);
            OnCommandIssued(e2);
        }
Example #3
0
 protected virtual void OnCommandIssued(CommandIssuedEventArg e)
 {
     if (CommandIssued != null)
     {
         //Invokes the delegates.
         CommandIssued(e);
     }
 }