コード例 #1
0
    public override void DoAction(PlayerCharacter character, ItemSlot slot)
    {
        ItemData item = slot.GetItem();

        if (item != null && item.plant_data != null)
        {
            Vector3 pos     = character.transform.position + character.transform.forward * 0.4f;
            Plant   nearest = Plant.GetNearest(pos, item.plant_data.sow_radius);
            if (nearest == null) //Make sure theres not already a plant there
            {
                PlayerData.Get().RemoveItemAt(slot.slot_index, 1);
                Plant.Create(item.plant_data, pos, 0);
            }
        }
    }
コード例 #2
0
    public void CraftPlant(PlantData plant)
    {
        if (CanCraft(plant))
        {
            CraftCostData cost = plant.GetCraftCost();
            foreach (KeyValuePair <ItemData, int> pair in cost.craft_items)
            {
                PlayerData.Get().RemoveItem(pair.Key.id, pair.Value);
                if (pair.Key.container_data)
                {
                    PlayerData.Get().AddItem(pair.Key.container_data.id, pair.Value);
                }
            }
            Vector3 pos = transform.position + transform.forward * 0.4f;
            Plant.Create(plant, pos, 0);

            TheAudio.Get().PlaySFX("craft", plant.craft_sound);
        }
    }
コード例 #3
0
ファイル: FieldFarm.cs プロジェクト: naaturaz/SM
    private void CreatePlantsLoop()
    {
        if (creaCount < _seedLoc.Count)
        {
            var plantNew = Plant.Create(_plantType, _seedLoc[creaCount], _building, this);

            if (_plantSave != null)
            {
                plantNew.LoadPlant(_plantSave);
            }

            _plants.Add(plantNew);
            creaCount++;
        }
        else
        {
            createPlantNow = false;
            creaCount      = 0;
            BatchInitial();
        }
    }