Beispiel #1
0
 public void ManageContrat(string manage_action_contrat, ClickOnContract new_contrat)
 {
     if (manage_action_contrat == "ActiveContrat")
     {
         if (actif_contrat)
         {
             if (actif_contrat != new_contrat)
             {
                 actif_contrat.SwitchImage();
             }
             new_contrat.SwitchImage();
         }
         else
         {
             new_contrat.SwitchImage();
         }
         if (actif_contrat != new_contrat)
         {
             actif_contrat = new_contrat;
         }
         else
         {
             actif_contrat = null;
         }
     }
     if (actif_contrat)
     {
         CheckSelectedForm(null, 0, 0, false);
     }
 }
Beispiel #2
0
    public void GenerateContrat()
    {
        GameObject current_contract;
        int        difficulty_contrat_max;
        int        difficulty_contrat;
        int        nb_form;
        int        color_choice = 0;
        int        choice_form  = 0;


        if (contract_done >= 55)
        {
            difficulty_contrat_max = 5;
        }
        else
        {
            difficulty_contrat_max = difficulty_by_contract[(int)contract_done / 5];
        }
        for (int i = 0; i < 5; i++)
        {
            if (difficulty_contrat_max > 1)
            {
                difficulty_contrat = Random.Range(1, difficulty_contrat_max + 1);
                choice_form        = Random.Range(0, form_contract_by_difficulty [difficulty_contrat - 1]);
            }
            else
            {
                difficulty_contrat = difficulty_contrat_max;
            }
            current_contract = parent_contract.GetChild(i).gameObject;
            current_contract.SetActive(true);
            current_contract.GetComponent <Image>().sprite = list_contrat [difficulty_contrat - 1];

            if (nb_current_generateur > 1)
            {
                color_choice = Random.Range(0, nb_current_generateur);
            }
            GenerateTask(current_contract, choice_form, list_contrat_block[color_choice], difficulty_contrat, true);
            goScript = (ClickOnContract)current_contract.GetComponent(typeof(ClickOnContract));
            goScript.SetSprite(list_contrat [difficulty_contrat - 1], list_contrat_light [difficulty_contrat - 1]);
            goScript.SetGameLogic(this);
            goScript.SetMotifFormColor(difficulty_contrat, choice_form, color_choice);
        }
    }
Beispiel #3
0
    public bool CheckSelectedForm(ClickOnTile current_tile, int index, int color, bool already_see)
    {
        if (already_see && current_tile)
        {
            for (int i = current_tile.GetNbTileSelected(); i < nb_tile_selected - 1; i++)
            {
                list_selected_tile [i]       = list_selected_tile [i + 1];
                list_selected_tile_object[i] = list_selected_tile_object[i + 1];
                list_selected_tile_object [i].SetNbTileSelected(i);
            }
            nb_tile_selected -= 1;
        }
        else if (current_tile != null && color != 4)
        {
            current_tile.SetNbTileSelected(nb_tile_selected);
            list_selected_tile [nb_tile_selected].x     = index;
            list_selected_tile [nb_tile_selected].y     = color;
            list_selected_tile_object[nb_tile_selected] = current_tile;
            nb_tile_selected += 1;
        }
        if (actif_contrat)
        {
            int   motif, form, nb_block_asked;
            int[] color_pattern, pattern;

            motif = actif_contrat.GetMotif();
            form  = actif_contrat.GetForm();
            color = actif_contrat.GetColor();
            if (motif >= 5)
            {
                nb_block_asked = 4;
            }
            else
            {
                nb_block_asked = actif_contrat.GetMotif();
            }
            if (nb_tile_selected == nb_block_asked)
            {
                pattern       = new int[nb_block_asked];
                color_pattern = new int[nb_block_asked];
                if (motif == 1)
                {
                    pattern = CreatePatern(1, 0, 0, 0, 0);
                }
                else if (motif == 2)
                {
                    if (form == 0)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, 0, 0);
                    }
                    else if (form == 1)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, 0, 0);
                    }
                }
                else if (motif == 3)
                {
                    if (form == 0)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri + 1, 0);
                    }
                    else if (form == 1)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri * 2, 0);
                    }
                    else if (form == 2)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, 2, 0);
                    }
                    else if (form == 3)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri, max_column_tetri + 1, 0);
                    }
                    else if (form == 4)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, max_column_tetri + 1, 0);
                    }
                    else if (form == 5)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, max_column_tetri, 0);
                    }
                }
                else if (motif == 4)
                {
                    if (form == 0)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri * 2, max_column_tetri * 3);
                    }
                    else if (form == 1)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, max_column_tetri, max_column_tetri * 2);
                    }
                    else if (form == 2)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, max_column_tetri + 1, max_column_tetri * 2 + 1);
                    }
                    else if (form == 3)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri, max_column_tetri + 1, max_column_tetri * 2 + 1);
                    }
                    else if (form == 4)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri + 1, max_column_tetri * 2);
                    }
                    else if (form == 5)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri + 1, max_column_tetri * 2, max_column_tetri * 2 + 1);
                    }
                    else if (form == 6)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri * 2, max_column_tetri * 2 + 1);
                    }
                    else if (form == 7)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, 2, 3);
                    }
                    else if (form == 8)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, 2, max_column_tetri + 2);
                    }
                    else if (form == 9)
                    {
                        pattern = CreatePatern(nb_block_asked, 2, max_column_tetri, max_column_tetri + 1, max_column_tetri + 2);
                    }
                    else if (form == 10)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, 2, max_column_tetri + 1);
                    }
                    else if (form == 11)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri, max_column_tetri + 1, max_column_tetri + 2);
                    }
                    else if (form == 12)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, 2, max_column_tetri);
                    }
                    else if (form == 13)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri + 1, max_column_tetri + 2);
                    }
                }
                else if (motif == 5)
                {
                    if (form == 0)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri, max_column_tetri * 2, max_column_tetri * 3 + 1);
                    }
                    else if (form == 1)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri + 1, max_column_tetri * 2 + 1, max_column_tetri * 3);
                    }
                    else if (form == 2)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri * 2, max_column_tetri * 3 + 1);
                    }
                    else if (form == 3)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri + 1, max_column_tetri * 2 + 1, max_column_tetri * 3);
                    }
                    else if (form == 4)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri, max_column_tetri * 2, max_column_tetri * 3);
                    }
                    else if (form == 5)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri + 1, max_column_tetri * 2 + 1, max_column_tetri * 3 + 1);
                    }
                    else if (form == 6)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, max_column_tetri, max_column_tetri + 2, max_column_tetri * 2 + 1);
                    }
                    else if (form == 7)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, 2, max_column_tetri, max_column_tetri * 2);
                    }
                    else if (form == 8)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, max_column_tetri + 2, max_column_tetri * 2 + 2);
                    }
                    else if (form == 9)
                    {
                        pattern = CreatePatern(nb_block_asked, 2, max_column_tetri + 2, max_column_tetri * 2, max_column_tetri * 2 + 1);
                    }
                    else if (form == 10)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri, max_column_tetri * 2 + 1, max_column_tetri * 2 + 2);
                    }
                    else if (form == 11)
                    {
                        pattern = CreatePatern(nb_block_asked, 3, max_column_tetri, max_column_tetri + 1, max_column_tetri + 2);
                    }
                    else if (form == 12)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, max_column_tetri + 1, max_column_tetri + 2, max_column_tetri + 3);
                    }
                    else if (form == 13)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, 2, 3, max_column_tetri);
                    }
                    else if (form == 14)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 1, 2, max_column_tetri + 3);
                    }
                    else if (form == 15)
                    {
                        pattern = CreatePatern(nb_block_asked, 1, 2, max_column_tetri, max_column_tetri + 3);
                    }
                    else if (form == 16)
                    {
                        pattern = CreatePatern(nb_block_asked, 0, 3, max_column_tetri + 1, max_column_tetri + 2);
                    }
                }
                color_pattern = CreatePatern(nb_block_asked, color, color, color, color);
                if (CheckForm(list_selected_tile, nb_block_asked, pattern, color_pattern))
                {
                    for (int i = 0; i < nb_tile_selected; i++)
                    {
                        list_selected_tile_object [i].Reset(default_sprite_tile);
                    }
                    nb_tile_used    -= nb_tile_selected;
                    nb_tile_selected = 0;
                    GenerateTask(actif_contrat.gameObject, form, null, motif, false);
                    actif_contrat.gameObject.SetActive(false);
                    Camera.main.gameObject.GetComponent <SoundManager> ().SuccedContratSound();
                    actif_contrat = null;
                    Finish_contract();
                    nb_contract_done [motif - 1] += 1;
                    return(true);
                }
            }
        }
        return(false);
    }