示例#1
0
 public Figurine(Figurine copy)
 {
     Dark   = copy.Dark;
     Big    = copy.Big;
     Square = copy.Square;
     Point  = copy.Point;
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nom,prix_ttc,quantite_magasin,quantite_stock,date_parution,nb_exemplaires,poids,largeur,hauteur,longueur,reference,description,MarqueId,CategorieId")] Figurine figurine)
        {
            if (id != figurine.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(figurine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FigurineExists(figurine.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(figurine));
        }
示例#3
0
 private void Displacement(Cell selected, IReadOnlyDictionary <Vector2, Cell> cells)
 {
     Cell[] emptyCells = SearchEmptyCell(selected, cells).ToArray();
     if (emptyCells.Length > 0)
     {
         //Debug.LogWarning("MOVE:" + selected.Index);
         Cell     newLocation = emptyCells[Random.Range(0, emptyCells.Length)];
         Figurine figurine    = selected.Selected;
         figurine.StartCoroutine(AnimDisplacement(oldLocation: selected, newLocation: cells[newLocation.Index]));
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            var LegoGuy1 = new Figurine
            {
                Topper      = "Red Cap",
                Head        = "Angry Eyes",
                Toroso      = "Adventurer",
                Legs        = "Brown",
                Accessories = "Pickaxe"
            };

            LegoGuy1.Display();

            while (true)
            {
                var userInput = Console.ReadLine();
                if (userInput == "w")
                {
                    LegoGuy1.MoveForward();
                }
                else if (userInput == "s")
                {
                    LegoGuy1.MoveBackward();
                }
                else if (userInput == "a")
                {
                    LegoGuy1.MoveLeft();
                }
                else if (userInput == "d")
                {
                    LegoGuy1.MoveRight();
                }
                else if (userInput == "q")
                {
                    LegoGuy1.Attack();
                }
                else if (userInput == "qq")
                {
                    LegoGuy1.SpecialAttack();
                }
                else if (userInput == " ")
                {
                    LegoGuy1.Jump();
                }
                else if (userInput == "  ")
                {
                    LegoGuy1.DoubleJump();
                }
                else if (userInput == "secret")
                {
                    LegoGuy1.Unlocks();
                }
            }
        }
示例#5
0
    protected void SetFigurine(Cell oldLocation, Cell newLocation, bool setPosition = true)
    {
        Figurine figurine = oldLocation.Selected;

        oldLocation.Selected = null;
        newLocation.Selected = figurine;

        if (setPosition)
        {
            figurine.transform.localPosition = Vector2.zero;
        }
    }
示例#6
0
    private IEnumerator AnimDisplacement(Cell oldLocation, Cell newLocation)
    {
        Figurine figurine = oldLocation.Selected;

        this.SetFigurine(oldLocation: oldLocation, newLocation: newLocation, false);

        while (Vector2.Distance(Vector2.zero, figurine.transform.localPosition) > 0f)
        {
            figurine.transform.localPosition = Vector2.Lerp(Vector2.zero, figurine.transform.localPosition, 0.5f);
            yield return(new WaitForFixedUpdate());
        }
        figurine.transform.localPosition = Vector2.zero;
    }
示例#7
0
 private void Create(ObjectForPlacementData data)
 {
     if (data is FigurineData)
     {
         Figurine figurine = Figurine.Create(prefabFigurine, content, data as FigurineData) as Figurine;
         CreateFigurine?.Invoke(figurine);
     }
     else if (data is SubjectData)
     {
         Subject subject = Subject.Create(prefabSubject, content, data as SubjectData) as Subject;
         CreateSubject?.Invoke(subject);
     }
 }
示例#8
0
    public override bool Use(Cell selected, GameManager gameManager)
    {
        Cell                 cell        = selected;
        Figurine             oldFigurine = cell.Selected;
        IReadOnlyList <Cell> cells       = SearchFigurines(selected, gameManager.Cells);

        if (cells.Count > 0)
        {
            cells = cells.Where(x => (x.Selected.Data != selected.Selected)).ToList();
            if (cells.Count > 0)
            {
                FigurineData[] datas = cells.OrderBy(x => - x.Selected.Data.Significance).Select(x => x.Selected.Data).ToArray();
                for (int indexData = 0; indexData < datas.Length; indexData++)
                {
                    FigurineData data = datas[indexData];
                    for (int indexInteraction = 0; indexInteraction < conditionForExecutions.Length; indexInteraction++)
                    {
                        FigurineInteractions conditionForExecution = conditionForExecutions[indexInteraction];
                        if (data.Interactions.Contains(conditionForExecution) == true)
                        {
                            Figurine figurine = Figurine.Create(prefab, cell.GetComponent <RectTransform>(), data) as Figurine;
                            cell.Selected = figurine;
                            if (conditionForExecution.CheckingUse(selected, gameManager) == true)
                            {
                                figurine.GetComponent <ControlDrag>().Interaction = false;
                                for (int index = 0; index < data.Interactions.Length; index++)
                                {
                                    FigurineInteractions interaction = data.Interactions[index];
                                    if (interaction.ActivateOnDrop == true)
                                    {
                                        interaction.Use(selected, gameManager);
                                    }
                                }
                                oldFigurine.Destroy();
                                return(true);
                            }
                            else
                            {
                                Destroy(figurine.gameObject);
                                cell.Selected = oldFigurine;
                            }
                        }
                    }
                }
            }
        }
        notCompleted.Use(selected, gameManager);
        return(true);
    }
        public async Task <IActionResult> Create([Bind("Id,Nom,prix_ttc,quantite_magasin,quantite_stock,date_parution,nb_exemplaires,poids,largeur,hauteur,longueur,reference,description,MarqueId,CategorieId")] Figurine figurine, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                var uniqueFileName = GetUniqueFileName(file.FileName);
                var uploads        = Path.Combine(hostingEnvironment.WebRootPath, "uploads");
                var filePath       = Path.Combine(uploads, uniqueFileName);
                file.CopyTo(new FileStream(filePath, FileMode.Create));

                figurine.image = uniqueFileName;

                _context.Add(figurine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(figurine));
        }
示例#10
0
 /// <summary>
 /// Обновить ячейку (Обновляеться на дочерний объект child)
 /// </summary>
 /// <param name="selected">Ячейка где находиться фигурка</param>
 /// <param name="gameManager"></param>
 /// <param name="prefab"></param>
 protected void UpgradeFigurine(Cell selected, GameManager gameManager, Figurine prefab)
 {
     if (selected.Selected.Data.Child != null)
     {
         Cell     cell     = selected;
         Figurine figurine = Figurine.Create(prefab, cell.GetComponent <RectTransform>(), selected.Selected.Data.Child) as Figurine;
         cell.Selected = figurine;
         figurine.GetComponent <ControlDrag>().Interaction = false;
         for (int index = 0; index < figurine.Data.Interactions.Length; index++)
         {
             FigurineInteractions interaction = figurine.Data.Interactions[index];
             if (interaction.ActivateOnDrop == true)
             {
                 interaction.Use(selected, gameManager);
             }
         }
     }
 }
示例#11
0
 private void Form1_Load(object sender, EventArgs e)
 {
     board   = new Figurine[4, 4];
     storage = new Figurine[4, 4];
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             storage[i, j]             = new Figurine(i < 2, j % 2 == 0, j < 2, i % 2 == 1);
             borderBox[i, j].BackColor = Color.White;
             pictureBox[i, j].Enabled  = false;
         }
     }
     Paint_Board();
     pictureBox1.Enabled = false;
     Paint_Storage();
     button2.Enabled = false;
 }
示例#12
0
    /// <param name="parent">Default use own parent</param>
    public void Create(ObjectForPlacementData data, RectTransform parent = null)
    {
        if (parent == null)
        {
            parent = content;
        }

        if (data is FigurineData)
        {
            Figurine figurine = Figurine.Create(prefabFigurine, parent, data as FigurineData) as Figurine;
            figurine.name = indefecator;
            CreateFigurine?.Invoke(figurine);
        }
        else if (data is SubjectData)
        {
            Subject subject = Subject.Create(prefabSubject, parent, data as SubjectData) as Subject;
            subject.name = indefecator;
            CreateSubject?.Invoke(subject);
        }
    }
示例#13
0
    public override bool Use(Cell selected, GameManager gameManager)
    {
        Figurine     figurine = selected.Selected;
        FigurineData data     = figurine.Data;

        data.AdditionalCurrencies.ToList().ForEach(
            x =>
        {
            for (int index = 0; index < currencies.Length; index++)
            {
                CurrencySubtype currency = currencies[index];
                if (currency.Subtype == x.Data)
                {
                    GameManager.Player.Currencies[currency.Selected].Amount += x.Amount;
                    break;
                }
            }
        });

        return(true);
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            //check for each item available and add.
            //itemtype references the item array found under the inventoryScript
            //gameobject.
            //check if full so we can add the items
            if (InventoryScript.MyInstance.MyEmptySlotCount > 0)
            {
                if (itemType == "Leaflet")
                {
                    Leaflet leaflet = (Leaflet)Instantiate(InventoryScript.MyInstance.items[1]);
                    InventoryScript.MyInstance.AddItem(leaflet);
                }
                else if (itemType == "Egg")
                {
                    Egg egg = (Egg)Instantiate(InventoryScript.MyInstance.items[2]);
                    InventoryScript.MyInstance.AddItem(egg);
                }
                else if (itemType == "Sword")
                {
                    Sword sword = (Sword)Instantiate(InventoryScript.MyInstance.items[3]);
                    InventoryScript.MyInstance.AddItem(sword);
                }
                else if (itemType == "Trident")
                {
                    Trident trident = (Trident)Instantiate(InventoryScript.MyInstance.items[4]);
                    InventoryScript.MyInstance.AddItem(trident);
                }
                else if (itemType == "Airpump")
                {
                    AirPump ap = (AirPump)Instantiate(InventoryScript.MyInstance.items[5]);
                    InventoryScript.MyInstance.AddItem(ap);
                }
                else if (itemType == "Bar")
                {
                    PlatinumBar bar = (PlatinumBar)Instantiate(InventoryScript.MyInstance.items[6]);
                    InventoryScript.MyInstance.AddItem(bar);
                }
                else if (itemType == "Knife")
                {
                    Knife knife = (Knife)Instantiate(InventoryScript.MyInstance.items[7]);
                    InventoryScript.MyInstance.AddItem(knife);
                }
                else if (itemType == "Rope")
                {
                    Rope rope = (Rope)Instantiate(InventoryScript.MyInstance.items[8]);
                    InventoryScript.MyInstance.AddItem(rope);
                }
                else if (itemType == "Skull")
                {
                    Skull skull = (Skull)Instantiate(InventoryScript.MyInstance.items[9]);
                    InventoryScript.MyInstance.AddItem(skull);
                }
                else if (itemType == "Sack")
                {
                    Sack sack = (Sack)Instantiate(InventoryScript.MyInstance.items[10]);
                    InventoryScript.MyInstance.AddItem(sack);
                }
                else if (itemType == "Lantern")
                {
                    Lantern lantern = (Lantern)Instantiate(InventoryScript.MyInstance.items[11]);
                    InventoryScript.MyInstance.AddItem(lantern);
                }
                else if (itemType == "Bottle")
                {
                    Bottle bottle = (Bottle)Instantiate(InventoryScript.MyInstance.items[12]);
                    InventoryScript.MyInstance.AddItem(bottle);
                }
                else if (itemType == "Candle")
                {
                    Candle candle = (Candle)Instantiate(InventoryScript.MyInstance.items[13]);
                    InventoryScript.MyInstance.AddItem(candle);
                }
                else if (itemType == "BlackBook")
                {
                    BlkBook book = (BlkBook)Instantiate(InventoryScript.MyInstance.items[14]);
                    InventoryScript.MyInstance.AddItem(book);
                }
                else if (itemType == "PlasticPile")
                {
                    PlasticPile plastic = (PlasticPile)Instantiate(InventoryScript.MyInstance.items[15]);
                    InventoryScript.MyInstance.AddItem(plastic);
                }
                else if (itemType == "Buoy")
                {
                    Buoy buoy = (Buoy)Instantiate(InventoryScript.MyInstance.items[16]);
                    InventoryScript.MyInstance.AddItem(buoy);
                }
                else if (itemType == "Shovel")
                {
                    Shovel shovel = (Shovel)Instantiate(InventoryScript.MyInstance.items[17]);
                    InventoryScript.MyInstance.AddItem(shovel);
                }
                else if (itemType == "Scarab")
                {
                    Scarab scarab = (Scarab)Instantiate(InventoryScript.MyInstance.items[18]);
                    InventoryScript.MyInstance.AddItem(scarab);
                }
                else if (itemType == "PotOfGold")
                {
                    PotOfGold gold = (PotOfGold)Instantiate(InventoryScript.MyInstance.items[19]);
                    InventoryScript.MyInstance.AddItem(gold);
                }
                else if (itemType == "Bracelet")
                {
                    Bracelet bracelet = (Bracelet)Instantiate(InventoryScript.MyInstance.items[20]);
                    InventoryScript.MyInstance.AddItem(bracelet);
                }
                else if (itemType == "Coal")
                {
                    Coal coal = (Coal)Instantiate(InventoryScript.MyInstance.items[21]);
                    InventoryScript.MyInstance.AddItem(coal);
                }
                else if (itemType == "Figurine")
                {
                    Figurine fig = (Figurine)Instantiate(InventoryScript.MyInstance.items[22]);
                    InventoryScript.MyInstance.AddItem(fig);
                }
                else if (itemType == "Diamond")
                {
                    Diamond diamond = (Diamond)Instantiate(InventoryScript.MyInstance.items[23]);
                    InventoryScript.MyInstance.AddItem(diamond);
                }
                else if (itemType == "Torch")
                {
                    Torch torch = (Torch)Instantiate(InventoryScript.MyInstance.items[24]);
                    InventoryScript.MyInstance.AddItem(torch);
                }
                else if (itemType == "Coins")
                {
                    Coins coins = (Coins)Instantiate(InventoryScript.MyInstance.items[25]);
                    InventoryScript.MyInstance.AddItem(coins);
                }
                else if (itemType == "Key")
                {
                    Key key = (Key)Instantiate(InventoryScript.MyInstance.items[26]);
                    InventoryScript.MyInstance.AddItem(key);
                }
                else if (itemType == "Matches")
                {
                    Matches matches = (Matches)Instantiate(InventoryScript.MyInstance.items[27]);
                    InventoryScript.MyInstance.AddItem(matches);
                }
                else if (itemType == "Wrench")
                {
                    Wrench wrench = (Wrench)Instantiate(InventoryScript.MyInstance.items[28]);
                    InventoryScript.MyInstance.AddItem(wrench);
                }
                else if (itemType == "Screwdriver")
                {
                    Screwdriver sd = (Screwdriver)Instantiate(InventoryScript.MyInstance.items[29]);
                    InventoryScript.MyInstance.AddItem(sd);
                }
                else if (itemType == "Jewels")
                {
                    Jewels jewels = (Jewels)Instantiate(InventoryScript.MyInstance.items[30]);
                    InventoryScript.MyInstance.AddItem(jewels);
                }
                else if (itemType == "Coffin")
                {
                    Coffin coffin = (Coffin)Instantiate(InventoryScript.MyInstance.items[31]);
                    InventoryScript.MyInstance.AddItem(coffin);
                }
                else if (itemType == "Chalice")
                {
                    Chalice chalice = (Chalice)Instantiate(InventoryScript.MyInstance.items[32]);
                    InventoryScript.MyInstance.AddItem(chalice);
                }
                //the following items should not be displayed in the world
                //but going to add just in case we revamp how these items
                //are obtained.
                else if(itemType == "Garlic")
                {
                    Garlic garlic = (Garlic)Instantiate(InventoryScript.MyInstance.items[33]);
                    InventoryScript.MyInstance.AddItem(garlic);
                }
                else if(itemType == "Sceptre")
                {
                    Sceptre sep = (Sceptre)Instantiate(InventoryScript.MyInstance.items[34]);
                    InventoryScript.MyInstance.AddItem(sep);
                }






                
                Destroy(gameObject);
            }
            //probably want to utilize CLI popup here
            else
            {
                Debug.Log("Bag full");
            }
        }
        
    }
示例#15
0
    private void InteractionsFigure(Cell selected)
    {
        Dictionary <Figurine, Cell> figurineAndLocation = new Dictionary <Figurine, Cell>();

        foreach (KeyValuePair <Vector2, Cell> location in this.cells)
        {
            if (location.Value.Selected != null)
            {
                figurineAndLocation.Add(location.Value.Selected, location.Value);
            }
        }
        if (figurineAndLocation.Count > 0)
        {
            List <Figurine> figurines = figurineAndLocation.Keys.ToList();
            for (int index = 0; index < figurines.Count; index++)
            {
                int numberRandom = Random.Range(0, figurines.Count);

                Figurine temp = figurines[numberRandom];
                figurines[numberRandom] = figurines[index];
                figurines[index]        = temp;
            }

            if (selected.Selected != null)
            {
                int indexSelected = figurines.IndexOf(selected.Selected);

                Figurine temp = figurines[0];
                figurines[0]             = selected.Selected;
                figurines[indexSelected] = temp;
            }

            List <Figurine> blackList = new List <Figurine>();
            Dictionary <FigurineInteractions, List <Figurine> > repeatedly = new Dictionary <FigurineInteractions, List <Figurine> >();
            for (int index = 0; index < figurines.Count; index++)
            {
                Figurine figurine = figurines[index];
                if (figurine != null && blackList.Contains(figurine) == false && figurine.Interaction == true)
                {
                    blackList.Add(figurine);
                    FigurineData data = figurine.Data;
                    for (int indexInteraction = 0; indexInteraction < data.Interactions.Length; indexInteraction++)
                    {
                        FigurineInteractions figurineInteraction = data.Interactions[indexInteraction];

                        if (figurine == selected.Selected && figurineInteraction.ActivateOnDrop != true)
                        {
                            figurine.InteractionsColmlited.Add(figurineInteraction);
                            continue;
                        }
                        if (figurineInteraction.Use(figurineAndLocation[figurine], this) == false)
                        {
                            if (repeatedly.ContainsKey(figurineInteraction) == false)
                            {
                                repeatedly.Add(figurineInteraction, new List <Figurine>());
                            }
                            repeatedly[figurineInteraction].Add(figurine);
                        }
                        else
                        {
                            figurine.InteractionsColmlited.Add(figurineInteraction);
                        }
                    }
                }
            }
            //foreach (KeyValuePair<Vector2, Cell> location in this.cells)
            //{
            //    Figurine figurine = location.Value.Selected;
            //    if (figurine != null && blackList.Contains(figurine) == false)
            //    {
            //        blackList.Add(figurine);
            //        FigurineData data = figurine.Data;
            //        for (int index = 0; index < data.Interactions.Length; index++)
            //        {
            //            FigurineInteractions figurineInteraction = data.Interactions[index];
            //            if (figurineInteraction.Use(location.Value, this.cells) == false)
            //            {
            //                if (repeatedly.ContainsKey(figurineInteraction) == false)
            //                {
            //                    repeatedly.Add(figurineInteraction, new List<Cell>());
            //                }
            //                repeatedly[figurineInteraction].Add(location.Value);
            //            }
            //            else
            //            {
            //                figurine.Interaction = false;
            //            }
            //        }
            //    }
            //}

            int checkIndex = 0;
            List <FigurineInteractions> figurineInteractions = repeatedly.Keys.ToList();
            while (repeatedly.Count > 0)
            {
                FigurineInteractions figurineInteraction = figurineInteractions[checkIndex];
                List <Figurine>      figurinesRepeatedly = repeatedly[figurineInteraction];

                figurineAndLocation.Clear();
                foreach (KeyValuePair <Vector2, Cell> location in this.cells)
                {
                    if (location.Value.Selected != null)
                    {
                        figurineAndLocation.Add(location.Value.Selected, location.Value);
                    }
                }

                for (int index = 0; index < figurinesRepeatedly.Count; index++)
                {
                    Figurine figurine = figurinesRepeatedly[index];
                    if (figurine != null)
                    {
                        if (figurineAndLocation.ContainsKey(figurine) == true && figurineInteraction.Use(figurineAndLocation[figurine], this) == true)
                        {
                            repeatedly[figurineInteraction].Remove(figurine);
                            figurine.InteractionsColmlited.Add(figurineInteraction);
                            if (repeatedly[figurineInteraction].Count == 0)
                            {
                                repeatedly.Remove(figurineInteraction);
                            }
                        }
                        else
                        {
                            repeatedly[figurineInteraction].Remove(figurine);
                            if (repeatedly[figurineInteraction].Count == 0)
                            {
                                repeatedly.Remove(figurineInteraction);
                            }
                        }
                    }
                }

                checkIndex++;
                if (checkIndex >= repeatedly.Count)
                {
                    checkIndex = 0;
                }
            }
            figurines.ForEach(x =>
            {
                if (x != null)
                {
                    x.InteractionsColmlited.Clear();
                }
            });
        }
    }
示例#16
0
 public void AddFigurineLayout(Figurine figurine)
 {
     //figurineLayoutList.add(new FigurineLayout(this, figurine);
 }
示例#17
0
 private void MoveTo(Character chr)
 {
     SpawnPoint.SpawnEntry.Position = chr.Position;
     Figurine.TeleportTo(chr.Position);
 }
示例#18
0
    public void InteractionsFigure(Cell selected)
    {
        Dictionary <Figurine, Cell> figurineAndLocation = GetFigurines();

        if (figurineAndLocation.Count > 0)
        {
            List <Figurine> figurines = figurineAndLocation.Keys.ToList();
            for (int index = 0; index < figurines.Count; index++)
            {
                int numberRandom = Random.Range(0, figurines.Count);
                Swap(index, numberRandom, ref figurines);
            }

            if (selected.Selected != null)
            {
                int indexSelected = figurines.IndexOf(selected.Selected);
                Swap(0, indexSelected, ref figurines);
            }

            List <Figurine> blackList = new List <Figurine>();
            Dictionary <FigurineInteractions, List <Figurine> > repeatedly = new Dictionary <FigurineInteractions, List <Figurine> >();
            for (int index = 0; index < figurines.Count; index++)
            {
                Figurine figurine = figurines[index];
                if (figurine != null && blackList.Contains(figurine) == false && figurine.Interaction == true)
                {
                    blackList.Add(figurine);
                    FigurineData data = figurine.Data;
                    for (int indexInteraction = 0; indexInteraction < data.Interactions.Length; indexInteraction++)
                    {
                        FigurineInteractions figurineInteraction = data.Interactions[indexInteraction];

                        if (figurine == selected.Selected && figurineInteraction.ActivateOnDrop != true)
                        {
                            figurine.InteractionsColmlited.Add(figurineInteraction);
                            continue;
                        }
                        if (figurineInteraction.Use(figurineAndLocation[figurine], this) == false)
                        {
                            if (repeatedly.ContainsKey(figurineInteraction) == false)
                            {
                                repeatedly.Add(figurineInteraction, new List <Figurine>());
                            }
                            repeatedly[figurineInteraction].Add(figurine);
                        }
                        else
                        {
                            figurine.InteractionsColmlited.Add(figurineInteraction);
                        }
                    }
                }
            }

            int checkIndex = 0;
            List <FigurineInteractions> figurineInteractions = repeatedly.Keys.ToList();
            while (repeatedly.Count > 0)
            {
                FigurineInteractions figurineInteraction = figurineInteractions[checkIndex];
                List <Figurine>      figurinesRepeatedly = repeatedly[figurineInteraction];

                figurineAndLocation = GetFigurines();

                for (int index = 0; index < figurinesRepeatedly.Count; index++)
                {
                    Figurine figurine = figurinesRepeatedly[index];
                    if (figurine != null)
                    {
                        if (figurineAndLocation.ContainsKey(figurine) == true && figurineInteraction.Use(figurineAndLocation[figurine], this) == true)
                        {
                            repeatedly[figurineInteraction].Remove(figurine);
                            figurine.InteractionsColmlited.Add(figurineInteraction);
                            if (repeatedly[figurineInteraction].Count == 0)
                            {
                                repeatedly.Remove(figurineInteraction);
                            }
                        }
                        else
                        {
                            repeatedly[figurineInteraction].Remove(figurine);
                            if (repeatedly[figurineInteraction].Count == 0)
                            {
                                repeatedly.Remove(figurineInteraction);
                            }
                        }
                    }
                }

                checkIndex++;
                if (checkIndex >= repeatedly.Count)
                {
                    checkIndex = 0;
                }
            }


            figurines.ForEach(x =>
            {
                if (x != null)
                {
                    x.InteractionsColmlited.Clear();
                }
            });
        }
    }
示例#19
0
        private void Button2_Click(object sender, EventArgs e)
        {
            button2.Enabled = false;
            if (pictureBox1.Enabled)
            {
                pictureBox1.Enabled = false;
                int istrg = 0, jstrg = 0, ibrd = 0, jbrd = 0;
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (borderBox[i, j].BackColor == Color.Blue)
                        {
                            istrg = i;
                            jstrg = j;
                            borderBox[i, j].BackColor = Color.White;
                            borderBox[i, j].Refresh();
                            pictureBox[i, j].Image = null;
                            pictureBox[i, j].Refresh();
                        }
                        if (((Bitmap)pictureBox1.Image).GetPixel(j * size + size / 2, (int)((i + 0.05f) * size)) == Color.FromArgb(255, 255, 0, 0))
                        {
                            ibrd = i;
                            jbrd = j;
                        }
                    }
                }

                board[ibrd, jbrd]     = new Figurine(storage[istrg, jstrg]);
                storage[istrg, jstrg] = null;
                Paint_Board();

                if (!Stop(board) && !Standoff(board))
                {
                    for (int i = 0; i < 4; i++)
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            pictureBox[i, j].Enabled = true;
                        }
                    }
                    richTextBox1.Text = "Выберете фигуру, которой будет играть противник.";
                }
                else if (Standoff(board))
                {
                    richTextBox1.Text = "Ничья!";
                    timer1.Stop();
                    (menu as Form3).ContinueLock();
                }
                else
                {
                    richTextBox1.Text = "QUARTO! Вы выиграли!";
                    queriesTableAdapter.IncWins(label6.Text, time - new DateTime(0, 0));
                    queriesTableAdapter.SaveGame(label6.Text, time - new DateTime(0, 0), step, turn);
                    timer1.Stop();
                    (menu as Form3).ContinueLock();
                }
            }
            else
            {
                step++;
                label2.Text = "Ход: " + step.ToString();
                label2.Refresh();

                richTextBox1.Text = "Подождите, компьютер делает свой ход.";
                richTextBox1.Refresh();

                int istrg = 0, jstrg = 0;
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        pictureBox[i, j].Enabled = false;
                        if (borderBox[i, j].BackColor == Color.Red)
                        {
                            borderBox[i, j].BackColor = Color.LimeGreen;
                            borderBox[i, j].Refresh();
                            istrg = i;
                            jstrg = j;
                        }
                    }
                }

                Thread.Sleep(1000);

                Graphics g = Graphics.FromImage(pictureBox1.Image);
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (board[i, j] == null)
                        {
                            Figurine[,] tmp = (Figurine[, ])board.Clone();
                            tmp[i, j]       = new Figurine(storage[istrg, jstrg]);
                            if (Stop(tmp) || Standoff(tmp))
                            {
                                g.DrawEllipse(new Pen(Color.LimeGreen, 3), (j + 0.05f) * size, (i + 0.05f) * size, size * 0.9f, size * 0.9f);
                                g.DrawImage(pictureBox[istrg, jstrg].Image, j * size + 4, i * size + 4, new Rectangle(0, 0, size, size), GraphicsUnit.Pixel);
                                pictureBox1.Refresh();
                                Thread.Sleep(200);

                                borderBox[istrg, jstrg].BackColor = Color.White;
                                borderBox[istrg, jstrg].Refresh();
                                pictureBox[istrg, jstrg].Image = null;
                                pictureBox[istrg, jstrg].Refresh();

                                board[i, j]           = new Figurine(storage[istrg, jstrg]);
                                storage[istrg, jstrg] = null;

                                if (Standoff(board))
                                {
                                    richTextBox1.Text = "Ничья!";
                                }
                                else
                                {
                                    richTextBox1.Text = "QUARTO! Компьютер выиграл!";
                                }

                                timer1.Stop();
                                (menu as Form3).ContinueLock();

                                return;
                            }
                        }
                    }
                }

                int  ibrd, jbrd, ifig, jfig, cnt = 0;
                bool flag;
                do
                {
                    cnt++;
                    flag = false;

                    do
                    {
                        ibrd = rnd.Next(4);
                        jbrd = rnd.Next(4);
                    } while (board[ibrd, jbrd] != null);

                    do
                    {
                        ifig = rnd.Next(4);
                        jfig = rnd.Next(4);
                    } while (storage[ifig, jfig] == null || ifig == istrg && jfig == jstrg);

                    Figurine[,] tmp1 = (Figurine[, ])board.Clone();
                    tmp1[ibrd, jbrd] = new Figurine(storage[istrg, jstrg]);
                    for (int i = 0; i < 4; i++)
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            if (tmp1[i, j] == null)
                            {
                                Figurine[,] tmp2 = (Figurine[, ])tmp1.Clone();
                                tmp2[i, j]       = new Figurine(storage[ifig, jfig]);
                                if (Stop(tmp2))
                                {
                                    flag = true;
                                }
                            }
                        }
                    }
                } while (flag || cnt < 9);

                g.DrawEllipse(new Pen(Color.LimeGreen, 3), (jbrd + 0.05f) * size, (ibrd + 0.05f) * size, size * 0.9f, size * 0.9f);
                g.DrawImage(pictureBox[istrg, jstrg].Image, jbrd * size + 4, ibrd * size + 4, new Rectangle(0, 0, size, size), GraphicsUnit.Pixel);
                pictureBox1.Refresh();
                Thread.Sleep(200);

                borderBox[istrg, jstrg].BackColor = Color.White;
                borderBox[istrg, jstrg].Refresh();
                pictureBox[istrg, jstrg].Image = null;
                pictureBox[istrg, jstrg].Refresh();

                board[ibrd, jbrd]     = new Figurine(storage[istrg, jstrg]);
                storage[istrg, jstrg] = null;

                borderBox[ifig, jfig].BackColor = Color.Blue;
                borderBox[ifig, jfig].Refresh();

                richTextBox1.Text   = "Противник сделал ход (зелёный). Выберете поле на доске для выбронной противником фигуры (синий).";
                pictureBox1.Enabled = true;

                step++;
                label2.Text = "Ход: " + step.ToString();
            }
        }