Exemplo n.º 1
0
        public override void Moved()
        {
            if (!MovedCommon())
            {
                return;
            }
            AddUpperEntities();
            AddMovingEntity(Loc.X + 1, Loc.Y);
            AddMovingEntity(Loc.X - 1, Loc.Y);
            var newCell = NextLoc.Get(Model.Data);

            if (Model.MovingEntities.ContainsKey(NextLoc) && newCell.TypeOfCell != CellType.Ball)
            {
                Model.MovingEntities.Remove(NextLoc);
            }
            newCell.TypeOfCell = CellType.Murphy;
            Loc = NextLoc;
        }
Exemplo n.º 2
0
        public string Moving()
        {
            Vector bufferDir = Vector.Null;
            var    directs   = new List <Vector>();

            foreach (var direct in GetDirectionsFromLeft())
            {
                var nextCell = (Loc + direct).Get(Model.Data);
                if (nextCell != null && (nextCell.TypeOfCell == CellType.None || nextCell.TypeOfCell == CellType.Murphy) &&
                    !nextCell.ToBeFilled)
                {
                    if (!_passedPoints.Contains(direct))
                    {
                        directs.Add(direct);
                    }
                    else
                    if (bufferDir == Vector.Null)
                    {
                        bufferDir = direct;
                    }
                }
            }
            // rotate scissors
            var scissorsType = Loc.Get(Model.Data).TypeOfScissors;

            if (!directs.Contains(MoveDir) && MoveDir != bufferDir)
            {
                Vector nextDir;
                if (directs.Count != 0)
                {
                    nextDir = directs[0];
                    _passedPoints.Add(nextDir);
                }
                else
                {
                    if (bufferDir == Vector.Null)
                    {
                        return("");
                    }
                    nextDir = bufferDir;
                    _passedPoints.Clear();
                }
                scissorsType = (DirectionType)(Array.IndexOf(PathBranch.CommonDirectons, nextDir) + 1);
                Loc.Get(Model.Data).TypeOfScissors = scissorsType;
                return("");
            }
            // moove in the direction set
            NextLoc = Loc + MoveDir;
            var newCell = NextLoc.Get(Model.Data);

            newCell.ToBeFilled = true;
            if (newCell.TypeOfCell == CellType.Murphy)
            {
                Model.GameFinishing(false);
                return("");
            }
            switch (scissorsType)
            {
            case DirectionType.Down:
                return("D");

            case DirectionType.Up:
                return("U");

            case DirectionType.Left:
                return("L");

            default:
                return("R");
            }
        }