Ejemplo n.º 1
0
        public void AIPutACheeseIntoChesseShow()
        {
            var _parent = (((this.Parent as Canvas).Parent as Grid).Parent as Class.DavinciCodePlay);

            Class.Cheese _temp = new Class.Cheese();


            List <int> _tmp = new List <int>();

            int key = 0;

            foreach (var tempcheese in _parent.CheeseSet.Children)
            {
                if (tempcheese is Class.Cheese)
                {
                    if ((tempcheese as Class.Cheese).Pass == false)
                    {
                        _tmp.Add(key);
                    }
                }
                key++;
            }

            _temp        = (_parent.CheeseSet.Children[_tmp[_parent.ran.Next(_tmp.Count)]] as Class.Cheese);
            _temp.Locked = true;

            //foreach (var _item in _parent.CheeseSet.Children)
            //{
            //    if (_item is Cheese)
            //    {
            //        _tmp = (_item as Cheese);
            //        break;
            //    }
            //}
            CheeseTmp = _temp;
            _parent.CheeseSet.Children.Remove(_temp);
            _parent.CheeseSet.Children.Add(_temp);
            DoubleAnimation TopMove  = new DoubleAnimation(Canvas.GetTop(_temp), Canvas.GetTop(_parent.CheeseShowSecend) + 25, new Duration(TimeSpan.FromSeconds(1)));
            DoubleAnimation LeftMove = new DoubleAnimation(Canvas.GetLeft(_temp), Canvas.GetLeft(_parent.CheeseShowSecend) + 25, new Duration(TimeSpan.FromSeconds(1)));

            TopMove.DecelerationRatio  = 0.7;
            LeftMove.AccelerationRatio = 0.3;
            LeftMove.DecelerationRatio = 0.7;
            Storyboard myStoryboard = new Storyboard();

            myStoryboard.Completed += new EventHandler(EndAIPutACheeseIntoChesseShow);
            myStoryboard.Children.Add(TopMove);
            myStoryboard.Children.Add(LeftMove);

            Storyboard.SetTarget(TopMove, _temp);
            Storyboard.SetTargetProperty(TopMove, new PropertyPath(Canvas.TopProperty));
            Storyboard.SetTarget(LeftMove, _temp);
            Storyboard.SetTargetProperty(LeftMove, new PropertyPath(Canvas.LeftProperty));
            myStoryboard.Begin();
        }
Ejemplo n.º 2
0
        public UIElement RemoveCheese()
        {
            Class.Cheese _tmp = (this.MainCheeseShow.Children[0] as Class.Cheese);



            (((this.Parent as Canvas).Parent as Grid).Parent as Class.DavinciCodePlay).cheesenum--;

            if ((((this.Parent as Canvas).Parent as Grid).Parent as Class.DavinciCodePlay).cheesenum == 0)
            {
                (((this.Parent as Canvas).Parent as Grid).Parent as Class.DavinciCodePlay).Lose();
            }
            this.MainCheeseShow.Children.RemoveAt(0);
            return(_tmp);
        }
Ejemplo n.º 3
0
        public void RemoveCheeseNoReturn()
        {
            try
            {
                Class.Cheese _tmp = (this.MainCheeseShow.Children[0] as Class.Cheese);



                (((this.Parent as Canvas).Parent as Grid).Parent as Class.DavinciCodePlay).cheesenum--;

                if ((((this.Parent as Canvas).Parent as Grid).Parent as Class.DavinciCodePlay).cheesenum == 0)
                {
                    (((this.Parent as Canvas).Parent as Grid).Parent as Class.DavinciCodePlay).Lose();
                }
                this.MainCheeseShow.Children.RemoveAt(0);
            }
            catch
            { }
            //return _tmp;
        }