Beispiel #1
0
 public void pointerExit()
 {
     if (!PlantManager.get().isSelected())
     {
         PlantManager.get().buttonDescription(null);
     }
 }
Beispiel #2
0
 void Awake()
 {
     if (plantManager == null)
     {
         plantManager = GetComponent <PlantManager>();
     }
 }
Beispiel #3
0
    public void OnEnable()
    {
        GameObject   gameManager  = GameObject.Find("GameManager");
        PlantManager plantManager = gameManager.GetComponent <PlantManager>();

        prevIndexNum = -1; //trigger a new clone
    }
Beispiel #4
0
    [SetUp] //called at the start of each test
    public void Setup()
    {
        pmanager = GameObject.Find("GameManager").GetComponent <PlantManager>();

        pmanager.prefabMappings.Clear();
        pmanager.allPrefabs.Clear();


        pmanager.activePlants = new GameObject[pmanager.maxActivePlants];

        pmanager.allPrefabs.Add("Aloe");
        pmanager.allPrefabs.Add("Jade");
        pmanager.allPrefabs.Add("Echeveria");
        pmanager.allPrefabs.Add("Basic Plant");

        int i = 0;

        foreach (string prefab in pmanager.allPrefabs)
        {
            GameObject plant = (GameObject)Resources.Load(PlantManager.prefabPath + prefab);
            pmanager.prefabMappings.Add(prefab, plant);

            GameObject testPlant = pmanager.MakePlant("tester" + i.ToString(), prefab);

            if (i < pmanager.maxActivePlants)
            {
                pmanager.SetPlantStatus(testPlant, true);
            }
            plantRates.Add(testPlant.GetComponent <PlantRates>());

            i++;
        }
    }
Beispiel #5
0
    public void randomGeneration(float pBouleau = 0.03f, float pSapin = 0.015f)
    {
        for (int i = 0; i < size; ++i)
        {
            for (int j = 0; j < size; ++j)
            {
                GameObject tree = null;
                if (pBouleau >= Main.random())
                {
                    tree = grid[i, j].insert(PlantManager.get().bouleau);
                }
                else if (pSapin >= Main.random())
                {
                    tree = grid[i, j].insert(PlantManager.get().sapin);
                }

                if (tree != null)
                {
                    tree.GetComponent <ArbreDefaut>().setAge((0.4f + 0.7f * Main.random()) * 450.0f);
                }
            }
        }

        for (int i = 0; i < 40; ++i)
        {
            updateCases();
        }
    }
Beispiel #6
0
    public void finishUpdate()
    {
        luminosite = (luminosite * 2 + tmpLuminosite) / 3;
        humidite   = (humidite * 5 + tmpHumidite) / 6;
        fertilite  = (fertilite * 9 + tmpFertilite) / 10;

        // Apparition de fleurs, etc...
        int   nbPlants = PlantManager.get().getNbPlants();
        float l        = getLuminosite();
        float h        = getHumidite();
        float f        = getFertilite();

        for (int i = 0; i < nbPlants; ++i)
        {
            Plant p = PlantManager.get().getPlant(i);
            if (p.toss(l, h, f))
            {
                insert(p);
                //Main.msgApparitionFleur();

                if (i == 9)
                {
                    Main.msgPolypore();
                }
            }
        }

        tmpLuminosite = 0;
        tmpHumidite   = 0;
        tmpFertilite  = 0;
    }
Beispiel #7
0
    void Awake()
    {
        if (gm == null)
        {
            gm = this;
        }
        else if (gm != this)
        {
            if (isMain)
            {
                Destroy(gm);
                gm = this;
            }
            else
            {
                Destroy(gameObject);
            }
        }

        isMain = true;

        nm = GetComponent <NetworkManager> ();
        pm = GetComponent <PlantManager> ();
        wd = GetComponent <WorldSerialization> ();
        zd = GetComponent <ZoneAndDoorManager> ();
        gc = GetComponent <GeneticCrossing> ();
    }
Beispiel #8
0
    public void OnEnable()
    {
        GameObject   plantCollectionHolder = GameObject.Find("GameManager");
        PlantManager plantManager          = plantCollectionHolder.GetComponent <PlantManager>();

        plantList = plantManager.plantCollection;
    }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        instance      = this;
        cursorPlant   = null;
        selectedPlant = null;

        icons = new GameObject[w, h];
        for (int i = 0; i < w; ++i)
        {
            for (int j = 0; j < h; ++j)
            {
                icons[i, j] = null;
            }
        }

        // Tests
        addToPanel(sapin);
        addToPanel(saule);
        addToPanel(hetre);
        addToPanel(bouleau);
        addToPanel(chene);

        /*
         * addToPanel( fougere );
         * addToPanel( herbe );
         * addToPanel( marguerite );
         * addToPanel( lin );
         * addToPanel( cepe );
         * addToPanel( tricholome );
         * addToPanel( amanite );
         */
    }
Beispiel #10
0
 private void Awake()
 {
     instance = this;
     endGamePanel.SetActive(false);
     bulb       = GetComponentInChildren <BulbGraphics>();
     isGameOver = false;
 }
Beispiel #11
0
        public PlantEditViewModel()
        {
            _plantManager = new PlantManager();
            _noteManager  = new NoteManager();

            MessagingCenter.Subscribe <PlantViewModel, Plant>(this, "EditPlant", async(message, args) =>
            {
                _selectedPlant = args;
                Name           = _selectedPlant.Name;

                var notesResult = await _noteManager.GetNote((int)NoteType.Plant, _selectedPlant.ID);
                Notes           = notesResult == null ? string.Empty : notesResult.Notes;

                GetVarieties();

                IsNewVarietyButtonVisible = true;
            });

            MessagingCenter.Subscribe <VarietyEditViewModel>(this, "VarietyChanged", (message) => {
                GetVarieties();
            });

            MessagingCenter.Subscribe <VarietyEditViewModel>(this, "VarietyUnchanged", (message) => {
                SelectedItem = null;
            });
        }
Beispiel #12
0
    // -------------------------------------------------------------------------------

    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);
    }
Beispiel #13
0
    public void SwapPlant(int index)
    {
        //show the 3 active plants in collection to swap with
        PlantManager plantManager = GetComponent <PlantManager>();

        popUpCanvas.GetComponent <PopUp>().PopUpSelectPlant(plantManager.GetActivePlantIndexes());
        selectingPlant = index;
    }
Beispiel #14
0
    public void onClick()
    {
        Main.msgButtonPlant();

        PlantManager.get().setSelectedPlant(plant);

        PlantManager.get().buttonDescription(plant);
    }
Beispiel #15
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        SelectedPlant = plants[0];
    }
Beispiel #16
0
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("more than one PlantManager in scene!");
         return;
     }
     instance = this;
 }
Beispiel #17
0
 void Start()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
         return;
     }
     Instance = this;
     DontDestroyOnLoad(gameObject);
 }
Beispiel #18
0
 public void CloudStartup(RainColor _rainColor, float[,] _area, int _xOffset, int _yOffset, float duration)
 {
     area      = _area;
     rainColor = _rainColor;
     timeLeft  = duration;
     xOffset   = _xOffset;
     yOffset   = _yOffset;
     plants    = PlantManager.GetPlantsInArea(area, xOffset, yOffset);
     plants.ForEach((plant) => plant.AddRain(rainColor));
 }
Beispiel #19
0
    public override void OnInspectorGUI()
    {
        PlantManager myObject = (PlantManager)target;

        DrawDefaultInspector();
        if (GUILayout.Button("Attribute Plant Indexes"))
        {
            myObject.InitializePlantInfoTab();
        }
    }
Beispiel #20
0
    void PlantSeed()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            PlantManager.PlantSeedAtPoint(hit);
        }
    }
Beispiel #21
0
    // Start is called before the first frame update
    void Start()
    {
        count = 0;
        if (plantManager == null)
        {
            plantManager = this;
        }

        plantList = new Dictionary <Vector3, GameObject>();
    }
Beispiel #22
0
 private void Start()
 {
     playerInventory        = ClassManager.instance.playerInventory;
     groundTileManager      = ClassManager.instance.groundTileManager;
     selectedTileController = ClassManager.instance.selectedTileController;
     sfxPlayer    = ClassManager.instance.sfxPlayer;
     plantManager = ClassManager.instance.plantManager;
     ageManager   = ClassManager.instance.ageManager;
     foodManager  = ClassManager.instance.foodManager;
     shopManager  = ClassManager.instance.shopManager;
 }
Beispiel #23
0
    // -------------------------------------------------------------------------------

    void Awake()
    {
        Instance = this;

        foreach (var plantData in PlantDataList)
        {
            mPlantDataDict.Add(plantData.PlantType, plantData);
        }

        mPlantLayerId = LayerMask.NameToLayer("Plants");
    }
Beispiel #24
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
Beispiel #25
0
    public void update(PlantManager pm)
    {
        if (!Menu.running)
        {
            return;
        }

        timer += 6 * Time.deltaTime;

        Vector3 newPos = new Vector3(0f, 0f);

        newPos.x = Mathf.Cos((timer * Mathf.PI) / 180f) * 1.5f;
        newPos.y = Mathf.Sin((timer * Mathf.PI) / 180f) * 1.5f;

        transform.position = newPos;
        skyColor(); triggers();

        if (timer > 270)
        {
            timer     = -90f;
            day       = !day;
            dayNum   += 0.5f;
            days.text = "Day: " + dayNum;

            sm.update(dayNum);
            wm.cycle(sm.getSeason());

            if (day)
            {
                bm.newDawn(sm.getSeason(), wm.getWeather(), pm.getPlants());
                saveManager.save();
            }
            else
            {
                bm.newDusk(sm.getSeason(), wm.getWeather(), pm.getPlants());
            }

            beastTrigger = true;
        }

        else if (timer > 90 && beastTrigger)
        {
            beastTrigger = false;
            if (day)
            {
                bm.newDay(sm.getSeason(), wm.getWeather(), pm.getPlants());
            }
            else
            {
                bm.newNight(sm.getSeason(), wm.getWeather(), pm.getPlants());
            }
        }
    }
Beispiel #26
0
    // Use this for initialization
    protected virtual void Awake()
    {
        setHealth(maxHealth);
        setGrowth(0);
        setThirst(maxThirst);
        setSunlight(maxSun);
        setHappiness(maxHappiness);

        coinText.text = "+$" + coinage;
        nameText.text = Name;

        pm   = FindObjectOfType <PlantManager>();
        anim = GetComponent <Animator>();
    }
Beispiel #27
0
        public PlantViewModel()
        {
            _plantManager = new PlantManager();

            MessagingCenter.Subscribe <PlantEditViewModel>(this, "PlantChanged", (message) =>
            {
                GetPlants();
            });

            MessagingCenter.Subscribe <PlantEditViewModel>(this, "PlantUnchanged", (message) =>
            {
                SelectedItem = null;
            });
        }
Beispiel #28
0
    public void Init(PlantManager _manager)
    {
        manager = _manager;

        transform.parent = manager.transform;

        timeSpent = TimeToGrow;

        Seedlevel.SetActive(true);
        SapplingLevel.SetActive(false);
        AlmostFlowerLevel.SetActive(false);
        Flower.SetActive(false);

        dryWetAxis = WetLevel.transform.position - DryLevel.transform.position;
        ActualWaterLevel.transform.position = DryLevel.transform.position + dryWetAxis * waterPercentage;
    }
Beispiel #29
0
    void RemoveInfection()
    {
        if (stance == PlantStance.friendly)
        {
            // get neighbours
            PlantBase[] neighbours = PlantManager.Get8NeighboursForPosition(gridPos);
            for (int i = 0; i < neighbours.Length; i++)
            {
                // can't have null plants
                if (neighbours [i] == null)
                {
                    continue;
                }

                neighbours [i].ClearInfection();
            }
        }
    }
Beispiel #30
0
 private void setClasses()
 {
     inputManager           = gameObject.GetComponent <InputManager>();
     ageManager             = gameObject.GetComponent <AgeManager>();
     farmerMovement         = farmerObject.GetComponent <FarmerMovement>();
     playerInventory        = farmerObject.GetComponent <PlayerInventory>();
     spriteManager          = gameObject.GetComponent <SpriteManager>();
     prefabManager          = gameObject.GetComponent <PrefabManager>();
     dropItem               = farmerObject.GetComponent <DropItem>();
     selectedTileController = farmerObject.GetComponent <SelectedTileController>();
     useItem           = farmerObject.GetComponent <UseItem>();
     groundTileManager = gameObject.GetComponent <GroundTileManager>();
     plantManager      = gameObject.GetComponent <PlantManager>();
     foodManager       = gameObject.GetComponent <FoodManager>();
     shopManager       = gameObject.GetComponent <ShopManager>();
     farmerAnimator    = farmerObject.GetComponent <Animator>();
     sfxPlayer         = soundObject.GetComponent <SfxPlayer>();
 }