Exemplo n.º 1
0
        public void ActionCommand(int commandRotate, IGenericGameArea gameArea)
        {
            //TODO: return cell, not only type
            Coordinate targetPosition = AnalyzePosition(commandRotate);
            IBaseCell  cellOnWay      = gameArea.GetCellOnPosition(targetPosition);

            if (cellOnWay == null)
            {
                return;
            }

            PointType cellType = cellOnWay.GetPointType();

            if (cellType == PointType.Food)
            {
                gameArea.TryEat(this, targetPosition);

                return;
            }

            if (cellType == PointType.Cell)
            {
                //Attack?
            }

            if (cellType == PointType.Trap)
            {
                Health = 0;
            }
        }
Exemplo n.º 2
0
        public void TryEat(IGenericCell sender, Coordinate foodPosition)
        {
            IBaseCell cellOnWay = GetCellOnPosition(foodPosition);
            PointType cellType  = cellOnWay.GetPointType();

            if (cellType != PointType.Food)
            {
                throw new ArgumentException();
            }

            sender.Health += ((FoodCell)cellOnWay).HealthIncome();
            RemoveCell(cellOnWay);
        }