Exemple #1
0
    //-----------------------------------------------

    /* public void PotionSaved()
     * {
     *   DataManager.SavePotion1 = Potion1Num;
     *   DataManager.SavePotion2 = Potion2Num;
     *   DataManager.SavePotion3 = Potion3Num;
     *   DataManager.SavePotion4 = Potion4Num;
     *   DataManager.SavePotion5 = Potion5Num;
     *   DataManager.SavePotion6 = Potion6Num;
     *   DataManager.SavePotion7 = Potion7Num;
     *   DataManager.SavePotion8 = Potion8Num;
     *   DataManager.SavePotion9 = Potion9Num;
     *   DataManager.SavePotion10 = Potion10Num;
     *   DataManager.SavePotion11 = Potion11Num;
     * }*/

    IEnumerator GetPotion()
    {
        yield return(new WaitForSeconds(0.5f - (FurnitureEffect.Furniture3_3Effect)));

        GetPotionCount = 0;

        GameObject[] Potion = GameObject.FindGameObjectsWithTag("ComPotion");

        Vector3 PlayerPos = GameObject.Find("Player").transform.position;
        Vector3 NPCPos    = GameObject.Find("Rain").transform.position;

        for (int index = 0; index < Potion.Length; index++)
        {
            if (Potion[index].transform.position.x >= PlayerPos.x - 0.5f && Potion[index].transform.position.x <= PlayerPos.x + 0.5f && Potion[index].transform.position.y <= -2.2f)
            {
                if (GetPotionCount < 1)
                {
                    PoParmeter = Potion[index].GetComponent <PotionParmeter>();
                    SoundManager.sounds["Pop (3)"].Play();
                    Rigidbody2D rigid     = Potion[index].GetComponent <Rigidbody2D>();
                    Vector2     getMotion = new Vector2(0f, 8f);


                    rigid.AddForce(getMotion, ForceMode2D.Impulse);
                    rigid.AddTorque(90f);

                    GetPotionCount++;
                    PotionCase = PoParmeter.PotionCaseNum;
                    switch (PotionCase)
                    {
                    case 0:
                        if (PoParmeter.isGasMat)
                        {
                            MaterialManager.MaterialGasNumber += 2;
                        }
                        else
                        {
                            MaterialManager.MaterialQSilverNumber += 2;
                        }

                        getBase.MaterialButtonUpdate();
                        break;

                    case 1:
                        if (!FirstPotion1)
                        {
                            DataCallManager.SavePotionType(1);
                        }
                        Potion1Num += PoParmeter.PotionNum;
                        PoList.Potion1ListUpdate();
                        break;

                    case 2:
                        if (!FirstPotion2)
                        {
                            DataCallManager.SavePotionType(2);
                        }
                        Potion2Num += PoParmeter.PotionNum;
                        PoList.Potion2ListUpdate();
                        break;

                    case 3:
                        if (!FirstPotion3)
                        {
                            DataCallManager.SavePotionType(3);
                        }
                        Potion3Num += PoParmeter.PotionNum;
                        PoList.Potion3ListUpdate();
                        break;

                    case 4:
                        if (!FirstPotion4)
                        {
                            DataCallManager.SavePotionType(4);
                        }
                        Potion4Num += PoParmeter.PotionNum;
                        PoList.Potion4ListUpdate();
                        break;

                    case 5:
                        if (!FirstPotion5)
                        {
                            DataCallManager.SavePotionType(5);
                        }
                        Potion5Num += PoParmeter.PotionNum;
                        PoList.Potion5ListUpdate();
                        break;

                    case 6:
                        if (!FirstPotion6)
                        {
                            DataCallManager.SavePotionType(6);
                        }
                        Potion6Num += PoParmeter.PotionNum;
                        PoList.Potion6ListUpdate();
                        break;

                    case 7:
                        if (!FirstPotion7)
                        {
                            DataCallManager.SavePotionType(7);
                        }
                        Potion7Num += PoParmeter.PotionNum;
                        PoList.Potion7ListUpdate();
                        break;

                    case 8:
                        if (!FirstPotion8)
                        {
                            DataCallManager.SavePotionType(8);
                        }
                        Potion8Num += PoParmeter.PotionNum;
                        PoList.Potion8ListUpdate();
                        break;

                    case 9:
                        if (!FirstPotion9)
                        {
                            DataCallManager.SavePotionType(9);
                        }
                        Potion9Num += PoParmeter.PotionNum;
                        PoList.Potion9ListUpdate();
                        break;

                    case 10:
                        if (!FirstPotion10)
                        {
                            DataCallManager.SavePotionType(10);
                        }
                        Potion10Num += PoParmeter.PotionNum;
                        PoList.Potion10ListUpdate();
                        break;

                    case 11:
                        if (!FirstPotion11)
                        {
                            DataCallManager.SavePotionType(11);
                        }
                        Potion11Num += PoParmeter.PotionNum;
                        PoList.Potion11ListUpdate();
                        break;

                    case 12:
                        if (!FirstPotion12)
                        {
                            DataCallManager.SavePotionType(12);
                        }
                        Potion12Num += PoParmeter.PotionNum;
                        PoList.Potion12ListUpdate();
                        break;

                    case 13:
                        if (!FirstPotion13)
                        {
                            DataCallManager.SavePotionType(13);
                        }
                        Potion13Num += PoParmeter.PotionNum;
                        PoList.Potion13ListUpdate();
                        break;

                    case 14:
                        if (!FirstPotion14)
                        {
                            DataCallManager.SavePotionType(14);
                        }
                        Potion14Num += PoParmeter.PotionNum;
                        PoList.Potion14ListUpdate();
                        break;

                    case 15:
                        if (!FirstPotion15)
                        {
                            DataCallManager.SavePotionType(15);
                        }
                        Potion15Num += PoParmeter.PotionNum;
                        PoList.Potion15ListUpdate();
                        break;
                    }
                    Destroy(Potion[index].gameObject, 0.5f);
                }
            }

            else if (Potion[index].transform.position.x >= NPCPos.x - 0.5f && Potion[index].transform.position.x <= NPCPos.x + 0.5f && Potion[index].transform.position.y <= -2.2f)
            {
                if (GetPotionCount < 1)
                {
                    PoParmeter = Potion[index].GetComponent <PotionParmeter>();
                    SoundManager.sounds["Pop (3)"].Play();
                    Rigidbody2D rigid     = Potion[index].GetComponent <Rigidbody2D>();
                    Vector2     getMotion = new Vector2(0f, 8f);


                    rigid.AddForce(getMotion, ForceMode2D.Impulse);
                    rigid.AddTorque(90f);

                    GetPotionCount++;
                    PotionCase = PoParmeter.PotionCaseNum;
                    switch (PotionCase)
                    {
                    case 0:
                        if (PoParmeter.isGasMat)
                        {
                            MaterialManager.MaterialGasNumber += 2;
                        }
                        else
                        {
                            MaterialManager.MaterialQSilverNumber += 2;
                        }

                        getBase.MaterialButtonUpdate();
                        break;

                    case 1:
                        if (!FirstPotion1)
                        {
                            DataCallManager.SavePotionType(1);
                        }
                        Potion1Num += PoParmeter.PotionNum;
                        PoList.Potion1ListUpdate();
                        break;

                    case 2:
                        if (!FirstPotion2)
                        {
                            DataCallManager.SavePotionType(2);
                        }
                        Potion2Num += PoParmeter.PotionNum;
                        PoList.Potion2ListUpdate();
                        break;

                    case 3:
                        if (!FirstPotion3)
                        {
                            DataCallManager.SavePotionType(3);
                        }
                        Potion3Num += PoParmeter.PotionNum;
                        PoList.Potion3ListUpdate();
                        break;

                    case 4:
                        if (!FirstPotion4)
                        {
                            DataCallManager.SavePotionType(4);
                        }
                        Potion4Num += PoParmeter.PotionNum;
                        PoList.Potion4ListUpdate();
                        break;

                    case 5:
                        if (!FirstPotion5)
                        {
                            DataCallManager.SavePotionType(5);
                        }
                        Potion5Num += PoParmeter.PotionNum;
                        PoList.Potion5ListUpdate();
                        break;

                    case 6:
                        if (!FirstPotion6)
                        {
                            DataCallManager.SavePotionType(6);
                        }
                        Potion6Num += PoParmeter.PotionNum;
                        PoList.Potion6ListUpdate();
                        break;

                    case 7:
                        if (!FirstPotion7)
                        {
                            DataCallManager.SavePotionType(7);
                        }
                        Potion7Num += PoParmeter.PotionNum;
                        PoList.Potion7ListUpdate();
                        break;

                    case 8:
                        if (!FirstPotion8)
                        {
                            DataCallManager.SavePotionType(8);
                        }
                        Potion8Num += PoParmeter.PotionNum;
                        PoList.Potion8ListUpdate();
                        break;

                    case 9:
                        if (!FirstPotion9)
                        {
                            DataCallManager.SavePotionType(9);
                        }
                        Potion9Num += PoParmeter.PotionNum;
                        PoList.Potion9ListUpdate();
                        break;

                    case 10:
                        if (!FirstPotion10)
                        {
                            DataCallManager.SavePotionType(10);
                        }
                        Potion10Num += PoParmeter.PotionNum;
                        PoList.Potion10ListUpdate();
                        break;

                    case 11:
                        if (!FirstPotion11)
                        {
                            DataCallManager.SavePotionType(11);
                        }
                        Potion11Num += PoParmeter.PotionNum;
                        PoList.Potion11ListUpdate();
                        break;

                    case 12:
                        if (!FirstPotion12)
                        {
                            DataCallManager.SavePotionType(12);
                        }
                        Potion12Num += PoParmeter.PotionNum;
                        PoList.Potion12ListUpdate();
                        break;

                    case 13:
                        if (!FirstPotion13)
                        {
                            DataCallManager.SavePotionType(13);
                        }
                        Potion13Num += PoParmeter.PotionNum;
                        PoList.Potion13ListUpdate();
                        break;

                    case 14:
                        if (!FirstPotion14)
                        {
                            DataCallManager.SavePotionType(14);
                        }
                        Potion14Num += PoParmeter.PotionNum;
                        PoList.Potion14ListUpdate();
                        break;

                    case 15:
                        if (!FirstPotion15)
                        {
                            DataCallManager.SavePotionType(15);
                        }
                        Potion15Num += PoParmeter.PotionNum;
                        PoList.Potion15ListUpdate();
                        break;
                    }
                    Destroy(Potion[index].gameObject, 0.5f);
                }
            }
        }
        StartCoroutine("GetPotion");
    }