Beispiel #1
0
        /// <summary>
        /// Implementacija minimax algoritma. Odredjivanje najboljeg poteza Determines the best move for the current
        /// board by igrajuci svaku mogucu kombijaciju pomeranja dok se igra ne zavrsi.
        /// </summary>
        public static State GetBestMove(DisplayPanel displayPanel, Hero hero)
        {
            State bestState = null;
            //prebaci sva mogica polja heroja u listu
            List <State> openSpaces = displayPanel.pocetnoStanje.mogucaSledecaStanja(hero);

            //prolazi kroz listu praznih polja
            for (int i = 0; i < openSpaces.Count; i++)
            {
                //uzme trenutnu poziciju(stanje)
                State newSpace = openSpaces[i];
                /*skontati sta ovde....*/
                if (displayPanel.Winner() == Pobednik.Niko /*&& newBoard.OpenSquares.Count > 0*/)
                {
                    State tempMove = GetBestMove(newBoard, ((Hero)(-(int)p)));  //a little hacky, inverts the current player
                    newSpace.Rank = tempMove.Rank;
                }
                else
                {
                    if (displayPanel.Winner() == Pobednik.Niko)
                    {
                        displayPanel.Rank = 0;
                    }
                    else if (displayPanel.Winner() == Pobednik.Covek)
                    {
                        displayPanel.Rank = -1;
                    }
                    else if (displayPanel.Winner() == Pobednik.Masina)
                    {
                        displayPanel.Rank = 1;
                    }
                }

                //Ako je novo stanje bolje od prethodnog, uzmi ga

                /*if (bestState == null ||
                 * (p == Osvajac.Covek && newSpace.Rank < bestState.Rank) ||
                 * (p == Osvajac.Masina && newSpace.Rank > ((Space)bestSpace).Rank))
                 * {
                 *  bestState = newSpace;
                 * }*/
            }

            return(bestState);
        }
Beispiel #2
0
        private void Paint()
        {
            SaveLoad      saveLoad      = new SaveLoad();
            List <string> getFarmInfo   = saveLoad.LoadThis(farmWorkingWith.FarmName, farmerWorkingWith);
            Calculations  algorithm     = new Calculations();
            List <string> theCoOrdinate = algorithm.createTheFarm(getFarmInfo);
            //algorithm.HandleNewAnimals(getFarmInfo);

            int startX;
            int startY;
            int cageSize;
            int angle = 0;

            myPen.Width = 1;
            g           = DisplayPanel.CreateGraphics();

            foreach (string item in theCoOrdinate)
            {
                string[] lines = item.Split(',');
                startX   = int.Parse(lines[1]);
                startY   = int.Parse(lines[2]);
                cageSize = int.Parse(lines[3]);
                if (lines[4] == "Prey")
                {
                    myPen.Color = Color.Blue;
                }
                if (lines[4] == "Predator")
                {
                    myPen.Color = Color.Red;
                }
                if (lines[4] == "Other")
                {
                    myPen.Color = Color.Green;
                }

                DrawLine(startX, startY, cageSize, angle);
            }


            //DrawLine(950, 950, 50, angle);
        }
        private static void Child_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            DisplayPanel displayPanel = (DisplayPanel)sender;

            //if (e.Button == MouseButtons.Left && (e.X != (int)Application.Current.Properties[displayPanel.Name + "_mouse_x"] || e.Y != (int)Application.Current.Properties[displayPanel.Name + "_mouse_y"]))
            if (e.Button == MouseButtons.Left && (e.X != Store.Data.Webcam.WindowMouseX || e.Y != Store.Data.Webcam.WindowMouseY))
            {
                //Window window = (Window)Application.Current.Properties["window_" + displayPanel.Name];
                //IntPtr windowHandle = (IntPtr)Application.Current.Properties["windowHandle_" + displayPanel.Name];

                Window window       = Store.Data.Webcam.Window;
                IntPtr windowHandle = Store.Data.Webcam.WindowHandle;

                if (e.Button == MouseButtons.Left)
                {
                    window.ResizeMode = ResizeMode.NoResize;
                    ReleaseCapture();
                    SendMessage(windowHandle, (int)Constants.WindowMessage.WM_NCLBUTTONDOWN, (int)Constants.WindowMessage.HTCAPTION, 0);
                }
            }
        }
    public void Initialize(List <string> spells, Hero user)
    {
        this.user    = user;
        newSpellBtns = new Dictionary <string, GameObject>();
        foreach (string spell in spells)
        {
            GameObject  splBtnGo = GameObjectUtility.CustomInstantiate(spellButton.gameObject, transform);
            SpellButton splBtn   = splBtnGo.GetComponent <SpellButton>();
            splBtn.Initialize(spell, this);
        }

        displayPanelGameObject = GameObject.Find("DisplayPanel");
        displayPanel           = displayPanelGameObject.GetComponent <DisplayPanel>();

        GameObject BackBtnGO = GameObjectUtility.CustomInstantiate(BackSpaceBtn.gameObject, transform);

        BackBtnGO.GetComponent <Button>().onClick.RemoveAllListeners();
        BackBtnGO.GetComponent <Button>().onClick.AddListener(() => { BackSpace(); });
        GameObject ClearBtnGO = GameObjectUtility.CustomInstantiate(ClearAllBtn.gameObject, transform);

        ClearBtnGO.GetComponent <Button>().onClick.RemoveAllListeners();
        ClearBtnGO.GetComponent <Button>().onClick.AddListener(() => { ClearAll(); });
    }
Beispiel #5
0
    void Start()
    {
        // Load the timer
        displayPanel   = GetComponent <DisplayPanel>();
        _instanceTimer = displayPanel.instantiatePanel(timer);
        _counter       = _instanceTimer.GetComponent <Counter>();
        lastStep       = new Step();

        _currentStep   = 0;
        _counterHints  = 0;
        _gameCompleted = false;

        _instanceButtonPanel = displayPanel.instantiatePanel(buttonPanel);
        _instanceRecipePanel = displayPanel.instantiatePanel(recipePanel);

        UpdateHintsCounter(MAX_HINTS);

        _instanceRecipePanel.SetActive(true);
        _instanceButtonPanel.SetActive(false);
        enableClickOnObjects(false);

        // Tracker: recogemos el nombre del nivel
        this.level = SceneManager.GetActiveScene().name;

        /*string var = "";
         *
         * for (int i = 0; i < this.steps.Count; i++)
         * {
         *  var += i + ":" + steps[i].drag.name + "-" + steps[i].drop.name + "-" + steps[i].action;
         * }
         *
         * Tracker.T.setVar("Pasos", var);*/

        Tracker.T.setVar("Tiempo", MAXTIME);
        Tracker.T.setVar("NumPasos", steps.Count);
        Tracker.T.Completable.Initialized(this.level);
    }
Beispiel #6
0
        private void initStuff()
        {
            //load data from files
            TextureManager.initAll();
            CharacterInfo.allInfos = FileLineLoader.LoadCharInfos();
            Equip.allWeapons       = FileLineLoader.LoadWeapons();
            Equip.allArmors        = FileLineLoader.LoadArmors();
            Magic.Init();

            //character selection
            control.bind(charSel);
            charSel.control = control;
            charSel.bindHadlers();

            //shop
            Shop.shop.selection = charSel;
            control.bind(Shop.shop);

            //equip selection
            control.bind(equipSel);
            equipSel.control = control;
            equipSel.init();

            //bind character and equip
            charSel.characterChangedEvent += new CharacterSelection.CharacterChanged(equipSel.setCharacter);

            //play button
            control.getPlayButton().Click += new EventHandler(playPressed);

            //monster infos
            MonsterInfo.allMonsterInfos = FileLineLoader.LoadMonstersInfos();

            //drawing panels
            DisplayPanel.Init();
            RowPanel.Init();
        }
Beispiel #7
0
        public BindingListDisplay(BindingList <TType> contents, Func <TType, Control> funcCreateControl, bool blnLoadVisibleOnly = true)
        {
            InitializeComponent();
            Contents            = contents ?? throw new ArgumentNullException(nameof(contents));
            _funcCreateControl  = funcCreateControl;
            _blnLoadVisibleOnly = blnLoadVisibleOnly;
            DisplayPanel.SuspendLayout();
            try
            {
                int intMaxControlHeight = 0;
                foreach (TType objLoopTType in Contents)
                {
                    ControlWithMetaData objNewControl = new ControlWithMetaData(objLoopTType, this, false);
                    intMaxControlHeight = Math.Max(objNewControl.Control.PreferredSize.Height, intMaxControlHeight);
                    _lstContentList.Add(objNewControl);
                }

                if (intMaxControlHeight > 0)
                {
                    ListItemControlHeight = intMaxControlHeight;
                }

                DisplayPanel.Controls.AddRange(_lstContentList.Select(x => x.Control).ToArray());
                _indexComparer        = new IndexComparer(Contents);
                _comparison           = _comparison ?? _indexComparer;
                Contents.ListChanged += ContentsChanged;
                ComputeDisplayIndex();
                LoadScreenContent();
                BindingListDisplay_SizeChanged(null, null);
            }
            finally
            {
                _blnIsTopmostSuspendLayout = true;
                DisplayPanel.ResumeLayout();
            }
        }
Beispiel #8
0
        public AlternatePongExperiment()
        {
            InitializeComponent();


            sensors = new DistanceSensors();
            sensors.DistancesChanged += new DistanceSensors.DistancesChangedHandler(sensors_DistancesChanged);
            sensors.Connect();

            sound1 = new SoundPlayer("sounds/pong.wav"); sound1.Load();
            sound2 = new SoundPlayer("sounds/pong2.wav"); sound2.Load();
            sound3 = new SoundPlayer("sounds/pong3.wav"); sound3.Load();

            paddle1   = 0.5f; paddle2 = 0.5f;
            ball      = new PointF(DisplayPanel.Width / 2, DisplayPanel.Height / 2);
            rand      = new Random();
            ballSpeed = new PointF((rand.NextDouble() <= 0.5 ? -1 : 1) * BALL_SPEED_FACTOR, (float)(rand.NextDouble() * 2 * BALL_SPEED_FACTOR) - BALL_SPEED_FACTOR);

            Task.Factory.StartNew(() =>
            {
                DateTime startTime = DateTime.Now;
                ballStartTimer     = BALL_START_TIMER;
                while (!IsDisposed)
                {
                    try
                    {
                        DateTime currTime = DateTime.Now;
                        UpdatePositions((float)(currTime - startTime).TotalSeconds);
                        Invoke(new MethodInvoker(delegate { DisplayPanel.Refresh(); }));
                        startTime = currTime;
                        Thread.Sleep(20);
                    }
                    catch { }
                }
            });
        }
Beispiel #9
0
 private void MainForm_Resize(object sender, EventArgs e)
 {
     DisplayPanel.Invalidate();
 }
Beispiel #10
0
 public static void Release()
 {
     Tool.NetworkDetectiveTool.Remove();
     GoToPanel.Release();
     DisplayPanel.Release();
 }
Beispiel #11
0
 void Start()
 {
     displayPanel = GetComponent <DisplayPanel>();
     lastStep     = new Step();
     currentStep  = 0;
 }
Beispiel #12
0
 private void frm_Load(object sender, EventArgs e)
 {
     DisplayPanel.Refresh();
     Paint();
 }