Exemplo n.º 1
0
    public static void Generate(Vector3 pos, Plant.Type type)
    {
        if (prefab == null)
        {
            prefab = Resources.Load <GameObject>("Prefabs/SeedItem");
        }
        GameObject obj = GameObject.Instantiate(prefab, pos, Quaternion.identity);

        obj.GetComponent <SpriteRenderer>().sprite
            = Resources.Load <CollecableSeed>(CollecableSeed.seedDictionary[type]).icon;
        obj.GetComponent <SeedItem>().seedType = type;

        /* switch(type)
         * {
         *  case Plant.Type.Aquabud:
         *      s = Resources.Load<Sprite>("Seeds/seed1");
         *      break;
         *  case Plant.Type.Goji:
         *      s = Resources.Load<Sprite>("Seeds/seed2");
         *      break;
         *  case Plant.Type.Mulberry:
         *      s = Resources.Load<Sprite>("Seeds/seed3");
         *      break;
         * }*/
    }
Exemplo n.º 2
0
 public void plantSeed(Plant currentPlant)
 {
     Plant.Type hilightType = seeds.GetSeedType(hilightCode);
     if (currentPlant.type != Plant.Type.None)
     {
         if (currentPlant.mature)
         {
             /*if(PlayerFruitEater.Usable(currentPlant.type))
              * {
              *  PlayerFruitEater.Eat(currentPlant.type);
              *  currentPlant.Collect();
              * }
              * else
              * {*/
             InventoryManager.instance.AddFruit(currentPlant.type);
             currentPlant.Collect();
             //}
         }
         else if (!currentPlant.watered)
         {
             currentPlant.Water();
             FindObjectOfType <Player>().CostHealth(waterCost);
         }
     }
     else if (currentPlant.type == Plant.Type.None && hilightType != Plant.Type.None)
     {
         //Debug.Log(hilightType);
         InventoryManager.instance.UseSeed(hilightType);
         currentPlant.PlantSeed(hilightType);
     }
 }
Exemplo n.º 3
0
    public void AddFruit(Plant.Type seedType)
    {
        CollectableFruit temp = ScriptableObject.CreateInstance("CollectableFruit") as CollectableFruit;

        temp = Resources.Load <CollectableFruit>(CollectableFruit.FruitDictionary[seedType]);
        InventoryManager.instance.addItem(temp);
    }
Exemplo n.º 4
0
    public void UseFruit(Plant.Type seedType)
    {
        CollecableSeed temp = ScriptableObject.CreateInstance("CollecableSeed") as CollecableSeed;

        temp = Resources.Load <CollecableSeed>(CollectableFruit.FruitDictionary[seedType]);
        useItem(temp);
    }
Exemplo n.º 5
0
 public void GetItemInformation(bool seed, Plant.Type seedType, Vector3 pos)
 {
     box = Instantiate(Resources.Load("Prefabs/UI/ItemInformation") as GameObject, pos, Quaternion.identity).GetComponent <InformationBox>();
     box.transform.SetParent(transform);
     box.transform.SetAsLastSibling();
     box.setInformation(GetInfo(seed, seedType));
 }
Exemplo n.º 6
0
    public void AddSeed(Plant.Type seedType)
    {
        CollecableSeed temp = ScriptableObject.CreateInstance("CollecableSeed") as CollecableSeed;

        temp = Resources.Load <CollecableSeed>(CollecableSeed.seedDictionary[seedType]);
        addItem(temp);
    }
Exemplo n.º 7
0
    public void loadAnimation(Plant.Type seedType)
    {
        CollecableSeed temp = ScriptableObject.CreateInstance("CollecableSeed") as CollecableSeed;

        temp = Resources.Load <CollecableSeed>(CollecableSeed.seedDictionary[seedType]);
        string        path = "PlantAnimate/" + temp.name;
        AnimationClip ani  = Resources.Load <AnimationClip>(path);

        overrideController["Aquabud"]  = ani;
        anim.runtimeAnimatorController = overrideController;
    }
Exemplo n.º 8
0
 public ItemInfo GetInfo(bool seed, Plant.Type seedType)
 {
     if (seed)
     {
         foreach (var tmp in  infoList.seedInformation)
         {
             if (tmp.id == (int)seedType)
             {
                 return(tmp);
             }
         }
     }
     else
     {
         foreach (var tmp in  infoList.itemInformation)
         {
             if (tmp.id == (int)seedType)
             {
                 return(tmp);
             }
         }
     }
     return(defaultItem);
 }
Exemplo n.º 9
0
    public static void Eat(Plant.Type t)
    {
        if (PL == null)
        {
            PL = FindObjectOfType <Player>();
        }
        if (GS == null)
        {
            GS = FindObjectOfType <GameSystem>();
        }
        if (PA == null)
        {
            PA = FindObjectOfType <PlayerAttack>();
        }

        switch (t)
        {
        case Plant.Type.Aquabud:
            PL.AddHealth(30);
            break;

        case Plant.Type.Goji:
            PL.gojiBuffCnt++;
            break;

        case Plant.Type.Mulberry:
            PL.mulberryBuffCnt++;
            break;

        case Plant.Type.Wisplum:
            PL.wisplumBuffCnt++;
            break;

        case Plant.Type.Lime:
            PL.limeBuffTime = Player.MaxLimeBuffTime;
            break;

        case Plant.Type.Cloudberry:
            PL.cloudberryBuffTime = Player.MaxCloudberryBuffTime;
            break;

        case Plant.Type.Lychee:
            PL.SetElement(Player.Element.Fire);
            break;

        case Plant.Type.Cyanberry:
            PL.SetElement(Player.Element.Ice);
            break;

        case Plant.Type.Mango:
            PL.SetElement(Player.Element.Electric);
            break;

        case Plant.Type.Turret:
            PA.PlaceTurret();
            break;

        case Plant.Type.Bubble:
            PA.PlaceBarrier();
            break;

        case Plant.Type.Dragonfruit:
            PA.DragonfruitShoot();
            break;

        case Plant.Type.Jujube:
            PA.JujubeFlash();
            break;

        case Plant.Type.Persimmon:
            PA.PersimmonFlash();
            break;
        }
    }
Exemplo n.º 10
0
    public static bool Usable(Plant.Type t)
    {
        if (PL == null)
        {
            PL = FindObjectOfType <Player>();
        }
        if (GS == null)
        {
            GS = FindObjectOfType <GameSystem>();
        }
        if (PA == null)
        {
            PA = FindObjectOfType <PlayerAttack>();
        }
        if (GS.dayOrNight == GameSystem.DayOrNight.Day)
        {
            switch (t)
            {
            case Plant.Type.Aquabud:
                return(PL.health < 300F);

            case Plant.Type.Goji:
                return(PL.gojiBuffCnt < 5);

            case Plant.Type.Mulberry:
                return(PL.mulberryBuffCnt < 5);

            case Plant.Type.Wisplum:
                return(PL.wisplumBuffCnt < 3);

            default:
                return(false);
            }
        }
        else
        {
            switch (t)
            {
            case Plant.Type.Lime:
                return(true);

            case Plant.Type.Cloudberry:
                return(true);

            case Plant.Type.Lychee:
                return(PL.element == Player.Element.Water);

            case Plant.Type.Cyanberry:
                return(PL.element == Player.Element.Water);

            case Plant.Type.Mango:
                return(PL.element == Player.Element.Water);

            case Plant.Type.Turret:
                return(PA.CanUseItem());

            case Plant.Type.Bubble:
                return(PA.CanUseItem());

            case Plant.Type.Persimmon:
                return(PA.CanUseItem());

            case Plant.Type.Jujube:
                return(PA.CanUseItem());

            case Plant.Type.Dragonfruit:
                return(PA.CanUseItem());

            default:
                return(false);
            }
        }
        return(false);
    }
Exemplo n.º 11
0
    public void LootSeed(Vector3 pos, Plant.Type type, float chance)
    {
        if (type == Plant.Type.None || type == Plant.Type.Withered || chance <= 0F)
        {
            return;
        }

        float p = 0F, r = 0F;

        if (type == Plant.Type.Aquabud)
        {
            r = 0.015F * (lootCnt[Plant.Type.Aquabud] - 15);
            r = Mathf.Clamp(r, 0F, 0.6F);
            if (Random.Range(0F, 1F) <= r)
            {
                type = Random.Range(0F, 2F) < 1F ? Plant.Type.Turret : Plant.Type.Bubble;
            }
        }
        if (type == Plant.Type.Goji)
        {
            r = 1 - Mathf.Pow(0.7F, lootCnt[Plant.Type.Goji]);
            if (lootCnt[Plant.Type.Goji] >= 5)
            {
                r = 1;
            }
            if (Random.Range(0F, 1F) <= r)
            {
                p = Random.Range(0F, 3F);
                if (p < 1F)
                {
                    type = Plant.Type.Dragonfruit;
                }
                else if (p < 2F)
                {
                    type = Plant.Type.Jujube;
                }
                else
                {
                    type = Plant.Type.Persimmon;
                }
            }
        }
        if (type == Plant.Type.Mulberry)
        {
            r = 1 - Mathf.Pow(0.7F, lootCnt[Plant.Type.Mulberry]);
            if (lootCnt[Plant.Type.Mulberry] >= 5)
            {
                r = 1;
            }
            if (Random.Range(0F, 1F) <= r)
            {
                p = Random.Range(0F, 3F);
                if (p < 1F)
                {
                    type = Plant.Type.Lychee;
                }
                else if (p < 2F)
                {
                    type = Plant.Type.Cyanberry;
                }
                else
                {
                    type = Plant.Type.Mango;
                }
            }
        }
        if (type == Plant.Type.Wisplum)
        {
            r = 1 - Mathf.Pow(0.6F, lootCnt[Plant.Type.Wisplum]);
            if (lootCnt[Plant.Type.Wisplum] >= 3)
            {
                r = 1;
            }
            if (Random.Range(0F, 1F) <= r)
            {
                type = Random.Range(0F, 2F) < 1F ? Plant.Type.Lime : Plant.Type.Cloudberry;
            }
        }

        lootChanceMultiplier[type] += chance * basicLootChance[type];

        float rand = Random.Range(0F, 1F);

        if (rand <= lootChanceMultiplier[type] * chance)
        {
            SeedItem.Generate(pos, type);
            lootChanceMultiplier[type] = 1F;
            lootCnt[type]++;
        }
    }