Ejemplo n.º 1
0
    public void OnClick()
    {
        gameObject.SetActive(false);

        MyCanvas.SetActive("Button2", true);
        ButtonFlag = true;
    }
Ejemplo n.º 2
0
 private void ExportButton_Click(object sender, RoutedEventArgs e)
 {
     if (TreeTop.Figures.Count != 0)
     {
         SaveFileDialog sfd = new SaveFileDialog
         {
             Title           = "Сохранить как",
             OverwritePrompt = true,
             CheckPathExists = true,
             Filter          = "Files(*.png)|*.png"
         };
         sfd.ShowDialog();
         if (sfd.FileName != "")
         {
             MyCanvas.Measure(new Size((int)MyCanvas.Width, (int)MyCanvas.Height));
             MyCanvas.Arrange(new Rect(new Size((int)MyCanvas.Width, (int)MyCanvas.Height)));
             var rtb = new RenderTargetBitmap((int)MyCanvas.Width, (int)MyCanvas.Height, 96d, 96d, PixelFormats.Pbgra32);
             rtb.Render(MyCanvas);
             PngBitmapEncoder png = new PngBitmapEncoder();
             png.Frames.Add(BitmapFrame.Create(rtb));
             FileStream file = (FileStream)sfd.OpenFile();
             png.Save(file);
             file.Close();
         }
     }
     else
     {
         System.Windows.MessageBox.Show("Нарисуйте что-нибудь...");
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            MyCanvas.CreateNewButton(1, 8, 10, 12);
            MyCanvas.CreateNewButton(1, 6, 20, 10);
            MyCanvas.CreateNewButton(1, 11, 30, 12);

            MyCanvas.Print();

            Console.WriteLine("\nMoveButton(0, 0, 7)");
            MyCanvas.MoveButton(0, 0, 7);
            MyCanvas.Print();

            Console.WriteLine("\nThe Max Width Of A Button is " + MyCanvas.GetTheMaxWidthOfAButton());
            Console.WriteLine("\nThe Max Height Of A Button is " + MyCanvas.GetTheMaxHeightOfAButton());
            Console.WriteLine("\nCurrent Number Of Buttons " + MyCanvas.GetCurrentNumberOfButtons());
            Console.WriteLine("\nIs Point Inside A Button? " + MyCanvas.IsPointInsideAButton(200, 200));
            Console.WriteLine("\nIs Point Inside A Button? " + MyCanvas.IsPointInsideAButton(1, 7));

            Console.WriteLine("\nDeleteLastButton()");
            MyCanvas.DeleteLastButton();
            MyCanvas.Print();

            Console.WriteLine("\nClearAllButtons()");
            MyCanvas.ClearAllButtons();
            Console.WriteLine("Current Number Of Buttons: " + MyCanvas.GetCurrentNumberOfButtons());
        }
        //MAIN WINDOW INITIALIZE
        public AsteroidShooter()
        {
            InitializeComponent();

            gameTimer.Interval = TimeSpan.FromMilliseconds(20);

            //Link The Game Engine To The Game Timer & Start
            gameTimer.Tick += gameEngine;
            gameTimer.Start();
            MyCanvas.Focus();

            //Initialize The Main Window Canvas Background Using An Image
            ImageBrush backgroundImage = new ImageBrush();

            backgroundImage.ImageSource   = new BitmapImage(new Uri("pack://application:,,,/Images/Background.png"));
            backgroundImage.TileMode      = TileMode.Tile;
            backgroundImage.Viewport      = new Rect(0, 0, 0.15, 0.15);
            backgroundImage.ViewportUnits = BrushMappingMode.RelativeToBoundingBox;
            MyCanvas.Background           = backgroundImage;


            //Initialize The Player Sprite
            ImageBrush playerImage = new ImageBrush();

            playerImage.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/Player.png"));
            player.Fill             = playerImage;
        }
 internal void Initialise(MyCanvas canvas)
 {
     this.canvas   = canvas;
     this.quadTree = canvas.QuadTree;
     nodes         = canvas.Nodes;
     edges         = canvas.Edges;
 }
Ejemplo n.º 6
0
        private void GameSetUp()
        {
            // this function will run when the program loads

            MyCanvas.Focus();                                   // set my canvas as the main focus for the program

            gameTimer.Tick    += GameLoop;                      // link the game loop event to the time tick
            gameTimer.Interval = TimeSpan.FromMilliseconds(20); // set time to tick every 20 milliseconds
            gameTimer.Start();                                  // start the time
            currentGhostStep = ghostMoveStep;                   // set current ghost step to the ghost move step

            // below pac man and the ghosts images are being imported from the images folder and then we are assigning the image brush to the rectangles
            ImageBrush pacmanImage = new ImageBrush();

            pacmanImage.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/pacman.jpg"));
            pacman.Fill             = pacmanImage;

            ImageBrush redGhost = new ImageBrush();

            redGhost.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/red.jpg"));
            redGuy.Fill          = redGhost;

            ImageBrush orangeGhost = new ImageBrush();

            orangeGhost.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/orange.jpg"));
            orangeGuy.Fill          = orangeGhost;

            ImageBrush pinkGhost = new ImageBrush();

            pinkGhost.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/pink.jpg"));
            pinkGuy.Fill          = pinkGhost;
        }
Ejemplo n.º 7
0
    public void Equi(int Item_sid)
    {
        GameObject I_temp = mybag.GoEntity(Item_sid);

        I_temp.transform.parent = this.transform.FindChild("Equi");
        string epos = Item.EquiPos(Item_sid);

        if (transform.FindChild("Equi").FindChild(epos) != null)
        {
            GameObject tempequi = transform.FindChild("Equi").FindChild(epos).gameObject;
            GameObject.Find("Environment").transform.FindChild("Item_class").GetComponent <Item_create>().ItemAloneCreate(transform.position, tempequi.GetComponent <Self_class>().s_id);
            UnEqui(tempequi);
            MyCanvas.IssueDis("已装备" + Item.Name(Item_sid) + "之前装备已替下");
            I_temp.name = epos;
        }
        else
        {
            I_temp.transform.parent = transform.FindChild("Equi");
            I_temp.name             = epos;
            MyCanvas.IssueDis("已装备" + Item.Name(Item_sid));
        }
        SelfClass.AddAtribute(I_temp, this.gameObject);
        if (epos == "Hand")
        {
            transform.GetComponent <player>().InsWeapon(Item.WeponModeIndex(Item_sid));
        }
    }
Ejemplo n.º 8
0
        private void aloitaPeli()
        {
            MyCanvas.Focus();

            int temp = 300;

            peliPaattyi = false;
            Canvas.SetTop(Lintu, 190);

            foreach (var x in MyCanvas.Children.OfType <Image>())
            {
                if ((string)x.Tag == "este1")
                {
                    Canvas.SetLeft(x, 500);
                }

                if ((string)x.Tag == "este2")
                {
                    Canvas.SetLeft(x, 800);
                }

                if ((string)x.Tag == "este3")
                {
                    Canvas.SetLeft(x, 1100);
                }

                if ((string)x.Tag == "cloud")
                {
                    Canvas.SetLeft(x, 300 + temp);
                    temp = 800;
                }
            }

            peliAika.Start();
        }
Ejemplo n.º 9
0
 IEnumerator scan()
 {
     while (true)
     {
         RaycastHit hit;
         bool       Tempflag = false;
         for (int i = 0; i < 3; i++)
         {
             if (Physics.Raycast(cplayer.transform.position + (i * 0.4f * cplayer.up), cplayer.transform.forward, out hit, 2))
             {
                 if (hit.transform.name == "WorkTable")
                 {
                     Tempflag = true;
                     break;
                 }
             }
         }
         if (!Tempflag)
         {
             MyCanvas.IssueDis("人物已离开制作所需的建筑");
             ReStart();
             StopCoroutine(scan());
         }
         yield return(new WaitForSeconds(0.02f));
     }
 }
Ejemplo n.º 10
0
        public MainWindow(string nazwaGracza)
        {
            InitializeComponent();

            nazGracza = nazwaGracza;

            licznikGry.Interval = TimeSpan.FromMilliseconds(20);
            licznikGry.Tick    += petla;
            licznikGry.Start();

            MyCanvas.Focus(); //zeby onkeje zastartowaly

            ImageBrush tło = new ImageBrush();

            tło.ImageSource     = new BitmapImage(new Uri("pack://application:,,,/obiekty/purple.png"));
            tło.TileMode        = TileMode.Tile;
            tło.Viewport        = new Rect(0, 0, 0.15, 0.15);
            tło.ViewportUnits   = BrushMappingMode.RelativeToBoundingBox;
            MyCanvas.Background = tło;

            ImageBrush ObGracza = new ImageBrush();

            ObGracza.ImageSource = new BitmapImage(new Uri("pack://application:,,,/obiekty/player.png"));
            gracz.Fill           = ObGracza;
        }
Ejemplo n.º 11
0
    public void use(int Item_sid)
    {
        if (!mybag.Query(Item_sid))
        {
            MyCanvas.IssueDis("该物品,已缺失");
            return;
        }
        int    spell_id = Item.SpellID(Item_sid);
        string note     = "使用了" + Item.Name(Item_sid);

        MyCanvas.IssueDis(note);
        SpellSystem.SpellCast(spell_id, this.gameObject);
        if (Item.Type(Item_sid) == "prop" || Item.Type(Item_sid) == "staticequi" || Item.Type(Item_sid) == "Building")
        {
            if (Item.IsCanTwiceSpell(Item_sid))
            {
                mybag.Cast(Item_sid);
                Canvas_con();
            }
            else
            {
                if (Item.Type(Item_sid) == "staticequi")
                {
                    Equi(Item_sid);
                }
                else if (Item.Type(Item_sid) == "Building")
                {
                    GameObject temp = mybag.GoEntity(Item_sid);
                    Building(temp);
                }
                mybag.Sub(Item_sid);
                Canvas_con();
            }
        }
    }
Ejemplo n.º 12
0
        private void StartGame()
        {
            MyCanvas.Focus();
            int temp = 300;

            score    = 0;
            gameOver = false;
            Canvas.SetTop(flappyBird, 190);

            foreach (var x in MyCanvas.Children.OfType <Image>())
            {
                if ((string)x.Tag == "obs1")
                {
                    Canvas.SetLeft(x, 500);
                }
                if ((string)x.Tag == "obs2")
                {
                    Canvas.SetLeft(x, 800);
                }
                if ((string)x.Tag == "obs3")
                {
                    Canvas.SetLeft(x, 1100);
                }
                if ((string)x.Tag == "clouds")
                {
                    Canvas.SetLeft(x, 300 + temp);
                    temp = 800;
                }

                gameTimer.Start();
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            MyCanvas.Focus();

            this.Cursor = Cursors.None;

            backgroundImage.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/background.png"));
            MyCanvas.Background         = backgroundImage;

            scopeImage.Source           = new BitmapImage(new Uri("pack://application:,,,/images/sniper-aim.png"));
            scopeImage.IsHitTestVisible = false;

            ghostSprite.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/ghost.png"));

            DummyMoveTimer.Tick    += DummyMoveTick;
            DummyMoveTimer.Interval = TimeSpan.FromMilliseconds(rand.Next(800, 2000));
            DummyMoveTimer.Start();

            showGhostTimer.Tick    += GhostAnimation;
            showGhostTimer.Interval = TimeSpan.FromMilliseconds(20);
            showGhostTimer.Start();

            topLocation = new List <int> {
                270, 540, 23, 540, 270, 23
            };
            bottomLocation = new List <int> {
                128, 678, 420, 678, 128, 420
            };
        }
Ejemplo n.º 14
0
        private void GameSetUp()
        {
            //this function will run when the program loads
            MyCanvas.Focus(); //set my canvas as the main focus for the program

            gameTimer.Tick += GameLoop; //link the game loop event to the time tick
            gameTimer.Interval = TimeSpan.FromMilliseconds(20);
            gameTimer.Start();
            currentGhostStep = ghostMoveStep;

            ImageBrush pacmanImage = new ImageBrush();
            pacmanImage.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/pacman.jpg"));
            pacman.Fill = pacmanImage;

            ImageBrush redGhost = new ImageBrush();
            redGhost.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/red.jpg"));
            redGuy.Fill = redGhost;

            ImageBrush orangeGhost = new ImageBrush();
            orangeGhost.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/orange.jpg"));
            orangeGuy.Fill = orangeGhost;

            ImageBrush pinkGhost = new ImageBrush();
            pinkGhost.ImageSource = new BitmapImage(new Uri("pack://application:,,,/images/pink.jpg"));
            pinkGuy.Fill = pinkGhost;
        }
Ejemplo n.º 15
0
        private async void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
        {
            var height = ApplicationView.GetForCurrentView().VisibleBounds.Height;
            var width  = ApplicationView.GetForCurrentView().VisibleBounds.Width;

            if (UWPPlatformTool.IsMobile)
            {
                border.Width  = this.Width = width;
                border.Height = this.Height = height;
            }
            else
            {
                border.Width  = width;
                border.Height = height;

                this.Height = height * 0.8;
                this.Width  = this.Height * 1.6;
            }
            SetCanvas();
            MyCanvas.Invalidate();
            await Task.Delay(10);

            SetCanvas();
            MyCanvas.Invalidate();
        }
Ejemplo n.º 16
0
    //public static int c=2;

    public void SaveText()
    {
        str             = inputField.text;
        text.text       = str;
        inputField.text = "";
        MyCanvas.SetActive("word", true);
    }
Ejemplo n.º 17
0
        //マウスで線を引いていたのを止める
        private void EndDraw()
        {
            IsDrawing = false;
            MyCanvas.ReleaseMouseCapture();//Canvasからマウス開放
            if (TempPolyline == null)
            {
                return;
            }
            //polyline
            if (TempPolyline.Points.Count > 1)
            {
                //PolylinePathからベジェ曲線Pathを作成してリストに追加
                Visibility visibility = (bool)(CheckBoxVisible.IsChecked) ? Visibility.Visible : Visibility.Hidden;
                var        myBezier   = new MyBezier(TempPolyline.Points, SliderCurve.Value, (int)SliderInterval.Value,
                                                     (DistanceType)ComboBoxDistanceType.SelectedItem,
                                                     (RadianType)ComboBoxRadianType.SelectedItem,
                                                     visibility);
                MyListBezierPaths.Add(myBezier);
                MyCanvas.Children.Add(myBezier.BezierPath);
                MyCanvas.Children.Add(myBezier.VertexPath);
                MyCanvas.Children.Add(myBezier.DirectionLinePath);

                MyCanvas.Children.Remove(TempPolyline);
            }
            TempPolyline = null;
        }
Ejemplo n.º 18
0
 /// アップグレードボタンの表示・非表示を切り替え
 void SetActiveUpgrade(bool b)
 {
     // 各種ボタンの表示制御
     MyCanvas.SetActive("ButtonRange", b);
     MyCanvas.SetActive("ButtonFirerate", b);
     MyCanvas.SetActive("ButtonPower", b);
 }
Ejemplo n.º 19
0
        public MainWindow()
        {
            InitializeComponent();

            gameTimer.Interval = TimeSpan.FromMilliseconds(20);
            gameTimer.Tick    += GameLoop;
            gameTimer.Start();

            MyCanvas.Focus();

            ImageBrush bg = new ImageBrush();

            bg.ImageSource =
                new BitmapImage(
                    new Uri("pack://application:,,,/Images/purple.png"));
            bg.TileMode         = TileMode.Tile;
            bg.Viewport         = new Rect(0, 0, 0.15, 0.15);
            bg.ViewportUnits    = BrushMappingMode.RelativeToBoundingBox;
            MyCanvas.Background = bg;

            ImageBrush playerImage = new ImageBrush();

            playerImage.ImageSource =
                new BitmapImage(new Uri("pack://application:,,,/Images/player.png"));
            Player.Fill = playerImage;
        }
Ejemplo n.º 20
0
    /// ボタンをクリックした時の処理
    public void OnClick()
    {
        //Debug.Log("Button click!");

        //c = 1;

        // 非表示にする
        //gameObject.SetActive(false);

        // 自分自身を無効化する
        MyCanvas.SetInteractive("Button", false);

        //Cubeを非表示
        MyCanvas.SetActive("unitychan", false);
        MyCanvas.SetActive("robo", false);

        //taichiの表示
        MyCanvas.SetActive("taichi", true);



        // Button2を表示する
        //MyCanvas.SetActive("Button2", true);

        //Button2の有効化
        MyCanvas.SetInteractive("Button2", true);
        MyCanvas.SetInteractive("Button3", true);
    }
        /// <summary>
        /// Starts application
        /// </summary>
        private void StartGame()
        {
            MyCanvas.Focus();

            int temp = 300;

            score = 0;

            gameOver = false;

            Canvas.SetTop(flappyBird, 190);                       // default position once started

            foreach (var x in MyCanvas.Children.OfType <Image>()) // any item apart of the game will have a loop
            {
                if ((string)x.Tag == "obs1")                      // first pipe item obstacle
                {
                    Canvas.SetLeft(x, 500);
                }
                if ((string)x.Tag == "obs2") // second pipe obstacle
                {
                    Canvas.SetLeft(x, 800);
                }
                if ((string)x.Tag == "obs3") // third pipe obstacle
                {
                    Canvas.SetLeft(x, 1100);
                }
                if ((string)x.Tag == "cloud") // background cloud item
                {
                    Canvas.SetLeft(x, 300 + temp);
                    temp = 800;
                }
            }

            gameTimer.Start();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// This method starts the game and makes the canvas the focus of the program so it runs faster.
        /// It also resets the game after a game over.
        /// It also contains a for each loop that loops through all the images and then it specifice what we want to move and where to move it through tags.
        /// Starts the gametimer.
        /// </summary>
        private void StartGame()
        {
            MyCanvas.Focus();

            int temp = 300;

            score = 0;

            gameOver = false;
            Canvas.SetTop(flappyBird, 190);
            //Loops through if statements that contain iamges and checks the obstacale and clouds and moves them to their starter position.
            foreach (var x in MyCanvas.Children.OfType <Image>())
            {
                if ((string)x.Tag == "obs1")
                {
                    Canvas.SetLeft(x, 500);
                }
                if ((string)x.Tag == "obs2")
                {
                    Canvas.SetLeft(x, 800);
                }
                if ((string)x.Tag == "obs3")
                {
                    Canvas.SetLeft(x, 1100);
                }
                if ((string)x.Tag == "cloud")
                {
                    Canvas.SetLeft(x, 300 + temp);
                    temp = 800;
                }
            }

            gameTimer.Start();
        }
Ejemplo n.º 23
0
 private void DeliConf()
 {
     GameObject.Find("Delivery/ConfBtn").GetComponent <DeliNodeBtn>().ItemDelivery();
     MyCanvas.SetActive("MenuUI/DeliSuccess", true);
     GameObject.Find("DeliSuccess").GetComponent <MessageView>().ItemDelivery_Success();
     doAnimation.Open_DOScale(GameObject.Find("DeliSuccess/BG"));
 }
Ejemplo n.º 24
0
 //被拖动的控件
 private void MyCanvas_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed)
     {
         dragging   = true;                         //标记鼠标按下
         mousePoint = e.GetPosition(this.MyCanvas); //获取鼠标在但前canvas内的位置
         //if (e.Source.GetType().Name == "NodeBox")
         //{
         //    return;
         //}
         //mouseCtrl = (Control)e.Source;   //获得事件触发的源,即哪个控件
         //mouseCtrl = (Canvas)e.Source;   //获得事件触发的源,即哪个控件
         mouseCtrl = (Canvas)sender;
         VisualBrush v;
         v             = new VisualBrush(mouseCtrl);//利用VisualBrush得到控件的影像
         shadow.Width  = mouseCtrl.Width;
         shadow.Height = mouseCtrl.Height;
         shadow.Fill   = v;//将影像填充给矩形
         Canvas.SetLeft(shadow, Canvas.GetLeft(mouseCtrl));
         Canvas.SetTop(shadow, Canvas.GetTop(mouseCtrl));
         shadow.Visibility = Visibility.Visible; //使矩形可见
         //Canvas.SetZIndex(shadow, 0);//可以通过SetZIndex设置阴影的z方向位置
         MyCanvas.CaptureMouse();                //强制捕获鼠标。这在对于背景透明的窗体里面是必须的
     }
 }
Ejemplo n.º 25
0
 private void SaveConf()
 {
     //LoadData.DataSave();
     MyCanvas.SetActive("MenuUI/Success", true);
     GameObject.Find("Success").GetComponent <MessageView>().Save_Success();
     doAnimation.Open_DOScale(GameObject.Find("Success/BG"));
 }
Ejemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     menuButton    = GetComponent <Button>();
     visibleMenuUI = GameObject.Find("FieldUI").GetComponent <MyCanvas>();
     doAnimation   = GameObject.Find("DOAnimation").GetComponent <DOAnimation>();
     FadeInOut     = GameObject.Find("FadeInOut").GetComponent <FadeGenerator>();
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Calculate all image parameters on its passed dimensions
        /// </summary>
        /// <param name="w">Width of an image</param>
        /// <param name="h">Height of an image</param>
        /// <param name="_canvas">Canvas, that will be used for drawing image</param>
        public static void CalculateParameters(int w, int h, MyCanvas _canvas)
        {
            BmpWidth = w;
            BmpHeight = h;

            Aspect = (double)BmpWidth / BmpHeight;

            WidthBigger = false;
            if (_canvas.ActualWidth / _canvas.ActualHeight < Aspect)
                WidthBigger = true;

            var usedSize = 0d;
            if (WidthBigger)
            {
                usedSize = Math.Min(_canvas.ActualWidth, BmpWidth);
                _canvas.Img.Width = usedSize;
                _canvas.Img.Height = usedSize / Aspect;
                _canvas.ImgTop = _canvas.ActualHeight / 2d - _canvas.Img.Height / 2d;
                _canvas.ImgLeft = _canvas.ActualWidth / 2d - usedSize / 2d;
            }
            else
            {
                usedSize = Math.Min(_canvas.ActualHeight, BmpHeight);
                _canvas.Img.Height = usedSize;
                _canvas.Img.Width = usedSize * Aspect;
                _canvas.ImgTop = _canvas.ActualHeight / 2d - usedSize / 2d;
                _canvas.ImgLeft = _canvas.ActualWidth / 2d - _canvas.Img.Width / 2d;
            }
        }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            MyCanvas myCanvas = new MyCanvas();

            //created buttons
            MyCanvas.CreateNewButton(0, 0, 100, 100);
            MyCanvas.CreateNewButton(100, 100, 200, 200);
            MyCanvas.CreateNewButton(200, 200, 300, 300);


            //moved button
            MyCanvas.MoveButton(0, 250, 250, 300, 400);

            //print
            Console.WriteLine(myCanvas.ToString());


            //fetch data
            Console.WriteLine($"Current Number Of Buttons: {MyCanvas.GetCurrentNumberOfButtons()}");
            Console.WriteLine($"Max Number Of Buttons: {MyCanvas.GetMaxNumberOfButtons()}");
            Console.WriteLine($"Max Width Of A Button: {MyCanvas.GetTheMaxWidthOfAButton()}");
            Console.WriteLine($"Max Height Of A Button: {MyCanvas.GetTheMaxHeightOfAButton()}");

            //check if
            Console.WriteLine($"Is Point Inside A Button: {MyCanvas.IsPointInsideAButton(120,120)}");
            Console.WriteLine($"If any buttons is overlapping: {MyCanvas.CheckIfAnyButtonIsOverlapping()}");

            //delete last button
            MyCanvas.DeleteLastButton();
            Console.WriteLine(myCanvas.ToString());

            //clear all buttons
            MyCanvas.ClearAllButtons();
            Console.WriteLine(myCanvas.ToString());
        }
Ejemplo n.º 29
0
    /// <summary>
    /// Corotina responsável por apresentar um novo pedido, atualizando o tempo decorrido.
    /// </summary>
    /// <param name="pedido">Pedido que será mostrado</param>
    /// <returns></returns>
    public IEnumerator MostrarPedido(Pedido pedido)
    {
        //Instancia o prefab do objeto e o adiciona no PainelPedido para mostrar o pedido ao jogador.
        var prefPedido = Instantiate(Resources.Load <GameObject>("Prefabs/Pedido"), MyCanvas.PainelPedido);

        prefPedido.GetComponentsInChildren <Text>()[0].text = "Pedido\n" + pedido.objetoNecessario.nome;

        //Iteração que atualizará o tempo decorrido de acordo com a necessidade.
        for (int i = 0; i <= pedido.tempoDeEspera; i++)
        {
            if (pedidosAndamento.Contains(pedido) && FaseController.IsFaseRodando())
            {
                prefPedido.GetComponentsInChildren <Text>()[1].text = pedido.tempoDecorrido + "/" + pedido.tempoDeEspera;
                pedido.tempoDecorrido = i;
                yield return(new WaitForSeconds(1f));
            }
            else
            {
                break;
            }
        }

        if (FaseController.IsFaseRodando())
        {
            //Quando chega ao fim do tempo do tempo decorrido, remove o pedido da lista de pedidos em andamento e o apaga do PainelPedidos.
            pedidosAndamento.Remove(pedido);
            MyCanvas.ApagarFilhoPainelPedido(pedido.objetoNecessario.nome);
        }
    }
Ejemplo n.º 30
0
        private void StartGame() //Klass som håller koll på om spelet ska startas och hur.
        {
            MyCanvas.Focus();

            int temp = 300;

            score = 0; //Startar med score:0

            gameover = false;
            Canvas.SetTop(flappyBird, 190);                       //Startar med fågeln på en höjd av 190

            foreach (var x in MyCanvas.Children.OfType <Image>()) // En loop där alla eliment som är en bild går igenom
            {
                if ((string)x.Tag == "obs1")                      //Gör så att tuberna samt målnen rör sig in i bilden.
                {
                    Canvas.SetLeft(x, 500);
                }
                if ((string)x.Tag == "obs2")
                {
                    Canvas.SetLeft(x, 800);
                }
                if ((string)x.Tag == "obs3")
                {
                    Canvas.SetLeft(x, 1100);
                }

                if ((string)x.Tag == "cloud")
                {
                    Canvas.SetLeft(x, 300 + temp);
                    temp = 800;
                }
            }

            gameTimer.Start();
        }
Ejemplo n.º 31
0
 private void Start()
 {
     thisImage           = GetComponent <Image>();
     thisOutline         = GetComponent <Outline>();
     thisOutline.enabled = false;
     canvas = GetComponentInParent <MyCanvas>();
 }
Ejemplo n.º 32
0
    void Start()
    {
        Dispatcher.RoundStart();

        timeOnStartSession = Time.fixedTime;
        curWorldTime = 0;
        Behaviour = this;
        CameraCreator();
        ScoresFieldsCreator();
        var mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height));
        var buttonGO = new MyButton(() => Dispatcher.SetGameOver(), button, new Rect(100, -100, 100, 30), "Back to menu");
        buttonGO.SetAnchor(new Vector2(0,1), new Vector2(0, 1));
        mainCanvas.AddElement(buttonGO);
        world = Dispatcher.CurrentRunner.World;
        if (world != null)
            Debugger.Log(DebuggerMessageType.Unity, "World loaded");
        else
            Debugger.Log(DebuggerMessageType.Unity, "Fail. World not loaded");

        CollisionInfo = new Tuple<string, string, int>(null, null, 0);
        Time.timeScale = 1; // вот почему так?
        //в момент повторного запуска время уже не нулевое
    }
Ejemplo n.º 33
0
    void Start()
    {
        if (!serverIsRunned)
        {
            Server();
            serverIsRunned = true;
        }

        mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height));
        MakeState();
        windowTests = MakeTests();
        windowTests.SetActive(stateMenu.IsOpenTestsWindow);
        var buttonWindowTests = new MyButton(() => windowTests.SetActive(!windowTests.isOpen), ButtonSprite, new Rect(0, 0, 64, 48), "Tests");
        var rectB = buttonWindowTests.Element.GetComponent<RectTransform>();
        var inputField = new MyInputField("Input", ButtonSprite, new Rect(0, 0, 160, 25));
        buttonWindowTests.SetAnchor(new Vector2(0, 1), new Vector2(0, 1));

        var buttonLog = new MyButton(
            () => Dispatcher.AddRunner(new LogRunner(inputField.Element.GetComponent<InputField>().text)),
            ButtonSprite,
            new Rect(0, 0, 64, 48),
            "Log play");

        var rectLog = buttonLog.Element.GetComponent<RectTransform>();
        buttonLog.SetAnchor(0, 0, 0, 0);
        rectLog.anchoredPosition = new Vector2(300, 40);

        rectB.offsetMin = new Vector2(100, -200);
        UIElement.SetSize(rectB, new Vector2(120, 30));
        var buttonTutorial = new MyButton(
            () => Dispatcher.AddRunner(new TutorialRunner(new LoadingData { AssemblyName = "RoboMovies", Level = "Test" })),
            ButtonSprite,
            new Rect(0, 00, 120, 48),
            "Tutorial");
        buttonTutorial.SetAnchor(new Vector2(0, 1), new Vector2(0, 1));

        rectB = buttonTutorial.Element.GetComponent<RectTransform>();
        rectB.offsetMin = new Vector2(100, -300);
        UIElement.SetSize(rectB, new Vector2(120, 30));

        dropDownListAssembly = Instantiate(DropDownList);
        dropDownListAssembly.name = "BambaLeilo";
        dropDownListAssembly.transform.localPosition = new Vector3(0, 0);
        var dropDown = dropDownListAssembly.GetComponent<Dropdown>();
        dropDown.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
        dropDown.options = new List<Dropdown.OptionData>();
        foreach (var e in Dispatcher.Loader.Levels.Keys)
            dropDown.options.Add(new Dropdown.OptionData(e));

        for (var i = 0; i < dropDown.options.Count; i++)
            if (dropDown.options[i].text == stateMenu.CurrentAssembly)
                dropDown.value = i;

        dropDownListLevel = Instantiate(DropDownList);
        dropDownListLevel.name = "BambaLeiloLevel";
        dropDownListLevel.transform.localPosition = new Vector3(0, 0);
        var dropDownList = dropDownListLevel.GetComponent<Dropdown>();
        dropDownList.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
        dropDownList.options = new List<Dropdown.OptionData>();
        foreach (var e in Dispatcher.Loader.Levels[stateMenu.CurrentAssembly].Keys)
            dropDownList.options.Add(new Dropdown.OptionData(e));

        for (var i = 0; i < dropDownList.options.Count; i++)
            if (dropDownList.options[i].text == stateMenu.CurrentLevel)
            {
                dropDownList.value = i;
                dropDownList.options[i] = new Dropdown.OptionData(stateMenu.CurrentLevel);
            }

        var backGround = new MyImage(menuBackground, new Rect(0, 0, menuBackground.textureRect.width, menuBackground.textureRect.height));

        mainCanvas.AddElement(backGround);
        mainCanvas.AddElement(inputField);
        mainCanvas.AddElement(windowTests.Head);
        mainCanvas.AddElement(buttonWindowTests);
        mainCanvas.AddElement(buttonTutorial);
        mainCanvas.AddElement(buttonLog);
        dropDownListLevel.transform.SetParent(mainCanvas.Element.transform);
        dropDown.transform.SetParent(mainCanvas.Element.transform);

        var rectDrop = dropDownListAssembly.GetComponent<RectTransform>();
        rectDrop.anchorMin = new Vector2(0, 1);
        rectDrop.anchorMax = new Vector2(0, 1);
        rectDrop.anchoredPosition = new Vector3(100, -40, 0);

        rectDrop = dropDownListLevel.GetComponent<RectTransform>();
        rectDrop.anchorMin = new Vector2(0, 1);
        rectDrop.anchorMax = new Vector2(0, 1);
        rectDrop.anchoredPosition = new Vector3(300, -40, 0);

        rectDrop = inputField.Element.GetComponent<RectTransform>();
        inputField.SetAnchor(0, 0, 0, 0);
        rectDrop.anchoredPosition = new Vector3(100, 40, 0);
    }
Ejemplo n.º 34
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="canvas">Parent canvas object</param>
 public MultiPagedImage(MyCanvas canvas)
     : base(canvas)
 {
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="canvas">Parent canvas object</param>
 public Ico(MyCanvas canvas)
     : base(canvas)
 {
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="canvas">Parent canvas object</param>
 public Gif(MyCanvas canvas)
     : base(canvas)
 {
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="canvas">Parent canvas object</param>
 public ImageReader(MyCanvas canvas)
 {
     _canvas = canvas;
 }
Ejemplo n.º 38
0
            /// <summary>
            /// The default constructor.
            /// </summary>
            public MyWindow()
            {
                // Create the canvas to draw on.
                int screenWidth;
                int screenHeight;
                int bitsPerPixel;
                int orientation;
                HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, 
                    out screenHeight, out bitsPerPixel, out orientation);

                inkCanvas = new MyCanvas(screenWidth - 60, screenHeight - 30);

                // Create the Clear button.
                button = new Button("Clear", 
                    Resources.GetFont(Resources.FontResources.small));
                button.Click += new EventHandler(button_Click);

                // Create the palette for selecting colors.
                colorPalette = new MyColorPalette(8, 2, 54, 204);
                colorPalette.HorizontalAlignment = HorizontalAlignment.Right;
                colorPalette.VerticalAlignment = VerticalAlignment.Top;

                colorPalette.ItemClick += 
                    new PaletteControlEventHandler(colorPalette_ItemClick);

                // Add a panel to hold the other controls.
                this.Child = panel;

                // Add the canvas, clear button and palette to the panel.
                panel.Children.Add(inkCanvas);
                panel.Children.Add(button);
                panel.Children.Add(colorPalette);

                // Set the drawing attributes to a default set.
                DrawingAttributes da = new DrawingAttributes();
                inkCanvas.DefaultDrawingAttributes = da;
            }
Ejemplo n.º 39
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="canvas">Parent canvas object</param>
 public Svg(MyCanvas canvas)
     : base(canvas)
 {
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="canvas">Parent canvas object</param>
 public Eps(MyCanvas canvas)
     : base(canvas)
 {
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="canvas">Parent canvas object</param>
 public Pdf(MyCanvas canvas)
     : base(canvas)
 {
 }