Beispiel #1
0
 public string CheckWHatSlotGot(NPCInBattlePro NPC, SlotBattle Slot) // kiem tra slot co gi
 {
     if (Slot.CheckNoNPC())
     {
         return("No");
     }
     else
     {
         if (CheckIfSameTeam(NPC, Slot.FindNPCInSlot().NPCPro))
         {
             if (NPCNow.GetSlot() == Slot)
             {
                 return("Self");
             }
             else
             {
                 return("Ally");
             }
         }
         else
         {
             return("Enemy");
         }
     }
 }
Beispiel #2
0
 public void CheckForHighLight(SlotBattle Slot)
 {
     if (Slot.CheckNoNPC() || Slot.FindNPCInSlot().NPCPro.HP <= 0)
     {
         Slot.BlinkingColor.WhiteBlink();
     }
     else
     {
         if (CheckIfSameTeam(NPCNow.NPCPro, Slot.transform.Find("NPCInbattle(Clone)").GetComponent <NPCInBattle>().NPCPro))
         {
             if (NPCNow.GetSlot() != Slot)
             {
                 Slot.BlinkingColor.GreenBlink(); // Ally
             }
             else
             {
                 //       Slot.BlinkingColor.YellowBlink(); // Self
             }
         }
         else
         {
             Slot.BlinkingColor.RedBlink();
         }
     }
 }
Beispiel #3
0
    public void CheckSlotCanMove(int Index)
    {
        SlotBattle SlotNeed  = ListSlot.transform.GetChild(Index).GetComponent <SlotBattle>();
        int        StepCount = 1;
        int        PathIndex = 0;

        List <SlotBattle> Slots = new List <SlotBattle>();

        Test = new List <Vector2>();
        OffALLBlinkSlot();

        Test.Add(new Vector2(NPCNow.transform.parent.GetSiblingIndex(), 0));
        foreach (var item in NPCNow.GetSlot().GetAdjSlotNoNPC())
        {
            if (Slots.Contains(item) == false)
            {
                Slots.Add(item);
                Test.Add(new Vector2(item.transform.GetSiblingIndex(), StepCount));
            }
        }

        int AddCount  = 0;
        int AddCount2 = 0;// so lan add de kiem tra da cung duong chua

        while (Slots.Contains(SlotNeed) != true)
        {
            AddCount   = AddCount2;
            StepCount += 1;
            int tempint = Slots.Count;
            for (int i = 0; i < tempint; i++)
            {
                foreach (var item in Slots[i].GetAdjSlotNoNPC())
                {
                    if (Slots.Contains(item) == false)
                    {
                        Slots.Add(item);
                        Test.Add(new Vector2(item.transform.GetSiblingIndex(), StepCount));
                        AddCount2 += 1;
                    }
                }
            }

            if (AddCount2 == AddCount)
            {
                Debug.Log("tac duong roi anh ey");
                break;
            }
        }


        //  Tim Duong ngan nhat
        int        temp     = StepCount - 1;
        SlotBattle tempSlot = SlotNeed;

        Test2 = new List <SlotBattle>();
        for (int i = 1; i < StepCount; i++)
        {
            TempList  = new List <Vector2>();
            TempList2 = new List <Vector2>();

            TempList = Test.FindAll(x => x.y == temp);
            foreach (var item in TempList)
            {
                if (tempSlot.GetAdjSlotNoNPC().Contains(GetSlotWithIndex((int)item.x)))
                {
                    TempList2.Add(item);
                }
            }
            int ran = Random.Range(0, TempList2.Count);
            Test2.Add(GetSlotWithIndex((int)TempList2[ran].x));

            tempSlot = GetSlotWithIndex((int)TempList2[ran].x);
            temp    -= 1;
            //  temp
        }

        foreach (var item in Test2)
        {
            item.BlinkingColor.WhiteBlink();
        }
    }