Exemple #1
0
        public FlowerMovment TransformRootToMovement()
        {
            PathNode oneBeforeRoot = this;

            while (oneBeforeRoot.Prev.Prev != null)
            {
                oneBeforeRoot = oneBeforeRoot.Prev;
            }
            FlowerMovment flm = new FlowerMovment
                                    (oneBeforeRoot.Prev.CurrentFlower,
                                    oneBeforeRoot.CurrentFlower);

            Console.WriteLine(oneBeforeRoot);
            return(flm);
        }
        public static void RandomMove()
        {
            Flower        computer     = GameManager.GetGameManager().GetGameGraph().GetComputerFlower();
            FlowerMovment fm           = null;
            Random        rnd          = new Random();
            bool          nextDotFound = false;

            while (!nextDotFound)
            {
                switch (rnd.Next(0, 6))
                {
                case 0:
                {
                    fm = new FlowerMovment(computer, computer.GetTopLeft());
                    break;
                }

                case 1:
                {
                    fm = new FlowerMovment(computer, computer.GetTopRight());
                    break;
                }

                case 2:
                {
                    fm = new FlowerMovment(computer, computer.GetRight());
                    break;
                }

                case 3:
                {
                    fm = new FlowerMovment(computer, computer.GetBottomRight());
                    break;
                }

                case 4:
                {
                    fm = new FlowerMovment(computer, computer.GetBottomLeft());
                    break;
                }

                case 5:
                {
                    fm = new FlowerMovment(computer, computer.GetLeft());
                    break;
                }
                }
                if (fm.GetDestenation() == null)
                {
                    GameManager.GetGameManager().DoComputerVictory();
                    break; // prevent next checks
                }
                if (!fm.GetSource().IsEscapeable())
                {
                    GameManager.GetGameManager().DoPlayerVictory();
                    break;
                }
                if (fm.GetDestenation().GetFlowerState() == Flower.DotState.Empty)
                {
                    nextDotFound = true;
                    break;
                }
            }
            if (nextDotFound)
            {
                GameManager.GetGameManager().PerformMovement(fm);
            }
        }