Ejemplo n.º 1
0
 /// <summary>
 /// OnGUI is called for rendering and handling GUI events.
 /// This function can be called multiple times per frame (one call per event).
 /// </summary>
 public void OnSceneGUI()
 {
     happyCheckStep = target as HappyCheckStep;
     Handles.color  = Color.white;
     if (mainData == null)
     {
         mainData = GameObject.Find("MainData").GetComponent <MainData>();
     }
     if (happyCheckStep.ufaMap == null)
     {
         return;
     }
     if (happyCheckStep.sortIndex < happyCheckStep.ufaIndexes.Length)
     {
         HCArea ufa = happyCheckStep.GetUfa(happyCheckStep.sortIndex);
         Handles.color = Color.yellow;
         Handles.Button(mainData.AreaPosWorld(ufa.pos.x, ufa.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap);
     }
     foreach (var index in happyCheckStep.stack)
     {
         HCArea ufa = happyCheckStep.GetUfa(index);
         Handles.color = happyCheckStep.numberCount == 0 ? Color.green : Color.red;
         Handles.Button(mainData.AreaPosWorld(ufa.pos.x, ufa.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap);
     }
     for (int i = 0; i < happyCheckStep.ufaIndexes.Length; i++)
     {
         if (happyCheckStep.ufaMap[happyCheckStep.GetUfa(i).pos] == 1)
         {
             HCArea ufa = happyCheckStep.GetUfa(i);
             Handles.color = Color.grey;
             Handles.Button(mainData.AreaPosWorld(ufa.pos.x, ufa.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.ArrowHandleCap);
         }
     }
 }
Ejemplo n.º 2
0
 public StepResult Step()
 {
     stepResult = StepResult.END;
     if (sortIndex < happyCheck.unFlipAreaList.Count || stack.Count > 0)
     {
         stepResult = StepResult.NORMAL;
         if (sortIndex == happyCheck.unFlipAreaList.Count)
         {
             sortIndex = stack[stack.Count - 1];
             stack.RemoveAt(stack.Count - 1);
             HCArea ufa = happyCheck.unFlipAreaList[ufaIndexes[sortIndex]];
             foreach (HCArea number in ufa.neighbours)
             {
                 number.value++;
                 if (number.value == 1)
                 {
                     numberCount++;
                     foreach (var neighbourUfa in number.neighbours)
                     {
                         ufaMap[neighbourUfa.pos] = 0;
                     }
                 }
             }
         }
         else
         {
             if (ufaMap[happyCheck.unFlipAreaList[ufaIndexes[sortIndex]].pos] == 0)
             {
                 stack.Add(sortIndex);
                 HCArea ufa = happyCheck.unFlipAreaList[ufaIndexes[sortIndex]];
                 foreach (HCArea number in ufa.neighbours)
                 {
                     number.value--;
                     if (number.value == 0)
                     {
                         numberCount--;
                         foreach (var neighbourUfa in number.neighbours)
                         {
                             ufaMap[neighbourUfa.pos] = 1;
                         }
                     }
                 }
                 stepResult = StepResult.PUTMINE;
                 if (numberCount == 0 && stack.Count <= Singleton.MainData.mineCount && stack.Count + happyCheck.unFlipAreaInsideList.Count >= Singleton.MainData.mineCount)
                 {
                     List <int> oneResult = new List <int>(stack);
                     checkResults.Add(oneResult);
                     stepResult = StepResult.GETRESULT;
                     createResultGb(oneResult);
                 }
             }
         }
         sortIndex++;
     }
     return(stepResult);
 }
Ejemplo n.º 3
0
 public void ChangeMapByFlip(List <FlipNode> flipNodes)
 {
     flipBoard = Singleton.GamePart.flipBoard;
     foreach (var node in flipNodes)
     {
         if (map[node.x, node.y] != -1)
         {
             var ufa = GetHCArea(node.x, node.y);
             foreach (var aroundNumber in ufa.neighbours)
             {
                 aroundNumber.neighbours.Remove(ufa);
                 if (aroundNumber.neighbours.Count == 0)
                 {
                     RemoveNumber(aroundNumber);
                 }
             }
             RemoveUnflipArea(ufa);
         }
         else
         {
             unFlipAreaInsideList.RemoveAt(insideMap[node.x, node.y]);
             insideMap[node.x, node.y] = -1;
         }
         List <HCArea> aroundUfa = new List <HCArea>();
         HCArea        number    = new HCArea(mineDatas[node.x, node.y], new IndexOfList2D(node.x, node.y), aroundUfa);
         flipBoard.ChangeAround(node.x, node.y,
                                (int x, int y, int get) => {
             if (get == 0)
             {
                 HCArea ufa = GetHCArea(x, y);
                 if (ufa == null)
                 {
                     ufa = new HCArea(-1, new IndexOfList2D(x, y), new List <HCArea>());
                     unFlipAreaInsideList.RemoveAt(insideMap[ufa.pos]);
                     insideMap[ufa.pos] = -1;
                     AddUnflipArea(ufa);
                 }
                 ufa.neighbours.Add(number);
                 aroundUfa.Add(ufa);
             }
             return(get);
         }
                                );
         if (aroundUfa.Count > 0)
         {
             AddNumber(number);
         }
     }
 }
Ejemplo n.º 4
0
    /// <summary>
    /// OnGUI is called for rendering and handling GUI events.
    /// This function can be called multiple times per frame (one call per event).
    /// </summary>
    public void OnSceneGUI()
    {
        HappyCheck happyCheck = target as HappyCheck;

        Handles.color = Color.white;
        if (mainData == null)
        {
            mainData = GameObject.Find("MainData").GetComponent <MainData>();
        }
        if (happyCheck.map == null)
        {
            return;
        }
        if (now == null)
        {
            SmartList <HCArea>[] hack = { happyCheck.unFlipAreaList, happyCheck.numberList };
            for (int i = 0; i < 2; i++)
            {
                foreach (HCArea ufa in hack[i])
                {
                    Handles.color = ufa.value >= 0 ? Color.yellow : Color.red;
                    if (Handles.Button(mainData.AreaPosWorld(ufa.pos.x, ufa.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap))
                    {
                        now = ufa;
                    }
                    Handles.Label(mainData.AreaPosWorld(ufa.pos.x, ufa.pos.y), ufa.value.ToString());
                }
            }
        }
        else
        {
            foreach (HCArea neighbor in now.neighbours)
            {
                Handles.color = neighbor.value >= 0 ? Color.yellow : Color.red;
                Handles.Label(mainData.AreaPosWorld(neighbor.pos.x, neighbor.pos.y), neighbor.value.ToString());
                if (Handles.Button(mainData.AreaPosWorld(neighbor.pos.x, neighbor.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap))
                {
                    now = neighbor;
                }
            }
            Handles.color = now.value >= 0 ? Color.yellow : Color.red;
            if (Handles.Button(mainData.AreaPosWorld(now.pos.x, now.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap))
            {
                now = null;
            }
        }
    }
Ejemplo n.º 5
0
 public void RemoveNumber(HCArea number)
 {
     numberList.RemoveAt(-2 - map[number.pos]);
     map[number.pos] = -1;
 }
Ejemplo n.º 6
0
 public void RemoveUnflipArea(HCArea ufa)
 {
     unFlipAreaList.RemoveAt(map[ufa.pos]);
     map[ufa.pos] = -1;
 }
Ejemplo n.º 7
0
 public void AddNumber(HCArea number)
 {
     map[number.pos] = -2 - numberList.Add(number);
 }
Ejemplo n.º 8
0
 public void AddUnflipArea(HCArea ufa)
 {
     map[ufa.pos] = unFlipAreaList.Add(ufa);
 }