コード例 #1
0
ファイル: PlantData.cs プロジェクト: Basipek/unitystation
    /// <summary>
    /// Mutates the plant instance this is run against
    /// </summary>
    /// <param name="_PlantData.plantEvolveStats"></param>
    public void MutateTo(PlantData _PlantData)
    {
        if (_PlantData.plantEvolveStats == null)
        {
            return;
        }
        Plantname     = _PlantData.Plantname;
        Description   = _PlantData.Description;
        Name          = _PlantData.Name;
        ProduceObject = _PlantData.ProduceObject;


        GrowthSpritesSOs = _PlantData.GrowthSpritesSOs;

        FullyGrownSpriteSO    = _PlantData.FullyGrownSpriteSO;
        DeadSpriteSO          = _PlantData.DeadSpriteSO;
        MutatesInToGameObject = _PlantData.MutatesInToGameObject;

        WeedResistance = WeedResistance + _PlantData.plantEvolveStats.WeedResistanceChange;
        WeedGrowthRate = WeedGrowthRate + _PlantData.plantEvolveStats.WeedGrowthRateChange;
        GrowthSpeed    = GrowthSpeed + _PlantData.plantEvolveStats.GrowthSpeedChange;
        Potency        = Mathf.Clamp(Potency + _PlantData.plantEvolveStats.PotencyChange, 0, MAX_POTENCY);
        Endurance      = Endurance + _PlantData.plantEvolveStats.EnduranceChange;
        Yield          = Yield + _PlantData.plantEvolveStats.YieldChange;
        Lifespan       = Lifespan + _PlantData.plantEvolveStats.LifespanChange;


        PlantTrays = (_PlantData.plantEvolveStats.PlantTrays.Union(PlantTrays)).ToList();
        CombineReagentProduction(_PlantData.plantEvolveStats.ReagentProduction);
    }
コード例 #2
0
    private void CropDeath()
    {
        if (plantData.PlantTrays.Contains(PlantTrays.Weed_Adaptation))
        {
            nutritionLevel = nutritionLevel + plantData.Potency;
            if (nutritionLevel > 100)
            {
                nutritionLevel = 100;
            }
        }

        if (plantData.PlantTrays.Contains(PlantTrays.Fungal_Vitality))
        {
            Dictionary <string, float> reagent = new Dictionary <string, float> {
                ["water"] = plantData.Potency
            };
            reagentContainer.AddReagents(reagent);
        }

        UpdatePlantGrowthStage(growingPlantStage, 0);
        UpdatePlantStage(plantCurrentStage, PlantSpriteStage.Dead);
        plantData = null;
        readyProduce.Clear();
        UpdateHarvestFlag(harvestNotifier, false);
    }
コード例 #3
0
 public static void Load()
 {
     craft_data.Clear();
     craft_data.AddRange(ItemData.GetAll());
     craft_data.AddRange(ConstructionData.GetAll());
     craft_data.AddRange(PlantData.GetAll());
 }
コード例 #4
0
        /// <summary>
        /// Handles processing produce into seed packets at rate defined by processingTime
        /// </summary>
        public override void UpdateMe()
        {
            //Only run on server and if there is something to process and the device has power
            if (!isServer || !IsProcessing || currentState == PowerStates.Off)
            {
                return;
            }
            //If processing isn't done keep waiting
            if (processingProgress < processingTime)
            {
                processingProgress += Time.deltaTime;
                return;
            }

            //Handle completed processing
            processingProgress = 0;
            var grownFood  = foodToBeProcessed.Dequeue();
            var seedPacket = Spawn.ServerPrefab(grownFood.SeedPacket).GameObject.GetComponent <SeedPacket>();

            seedPacket.plantData = PlantData.CreateNewPlant(grownFood.GetPlantData());

            //Add seed packet to dispenser
            seedPackets.Add(seedPacket);
            updateEvent.Invoke();

            //De-spawn processed food
            Inventory.ServerDespawn(grownFood.gameObject);
            if (foodToBeProcessed.Count == 0)
            {
                Chat.AddLocalMsgToChat("The seed extractor finishes processing", (Vector2Int)registerObject.WorldPosition, this.gameObject);
            }
        }
コード例 #5
0
ファイル: StoreManager.cs プロジェクト: dovisj/secretprojectX
        private StoreItem GetRandomStoreItem()
        {
            PlantData plant = PlantManager.Instance.GetRandomPlantType();

            plant.Randomize();
            return(new StoreItem(plant));
        }
コード例 #6
0
    private void CropDeath()
    {
        if (plantData.PlantTrays.Contains(PlantTrays.Weed_Adaptation))
        {
            nutritionLevel = nutritionLevel + plantData.Potency;
            if (nutritionLevel > 100)
            {
                nutritionLevel = 100;
            }
        }

        if (plantData.PlantTrays.Contains(PlantTrays.Fungal_Vitality))
        {
            Dictionary <string, float> reagent = new Dictionary <string, float> {
                ["water"] = plantData.Potency
            };
            reagentContainer.AddReagents(reagent);
        }

        SyncGrowingPlantStage(0);
        plantSubStage        = 0;
        plantHealth          = 100;
        readyToHarvest       = false;
        numberOfUpdatesAlive = 0;
        SyncStage(PlantSpriteStage.Dead);
        plantData = null;
        hasPlant  = false;
        readyProduce.Clear();
        SyncHarvest(false);
    }
コード例 #7
0
//	public FriendlyMeaty CreateFriendlyMeaty(string name) {
//		int temp;
//		//if(isHostile)
//		//	Meaty m = new Meaty ();
//
//
//		return null;
//	}

    //Randomly generates a PlantDataData
    //REQUIRE: PlantDataData must be in the SEED state
    public List <PlantData> CreatePlantDatas()
    {
        string PlantDataFilePath = Path.Combine(Application.streamingAssetsPath, PlantDataFileName);

        //Set up the temp stuff we know ahead of time
        //int temp;
        PlantData p;
        PlantDataRawObjectList pdrol;
        List <PlantData>       Plants = new List <PlantData>();

        if (File.Exists(PlantDataFilePath))
        {
            Debug.Log("in CreatePlantDatas, file exists");
            string PlantDataJSONData = File.ReadAllText(PlantDataFilePath);
            pdrol = JsonUtility.FromJson <PlantDataRawObjectList>(PlantDataJSONData);
            for (int i = 0; i < pdrol.pdata.Count; i++)
            {
                p = PlantData.ObjectFromRaw(pdrol.pdata [i]);
                p.DumpPlant();
                Plants.Add(p);
            }
        }
        else
        {
            Debug.LogError("Error: PlantData data file not found.  Are you missing plantData.json?");
        }
        //TODO: plant data patch file handling here

        return(Plants);
    }
コード例 #8
0
    public void ServerInit()
    {
        if (isSoilPile)
        {
            //only select plants that have valid produce
            plantData = PlantData.CreateNewPlant(DefaultPlantData.PlantDictionary.Values
                                                 .Where(plant => plant.plantData.ProduceObject != null).PickRandom());
            UpdatePlant(null, plantData.Name);
            UpdatePlantStage(PlantSpriteStage.None, PlantSpriteStage.FullyGrown);
            UpdatePlantGrowthStage(growingPlantStage, plantData.GrowthSprites.Count - 1);
            ProduceCrop();
        }
        else
        {
            plantData = null;
            UpdatePlantStage(PlantSpriteStage.None, PlantSpriteStage.FullyGrown);
            UpdatePlant(plantSyncString, null);
            UpdatePlantGrowthStage(growingPlantStage, 0);
        }

        UpdateHarvestFlag(showHarvestFlag, false);
        UpdateWeedsFlag(showWeedsFlag, false);
        UpdateWaterFlag(showWaterFlag, false);
        UpdateNutrimentFlag(showNutrimenetFlag, false);
    }
コード例 #9
0
ファイル: Plant.cs プロジェクト: Spydarlee/Plantasia
    // -------------------------------------------------------------------------------

    public void OnSpawned(Vector3 groundNormal, PlantData plantData, GameObject dirtDecal, Planetoid planetoidOwner, bool spawnedByPlayer)
    {
        if (!Animator)
        {
            Animator = GetComponent <Animator>();
        }

        mWilteredShaderPopertyId = Shader.PropertyToID("_Wilted");
        mPlanetoidOwner          = planetoidOwner;

        mPlantManager     = PlantManager.Instance;
        PlantData         = plantData;
        mMainGrowth       = (1.0f - PlantData.InitialGrowth);
        mBeingHarvested   = false;
        mNormalisedGrowth = 0.0f;
        mGrowthTime       = 0.0f;

        mDirtDecalRenderer = dirtDecal.GetComponent <Renderer>();
        if (spawnedByPlayer)
        {
            LeanTween.scale(mDirtDecalRenderer.gameObject, mDirtDecalRenderer.transform.localScale, 1.0f);
            mDirtDecalRenderer.transform.localScale = Vector3.zero;
            AudioManager.Instance.PlayRandomSfx(MyAudioSource, 0f, "Drop1", "Drop2", "Drop3");
        }
        mDirtDecalRenderer.material.color = Color.Lerp(mPlantManager.DirtDecalUnwateredColor, mPlantManager.DirtDecalWateredColor, Mathf.Clamp01(WaterCharge));

        mSkinnedMeshRenderer = GetComponentInChildren <SkinnedMeshRenderer>();

        PlantType     = plantData.PlantType;
        mNumGrowAnims = plantData.NumGrowthAnims;
        Animator.SetInteger("GrowIndex", Random.Range(0, mNumGrowAnims));

        transform.up = GroundNormal = groundNormal;
        mSkinnedMeshRenderer.material.SetFloat(mWilteredShaderPopertyId, mWilted);
    }
コード例 #10
0
    public void LoadFromPlantData(PlantData pd)
    {
        plantName          = pd.plantName;
        moistureFromSoil   = pd.moisture_required;
        fertilityFromSoil  = pd.soil_fertility;
        photonsRequired    = pd.photonsRequired;
        canTravel          = pd.canTravel;
        plantAnimationFile = pd.plantAnimationFile;
        fruitImageFile     = pd.imageFile;
        plantSeedIconfile  = pd.plantSeedIconFile;
                #if UNITY_STANDALONE
        StartCoroutine(TurnController.LoadSprite(Path.Combine(Application.streamingAssetsPath, plantSeedIconfile), plantSeedIcon, fruitPixelsPerUnit));
                #elif UNITY_ANDROID || UNITY_IOS
        switch (produce.fruitName)
        {
        case "Solar Strawberry": break;

        case "Apogee Apple": break;

        case "Ozone Orange": break;

        case "Lunation Lemon": break;

        case "Waxing Watermelon": break;
        }
                #endif


        //TODO: REWRITE this so we somehow get it out of Streaming Assets
        plantAnimation = Resources.Load(plantAnimationFile) as RuntimeAnimatorController;

        fruitIProduce = Instantiate(smgr.fruitPrefab.gameObject.GetComponent <Fruit>());
        fruitIProduce.LoadFruitFromPlantData(plantName, pd.imageFile, 32.0f);
    }
コード例 #11
0
ファイル: Plant.cs プロジェクト: lovoror/Anbinson-Away
    //Spawn an existing one in the save file (such as after loading)
    public static Plant Spawn(string uid)
    {
        SowedPlantData sdata = PlayerData.Get().GetSowedPlant(uid);

        if (sdata != null)
        {
            PlantData pdata = PlantData.Get(sdata.plant_id);
            if (pdata != null)
            {
                GameObject prefab = pdata.GetStagePrefab(sdata.growth_stage);
                GameObject build  = Instantiate(prefab, sdata.pos, prefab.transform.rotation);
                Plant      plant  = build.GetComponent <Plant>();
                plant.data                = pdata;
                plant.was_built           = true;
                plant.unique_id.unique_id = uid;

                Destructible destruct = plant.GetComponent <Destructible>();
                if (destruct != null)
                {
                    destruct.was_built = true;
                }
                return(plant);
            }
        }
        return(null);
    }
コード例 #12
0
ファイル: OldPlant.cs プロジェクト: dynopa/rewilding
 public void LoadPlant(PlantData data)
 {
     position = data.position;
     type     = (OldPlantType)data.plantType;
     stage    = data.stage;
     if (stage != 1)
     {
         GameObject.Destroy(gameObject.transform.GetChild(0).gameObject);
         GameObject.Instantiate(Resources.Load(type.ToString() + "_" + (stage - 1)), gameObject.transform);
         plantDisplay = gameObject.GetComponentInChildren <MeshRenderer>();
     }
     grown         = data.grown;
     growthPercent = data.growthPercent;
     withering     = data.withering;
     if (growthPercent >= 1.0f)
     {
         growthPercent = 1.0f;
         grown         = true;
     }
     if (grown)
     {
         Services.PlantManager.typeCount[(int)type]++;
         if (type == OldPlantType.Tree)
         {
             Services.PlantManager.CreateNewPylon(position);
         }
     }
     gameObject.transform.localScale = Vector3.Lerp(minSize, maxSize, growthPercent);
 }
コード例 #13
0
    public void OnClickCraft()
    {
        PlayerCharacter player = PlayerCharacter.Get();

        if (player.CanCraft(data))
        {
            ItemData         item      = data.GetItem();
            ConstructionData construct = data.GetConstruction();
            PlantData        plant     = data.GetPlant();

            if (item != null)
            {
                player.CraftItem(item);
            }
            if (construct != null)
            {
                player.SelectCraftConstruction(construct);
            }
            if (plant != null)
            {
                player.CraftPlant(plant);
            }

            craft_btn.interactable = false;
            Hide();
        }
    }
コード例 #14
0
 private void EnsureInit()
 {
     if (defaultPlantData != null)
     {
         plantData = new PlantData();
         plantData.SetValues(defaultPlantData);
     }
 }
コード例 #15
0
        public PlantData Get(int id)
        {
            var       db   = new SmartHomeServiceContext();
            PlantData data = db.PlantDatas.FirstOrDefault(e => e.Id == id);

            data.SensorDataHistory = db.SensorDatas.Where(e => e.SensorId == data.SensorId).ToList();
            return(data);
        }
コード例 #16
0
 private void EnsureInit()
 {
     if (string.IsNullOrEmpty(plantData?.Name) && defaultPlantData != null)
     {
         plantData       = PlantData.CreateNewPlant(defaultPlantData);
         PlantSyncString = plantData.Name;
     }
 }
コード例 #17
0
ファイル: TheData.cs プロジェクト: lovoror/Anbinson-Away
 void Awake()
 {
     _instance = this;
     ItemData.Load(items_folder);
     ConstructionData.Load(constructions_folder);
     PlantData.Load(plants_folder);
     CraftData.Load();
 }
コード例 #18
0
    /// <summary>
    /// Gets a new instance of PlantData based on param
    /// </summary>
    /// <param name="plantData">PlantData to copy</param>
    /// <returns></returns>
    public static PlantData CreateNewPlant(PlantData plantData)
    {
        PlantData newPlant = new PlantData();

        newPlant.SetValues(plantData);
        newPlant.Health = 100;
        newPlant.Age    = 0;
        return(newPlant);
    }
コード例 #19
0
ファイル: StoreItem.cs プロジェクト: dovisj/secretprojectX
 //public Consumable consumable;
 public StoreItem(PlantData plantData)
 {
     itemType       = ItemType.PLANT;
     this.plantData = plantData;
     buyPrice       = plantData.price;
     itemName       = plantData.plantName;
     description    = plantData.description;
     sprite         = plantData.seedSprite;
 }
コード例 #20
0
ファイル: SeedPacket.cs プロジェクト: ynot01/unitystation
 void Start()
 {
     if (defaultPlantData != null)
     {
         plantData = new PlantData();
         plantData.SetValues(defaultPlantData);
     }
     SyncPlant(plantData.Name);
 }
コード例 #21
0
ファイル: Plantable.cs プロジェクト: dumpstertree/Gardening
        public void Plant(Player player, PlantData data)
        {
            var go = Instantiate(data.Prefab);

            go.transform.position = _spawner.position;
            go.transform.rotation = _spawner.rotation;

            _destroyable.Destroy();
        }
コード例 #22
0
        public static void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
        {
            // handle message received
            Console.WriteLine("message=" + Encoding.UTF8.GetString(e.Message));

            string    valuesFromBroker = Encoding.UTF8.GetString(e.Message);
            PlantData _plant           = JsonConvert.DeserializeObject <PlantData>(valuesFromBroker);

            influxClient.WritePoint(_plant);
        }
コード例 #23
0
    public void SetPlant(PlantData plantData)
    {
        if (_plant != null)
        {
            Destroy(_plant.gameObject);
        }

        _plant = Instantiate(plantData.PlantPrefab, _plantTransform);
        _plant.SetGrowAnimationTime(_growth);
    }
コード例 #24
0
    public static PlantData MutateNewPlant(PlantData plantData, PlantTrayModification modification)
    {
        PlantData newPlant = new PlantData();

        newPlant.SetValues(plantData);
        newPlant.Health = 100;
        newPlant.Age    = 0;
        newPlant.NaturalMutation(modification);
        return(newPlant);
    }
コード例 #25
0
ファイル: GrownFood.cs プロジェクト: Basipek/unitystation
 /// <summary>
 /// Called when plant creates food
 /// </summary>
 public void SetUpFood(PlantData newPlantData, PlantTrayModification modification)
 {
     plantData = PlantData.MutateNewPlant(newPlantData, modification);
     SyncSize(SizeScale, 0.5f + (newPlantData.Potency / 200f));
     SetupChemicalContents();
     if (edible != null)
     {
         SetupEdible();
     }
 }
コード例 #26
0
 public void Setup(PlantData plantData)
 {
     plantSData = GameDataManager.instance.GetPlantSData(plantData.plantName);
     ResourceManager.instance.GetPlantSpriteAOH(plantSData.plantName).Completed += aoh =>
     {
         plantImage.sprite = aoh.Result as Sprite;
     };
     plantName.SetText($"{plantSData.plantName}");
     beautyPointText.SetText($"+{plantSData.prestigePoint:0} PRESTIGEPOINTS");
     countText.SetText($"{plantData.count}");
 }
コード例 #27
0
    // Use this for initialization
    void Start()
    {
        enemiesInRange = new List <GameObject>();
        lastShotTime   = Time.time;
        monsterData    = gameObject.GetComponentInChildren <PlantData> ();

        if (!PersistantManager.IsAmbientEnabled())
        {
            GetComponent <AudioSource>().enabled = false;
        }
    }
コード例 #28
0
    public PlantInstance(PlantData plantData)
    {
        data = plantData;

        fuel     = plantData.GetInitialFuel();
        scale    = plantData.GetScale(fuel);
        burnRate = plantData.GetBurnRate();

        currentState  = PlantState.Default;
        previousState = currentState;
    }
コード例 #29
0
    public void Init(PlantData plantData)
    {
        _plantData = plantData;

        // _plantImage.sprite = plantData.Sprite; TODO: implement new plant choice panel

        button.onClick.AddListener(delegate {
            Debug.Log("Plant chosen: " + _plantData.Name);
            ApplicationManager.Instance.SelectPlant(_plantData);
        });
    }
コード例 #30
0
        public PointData ConvertToInflux(PlantData plant)
        {
            var point = PointData.Measurement("Fern")
                        .Tag("Device ID", plant.DeviceId)
                        .Field("Temperature", plant.TemperatureC)
                        .Field("Soil Humidity", plant.SoilHumidity)
                        .Field("Humidity Level", plant.Humidity)
                        .Timestamp(DateTime.UtcNow, WritePrecision.S);

            return(point);
        }