Inheritance: GameCommand
Esempio n. 1
0
        public void killCreature()//Kill pack AND creature
        {
            RandomGenerator.initializeWithSeed(123);
            Game game = new Game(5, 2, 20);

            game.player.dungeon = game.dungeon;


            Node n    = new Node();
            Pack pack = new Pack("999", 1, n, null);

            game.player.location = n;
            n.packs.Add(pack);
            n.contested        = true;
            pack.members[0].HP = 5;

            Console.WriteLine(pack.members[0].HP); //hp is 5

            AttackCommand attack = new AttackCommand();

            attack.Execute(game.player, game.dungeon);


            Assert.AreEqual(1, game.player.KillPoint);
            Assert.AreEqual(0, n.packs.Count);
            Assert.AreEqual(0, pack.members.Count);
        }
    void UpdateCommand(AttackCommand command)
    {
        boardManager.ResetAllIndicators();
        if (command.moveName == EarthElemental.Moves.PEBBLESTORM)
        {
        }
        else if (command.moveName == EarthElemental.Moves.BOULDERDROP)
        {
        }
        else if (command.moveName == EarthElemental.Moves.ROCKTHROW)
        {
            command.coords = rockThrow.CalculateTargets();
        }
        else if (command.moveName == EarthElemental.Moves.CRYSTALBLOCK)
        {
        }
        else if (command.moveName == EarthElemental.Moves.CRYSTALIZE)
        {
        }
        else
        {
            Debug.LogWarning("Unknown Attack processed");
        }

        if (command.coords != null)
        {
            foreach (int[] coord in command.coords)
            {
                boardManager.GetTile(coord[0], coord[1]).SetAttackIndicator(true);
            }
        }
    }
    public IEnumerator ProcessNextAttack()
    {
        AttackCommand command = DeQueue();

        if (command == null)
        {
            Debug.LogWarning("No command dequeued");
            yield break;
        }
        if (command.moveName == EarthElemental.Moves.PEBBLESTORM)
        {
            yield return(StartCoroutine(pebbleStorm.CastSkill()));
        }
        else if (command.moveName == EarthElemental.Moves.BOULDERDROP)
        {
            yield return(StartCoroutine(boulderDrop.CastSkill()));
        }
        else if (command.moveName == EarthElemental.Moves.ROCKTHROW)
        {
            yield return(StartCoroutine(rockThrow.CastSkill(command)));
        }
        else if (command.moveName == EarthElemental.Moves.CRYSTALBLOCK)
        {
            yield return(StartCoroutine(crystalBlock.CastSkill()));
        }
        else if (command.moveName == EarthElemental.Moves.CRYSTALIZE)
        {
            yield return(StartCoroutine(crystalize.CastSkill()));
        }
        else
        {
            Debug.LogWarning("Unknown Attack processed");
        }
    }
Esempio n. 4
0
        public void AttackCommand()
        {
            //check if attackcommand attacks monsters
            Game game = new Game(5, 2, 20);

            Dungeon d    = new Dungeon(1, 0);
            Pack    pack = new Pack("1", 1, d.startNode, d);

            game.dungeon         = d;
            game.player.location = d.startNode;
            d.startNode.packs.Add(pack);
            d.startNode.contested = true;
            Player p = new Player();

            p.location = d.startNode;
            p.dungeon  = d;

            //superpowers
            p.AttackRating = 100;

            AttackCommand cmd = new AttackCommand();

            cmd.Execute(game.player, game.dungeon);

            Assert.True(!p.location.contested && p.location.packs.Count == 0);
        }
        public IExecutable ManageCommand(string[] inputArgs)
        {
            IExecutable command = null;

            string commandType = inputArgs[0];

            switch (commandType)
            {
                case "create":
                    command = new CreateCommand(this.Engine, inputArgs[1], int.Parse(inputArgs[2]), int.Parse(inputArgs[3]),
                        (BehaviorTypes)Enum.Parse(typeof(BehaviorTypes), inputArgs[4]), (AttackTypes)Enum.Parse(typeof(AttackTypes), inputArgs[5]));
                    break;
                case "attack":
                    command = new AttackCommand(this.Engine, inputArgs[1], inputArgs[2]);
                    break;
                case "pass":
                    command = new PassCommand();
                    break;
                case "status":
                    command = new StatusCommand(this.Engine);
                    break;
                case "drop":
                    command = new DropCommand();
                    break;
            }

            return command;
        }
Esempio n. 6
0
        /*
         * 命令模式: 将一个请求封装为一个对象,从而使你可用不同的请求对客户(客户程序,也是行为的请求者)进行参数化;对请求排队或记录请求日志,以及支持可撤销的操作。——《设计模式》GoF
         *
         * 使用频率:★★★★☆
         *
         * 模式的组成:
         *
         *  (1)、客户角色(Client):创建具体的命令对象,并且设置命令对象的接收者。注意这个不是我们常规意义上的客户端,而是在组装命令对象和接收者,或许,把这个Client称为装配者会更好理解,因为真正使用命令的客户端是从Invoker来触发执行。
         *   这里暂时没有,是我们手动创建的
         *
         *  (2)、命令角色(Command):声明了一个给所有具体命令类实现的抽象接口。
         *      如:[Command]
         *
         *  (3)、具体命令角色(ConcreteCommand):命令接口实现对象,是“虚”的实现;通常会持有接收者,并调用接收者的功能来完成命令要执行的操作。
         *      如:[AttackCommand,RetreatCommand]
         *
         *  (4)、请求者角色(Invoker):要求命令对象执行请求,通常会持有命令对象,可以持有很多的命令对象。这个是客户端真正触发命令并要求命令执行相应操作的地方,也就是说相当于使用命令对象的入口。
         *      如:[Commander]
         *
         *  (5)、接受者角色(Receiver):接收者,真正执行命令的对象。任何类都可能成为一个接收者,只要它能够实现命令要求实现的相应功能。
         *      如:[Soldier]
         *
         */
        static void Main(string[] args)
        {
            Soldier soldier = new Soldier();

            //1.司令员决定,策划两个命令
            Command command1 = new AttackCommand("进攻敌人左侧城楼", soldier);
            Command command2 = new RetreatCommand("撤退到根据地", soldier);


            Commander commander = new Commander();

            Console.WriteLine("===============下发命令1===============");
            //下发命令1
            commander.Command = command1;
            commander.SendCommand();

            Console.WriteLine("===============下发命令2===============");
            //下发命令2
            commander.Command = command2;
            commander.SendCommand();

            Console.ReadKey();

            /*
             * 总结:
             * 1.命令模式把命令的发出者和命令的执行者分开了,单独来用一个命令来保证两者的关系。
             * 2.Commander也可以持有多个命令,如果是一系列的队列命令,我们就可以一直的发命令可以对命令进行管理,比如撤销,恢复什么的。
             *
             */
        }
Esempio n. 7
0
    public static void EnemyAttack()
    {
        foreach (EnemyBehaviour enemy in instance.activeEnemies)
        {
            if (enemy.Active != false)
            {
                Transform target = CharacterObserver.GetEnemyTarget();
                if (target != null)
                {
                    PlayerMoveCommand move = new PlayerMoveCommand();
                    move.AssignMove(enemy.transform, enemy.transform.position, target.position);
                    PlayerCommand.AddCommand(move);

                    AttackCommand attack = new AttackCommand();
                    attack.AssignCommand(10, target.gameObject);
                    attack.AssignAnimation(enemy.gameObject, "Attack", 0f);
                    PlayerCommand.AddCommand(attack);

                    PlayerMoveCommand move2 = new PlayerMoveCommand();
                    move2.AssignMove(enemy.transform, target.position, enemy.transform.position);
                    PlayerCommand.AddCommand(move2);
                }
            }
        }
    }
Esempio n. 8
0
        public void CommandDemo()
        {
            Monster monster    = new Zombie(10, 10, 10, 0, 0);
            Player  demoPlayer = new Player
            {
                Name  = "DemoPlayer",
                Score = 100,
                Life  = 100,
                PosX  = rnd.Next(1, 2),
                PosY  = rnd.Next(1, 2)
            };

            Form1.commandLogger.logMessage(AbstractLogger.TEST, "\t\nCommand Test:\n\n");
            Form1.commandLogger.logMessage(AbstractLogger.TEST, demoPlayer.Name + " " + demoPlayer.Life + "\n");
            Form1.commandLogger.logMessage(AbstractLogger.TEST, "executing attack command on " + demoPlayer.Name + "\n");

            AttackCommand demoCommand = new AttackCommand(monster, demoPlayer);

            Form1.commandLogger.logMessage(AbstractLogger.TEST, demoPlayer.Name + " " + demoPlayer.Life + "\n");
            Form1.commandLogger.logMessage(AbstractLogger.TEST, "UNDOing attack command on " + demoPlayer.Name + "\n");

            demoCommand.undo(ref demoPlayer);

            Form1.commandLogger.logMessage(AbstractLogger.TEST, demoPlayer.Name + " " + demoPlayer.Life + "\n\n");
        }
Esempio n. 9
0
    public override void UndoAttack(AttackCommand lastAttack, bool _isThisUnitTheAttacker)
    {
        base.UndoAttack(lastAttack, _isThisUnitTheAttacker);

        if (!_isThisUnitTheAttacker)
        {
            isInRage           = lastAttack.isInRage;
            turnsLeftToRageOff = lastAttack.rageTurnsLeft;

            if (!isInRage)
            {
                isInRageIcon.SetActive(false);
                turnsLeftToRageOff = maxNumberOfTurnsInRage;
                myPanelPortrait.GetComponent <Portraits>().specialSkillTurnsLeft.enabled = false;

                RageColor();
            }
        }

        Debug.Log("woooooowooo");

        //Quitar efectos de rage visuales si se le quita con el undo

        //Estas líneas las añado para comprobar si hay samurai y si hay que actualizar el honor
        Samurai samuraiUpgraded = FindObjectOfType <Samurai>();

        if (samuraiUpgraded != null)
        {
            samuraiUpgraded.RefreshHonorOnPortrait();
        }
        UIM.CheckActionsAvaliable();
    }
Esempio n. 10
0
    public override bool Execute()
    {
        if (!CheckTarget() || !CheckCost(actionCost))
        {
            return(false);
        }

        Pawn tPawn = target.GetComponent <Pawn>();

        if (owner.weapon.range == 1)
        {
            AttackCommand.Attack(owner, target);
        }

        LinkPositions pushDirection;

        pushDirection = owner.currentNode.GetRelativePositionInLinks(tPawn.currentNode);
        for (int i = 0; i < distance; i++)
        {
            NodeBehaviour tmpNode = tPawn.currentNode.GetLinkInDirection(pushDirection);
            if (!tmpNode.isOccupied)
            {
                tPawn.GetComponent <GridNavMeshWrapper>().currentNode = tmpNode;
            }
        }
        return(true);
    }
Esempio n. 11
0
 void ExecuteOnAttack(IonianTone?tone)
 {
     if (AttackCommand?.CanExecute(tone) ?? false)
     {
         AttackCommand.Execute(tone);
     }
 }
Esempio n. 12
0
        public void PrzeciwnikPanikujeOkreslonaIloscCzasu()
        {
            // arrange
            Creature enemyInPanic = TestObjects.GetSimpleCreature(map, player);

            enemyInPanic.MeleeWeapon = new MeleeWeapon()
            {
                Damage = 5
            };
            enemyInPanic.PanicModeCounter = 1;
            map[0, 0].putCreature(player);
            map[0, 1].putCreature(enemyInPanic);

            // act
            ICreatureCommand command1  = enemyInPanic.AI.GenerateNextCommand();
            MoveCommand      mCommand1 = command1 as MoveCommand;

            ICreatureCommand command2  = enemyInPanic.AI.GenerateNextCommand();
            AttackCommand    mCommand2 = command2 as AttackCommand;

            // assert
            Assert.IsInstanceOfType(command1, typeof(MoveCommand));
            Assert.AreEqual <MoveCommand.Direction>(MoveCommand.Direction.RightDown, mCommand1.moveDirection);
            Assert.IsInstanceOfType(command2, typeof(AttackCommand));
        }
Esempio n. 13
0
 public void Attack(AttackCommand ac)
 {
     if (attackDelegate != null)
     {
         attackDelegate();
     }
 }
Esempio n. 14
0
        static void Main(string[] args)
        {
            CombatLogger logger = new CombatLogger();

            IHandler handler = new Handler();

            logger.SetSuccessor(handler);
            logger.Handle(LogType.ATTACK, "Hello");

            Logger combatLog = new CombatLogger();
            Logger eventLog  = new EventLogger();

            combatLog.SetSuccessor(eventLog);
            var warrior = new Warrior("gosho", 100, combatLog);
            var dragon  = new Dragon("Peter", 100, 25, combatLog);

            warrior.SetTarget(dragon);
            dragon.Register(warrior);

            warrior.Attack();

            IExecutor executor = new CommandExecutor();
            ICommand  command  = new TargetCommand(warrior, dragon);
            ICommand  attack   = new AttackCommand(warrior);
        }
Esempio n. 15
0
    public void AttackTarget()
    {
        AttackCommand command   = (AttackCommand)currentCommand;
        Vector3       targetPos = new Vector3(command.target.transform.position.x, 0f, command.target.transform.position.y);
        float         dist      = Vector3.Distance(targetPos, transform.position);

        Debug.Log(dist);
        if (dist > attackRange)
        {
            agent.destination = targetPos;
        }
        else
        {
            if (isMelee)
            {
                //punch
            }
            else
            {
                GameObject go;
                go = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/Projectile"));
                go.transform.position = transform.position;
                Projectile projectile = go.GetComponent <Projectile>();
                projectile.target = command.target;
                projectile.speed  = projectileSpeed;
                currentCommand    = null;
                agent.destination = transform.position;
            }
        }
    }
Esempio n. 16
0
    public override void UndoAttack(AttackCommand lastAttack, bool _isThisUnitTheAttacker)
    {
        base.UndoAttack(lastAttack, _isThisUnitTheAttacker);

        if (isDead &&
            (_isThisUnitTheAttacker && lastAttack.pjPreviousHealth > 0) ||
            (!_isThisUnitTheAttacker && lastAttack.objPreviousHealth > 0))
        {
            for (int i = 0; i < LM.charactersOnTheBoard.Count; i++)
            {
                if (LM.charactersOnTheBoard[i].GetComponent <Mage>())
                {
                    myMage = LM.charactersOnTheBoard[i].GetComponent <Mage>();

                    myMage.myDecoys.Add(gameObject);
                    LM.charactersOnTheBoard.Add(this);

                    break;
                }
            }

            EnableUnableCollider(true);
            //Estas líneas las añado para comprobar si hay samurai y si hay que actualizar el honor
            Samurai samuraiUpgraded = FindObjectOfType <Samurai>();

            if (samuraiUpgraded != null)
            {
                samuraiUpgraded.RefreshHonorOnPortrait();
            }
            UIM.CheckActionsAvaliable();
        }
    }
Esempio n. 17
0
 public RunAttackCommand(Monster self, Unit paramTarget)
 {
     monster       = self;
     target        = paramTarget;
     moveCommand   = new MoveCommand(self, paramTarget);
     attackCommand = new AttackCommand(self, paramTarget);
 }
Esempio n. 18
0
        private void InputController_ClickEvent(object sender, InfoEventArgs <GameObject> e)
        {
            var player = connector.Game.CurrentPlayer;

            if (player != null)
            {
                var gameobjectevent = e.Info;

                Debug.Log($"Clicked object : {gameobjectevent}");

                ICommand command = default(ICommand);

                if (gameobjectevent.name.Contains("Grid") && state == PlayerState.Idle)
                {
                    command = new MoveCommand(player.Visual, gameobjectevent, player, SpellBar, DisplayInfos);
                }
                else if (gameobjectevent.name.Contains("Grid") && state == PlayerState.IsAttacking)
                {
                    command = new AttackCommand(player.Visual, gameobjectevent, this, player, SpellBar, DisplayInfos);
                }
                else if (gameobjectevent.name.Contains("Spell"))
                {
                    int spellIndex = 0;
                    int.TryParse(gameobjectevent.name.Replace("Spell", string.Empty), out spellIndex);

                    command = new SelectSpellCommand(player.Visual, spellIndex, this, player);
                }

                if (command != null && command.EvaluateCommand())
                {
                    command.ExecuteCommand();
                }
            }
        }
        public IExecutable ManageCommand(string[] inputArgs)
        {
            IExecutable command = null;

            string commandType = inputArgs[0];

            switch (commandType)
            {
            case "create":
                command = new CreateCommand(this.Engine, inputArgs[1], int.Parse(inputArgs[2]), int.Parse(inputArgs[3]),
                                            (BehaviorTypes)Enum.Parse(typeof(BehaviorTypes), inputArgs[4]), (AttackTypes)Enum.Parse(typeof(AttackTypes), inputArgs[5]));
                break;

            case "attack":
                command = new AttackCommand(this.Engine, inputArgs[1], inputArgs[2]);
                break;

            case "pass":
                command = new PassCommand();
                break;

            case "status":
                command = new StatusCommand(this.Engine);
                break;

            case "drop":
                command = new DropCommand();
                break;
            }

            return(command);
        }
    /*
     * Execute
     * overrides function Unit's Execute(GameManagment.eActionType actionType, int tileX, int tileY)
     *
     * adds a command of the specified type to the unit
     *
     * @param GameManagement.eActionType actionType - the type of action to execute
     * @param Tiles st - the first tile selected
     * @param Tiles et - the last tile selected
     * @param UnitCommand.VoidFunc callback - function reference to invoke if the command completes
     * @returns void
     */
    public override void Execute(GameManagment.eActionType actionType, Tiles st, Tiles et, UnitCommand.VoidFunc callback, bool safeMove)
    {
        //create a list of function references to execute
        UnitCommand.VoidFunc callstack = OnCommandFinish;
        callstack += callback;

        //movement command
        if (actionType == GameManagment.eActionType.MOVEMENT)
        {
            MoveCommand mc = new MoveCommand(this, callstack, OnCommandFailed, st, et, safeMove);

            commands.Add(mc);
        }
        //attack command
        else if (actionType == GameManagment.eActionType.ATTACK)
        {
            AttackCommand ac = new AttackCommand(this, callstack, OnCommandFailed, st, et);

            ac.attackTimer = attackTime;

            commands.Add(ac);
        }
        //dying command
        else if (actionType == GameManagment.eActionType.DEATH)
        {
            DeathCommand dc = new DeathCommand(this, callstack, null, st, null);

            dc.deathTimer = deathTime;

            commands.Add(dc);
        }
    }
Esempio n. 21
0
        public void acceleratedKillAllMonsters()
        {
            RandomGenerator.initializeWithSeed(123);
            Game game = new Game(5, 2, 20);

            game.player.dungeon = game.dungeon;


            Node n    = new Node();
            Pack pack = new Pack("999", 5, n, null);

            game.player.location = n;
            n.packs.Add(pack);
            n.contested             = true;
            game.player.accelerated = true;

            //set HP to 10, so player can't kill them.
            foreach (Monster m in pack.members.ToList())
            {
                m.HP = 1;
            }

            AttackCommand attack = new AttackCommand();

            attack.Execute(game.player, game.dungeon);


            Assert.AreEqual(5, game.player.KillPoint);
            Assert.AreEqual(0, n.packs.Count);
            Assert.AreEqual(0, pack.members.Count);
        }
Esempio n. 22
0
    private void Start()
    {
        this.player = GetComponent <Player>();

        attack = new AttackCommand(this.player);
        block  = new BlockCommand(this.player);
        dodge  = new DodgeCommand(this.player);
    }
 void OnGUI()
 {
     if (GUI.Button(new Rect(50, 50, 60, 40), "Attack"))
     {
         AttackCommand attackCommand = new AttackCommand(GameObject.FindGameObjectWithTag(Consts.TAG_PLAYER).GetComponent <BaseWorldCharacter>());
         ExecuteCommand(attackCommand);
     }
 }
        public void ThrowArgumentException_WhenLessStringArgumentsArePassed()
        {
            var attackCommand = new AttackCommand();

            var bmanager = new Mock <IBattleManager>();

            Assert.Throws <ArgumentException>(() => attackCommand.ProcessCommand(bmanager.Object, new string[] { "Pesho" }));
        }
        public void ThrowArgumentNullException_WhenNullStringArgumentsPassed()
        {
            var attackCommand = new AttackCommand();

            var bmanager = new Mock <IBattleManager>();

            Assert.Throws <ArgumentNullException>(() => attackCommand.ProcessCommand(bmanager.Object, null));
        }
Esempio n. 26
0
 private void AttackKey()
 {
     if (AttackCommand?.CanExecute(this) ?? false)
     {
         AttackCommand.Execute(this);
         attacked       = true;
         Rectangle.Fill = Sharp ? SharpAttackKeyFill : AttackKeyFill;
     }
 }
Esempio n. 27
0
 public Command ButtonAttack()
 {
     if (bActionUI)
     {
         AttackCommand command = new AttackCommand(selectedActor);
         return(command);
     }
     return(null);
 }
 void issueAttackCommand(Unit target)
 {
     for (int i = 0; i < selectedUnits.Count; i++)
     {
         AttackCommand command = new AttackCommand();
         command.target = target;
         selectedUnits[i].currentCommand = command;
     }
 }
Esempio n. 29
0
 async Task OnAttackUnit(AttackCommand cmd)
 {
     if (cmd.TargetId == _model.State.Id)
     {
         var diff = _oldHealth - _model.State.Health;
         _oldHealth = _model.State.Health;
         await _view.AnimateDamage(diff);
     }
 }
Esempio n. 30
0
 public AEnemyObject(PigTypes pigType, SpriteGenerator sprites, Vector2 beginPosition, Dictionary <TextTypes, SpriteFont> spriteFonts, int hearts, int attackDamage, MoveTypes moveTypes) : base(pigType, sprites, beginPosition, spriteFonts, moveTypes)
 {
     beginHearts       = hearts;
     beginAttackDamage = attackDamage;
     Attack            = new AttackCommand();
     Hearts            = hearts;
     AttackDamage      = attackDamage;
     CheckSprites();
 }
Esempio n. 31
0
        /// <summary>
        /// Provides a very basic finite-state machine to control the interactions
        /// with the game. When a case is clicked, there are several possible
        /// actions according to the UI's current state.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CaseClicked(object sender, CaseClickedEventArgs e)
        {
            switch (_state)
            {
            case CommandState.Selecting:
                var select = new SelectCaseCommand(_game, _gameControl);
                if (select.CanExectute(e.ClickedCase))
                {
                    select.Execute(e.ClickedCase);
                }
                else
                {
                    _gameControl.DisplayInvalidCommandOn(e.ClickedCase);
                }

                break;

            case CommandState.Moving:
                var unitToMove = ((UnitView)_units.SelectedItem).Unit;
                var move       = new MoveUnitCommand(_game, unitToMove);

                if (move.CanExectute(e.ClickedCase))
                {
                    move.Execute(e.ClickedCase);
                    ResetUIState();
                    _gameControl.SelectCase(e.ClickedCase);
                }
                else
                {
                    _gameControl.DisplayInvalidCommandOn(e.ClickedCase);
                }

                break;

            case CommandState.Attacking:
                var attackWithUnit = ((UnitView)_units.SelectedItem).Unit;
                var attack         = new AttackCommand(attackWithUnit);

                if (attack.CanExectute(e.ClickedCase))
                {
                    attack.Execute(e.ClickedCase);
                    ResetUIState();
                    _gameControl.SelectCase(e.ClickedCase);
                }
                else
                {
                    _gameControl.DisplayInvalidCommandOn(e.ClickedCase);
                }
                break;

            default:
                _state = CommandState.Selecting;
                CaseClicked(sender, e);
                break;
            }
        }
Esempio n. 32
0
    public override void TurnOnGUI()
    {
        float buttonHeight = 50;
        float buttonWidth = 150;

        Rect buttonRect = new Rect(0, Screen.height - buttonHeight * 7, buttonWidth, buttonHeight);
        ICharacterActionCommand cmd;
        //move button
        if (GUI.Button(buttonRect, "Move"))
        {
            if (!_isMoving)
            {
                GameManager.instance.removeTileHighlights();
                _isMoving = true;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                cmd = new MoveCommand(null, null);
                _cmdManager.CommandStack.Push(cmd);
                ((MoveCommand)cmd).Execute();
                GameManager.instance.highlightTilesAt(gridPosition, Color.blue, movementPerActionPoint, false);
            }
            else
            {
                _isMoving = false;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = false;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //attack/heal button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 6, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Attack"))
        {
            if (!_isAttacking)
            {
                //GameManager.instance.removeTileHighlights();
                _isMoving = false;
                _isAttacking = true;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                cmd = new AttackCommand(null);
                _cmdManager.CommandStack.Push(cmd);
                ((AttackCommand)cmd).Execute();
                //GameManager.instance.highlightTilesAt(gridPosition, Color.red, attackRange);
            }
            else
            {
                _isMoving = true;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //defend button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 5, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Defend"))
        {
            if (!_isDefending)
            {
                //GameManager.instance.removeTileHighlights();
                _isMoving = false;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = true;
                _isRotating = false;
                cmd = new DefendCommand(null);
                _cmdManager.CommandStack.Push(cmd);
                ((DefendCommand)cmd).Execute(this);
                //GameManager.instance.highlightTilesAt(gridPosition, Color.red, attackRange);
            }
            else
            {
                _isMoving = false;
                _isAttacking = false;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //rotate button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 4, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Rotate"))
        {
            if (!_isRotating)
            {
                //GameManager.instance.removeTileHighlights();
                _isMoving = false;
                _isAttacking = true;
                _hasPerformedAtLeastOneMove = false;
                _isDefending = false;
                _isRotating = true;
                cmd = new RotateCommand(null);
                _cmdManager.CommandStack.Push(cmd);
                ((RotateCommand)cmd).Execute();
                //GameManager.instance.highlightTilesAt(gridPosition, Color.red, attackRange);
            }
            else
            {
                _isMoving = true;
                _isAttacking = false;
                _hasPerformedAtLeastOneMove = true;
                _isDefending = false;
                _isRotating = false;
                //GameManager.instance.removeTileHighlights();
            }
        }

        //undo button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 3, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Undo"))
        {
            if (_hasPerformedAtLeastOneMove)
            {
                _cmdManager.Undo(this, _cmdManager.LastCharacterAttacked);
                if (_cmdManager.CommandStack.Count == 0)
                    _hasPerformedAtLeastOneMove = false;
            }
        }

        //skip button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 2, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "Skip"))
        {
            GameManager.instance.GoToNextCharacter();
        }

        //end turn button
        buttonRect = new Rect(0, Screen.height - buttonHeight * 1, buttonWidth, buttonHeight);

        if (GUI.Button(buttonRect, "End Turn"))
        {
            GameManager.instance.GoToNextCharacter();
        }

        base.TurnOnGUI();
    }