コード例 #1
0
 public void growing()
 {
     if (season.Equals(timeManager.getSeason().ToString()))
     {
         if (timeManager.getDay() >= dayToS1)
         {
             state = Crops.cropStates.ST1;
             this.gameObject.GetComponent <Renderer> ().sharedMaterials = M_ST1;
             this.GetComponent <MeshFilter> ().sharedMesh = MF_ST1.sharedMesh;
         }
         if (timeManager.getDay() >= dayToS2)
         {
             this.gameObject.GetComponent <Renderer> ().sharedMaterials = M_ST2;
             state = Crops.cropStates.ST2;
             this.GetComponent <MeshFilter> ().sharedMesh = MF_ST2.sharedMesh;
         }
         if (timeManager.getDay() >= dayToHarvest)
         {
             state = Crops.cropStates.HARVEST;
             this.gameObject.GetComponent <Renderer> ().sharedMaterials = M_HARVEST;
             this.GetComponent <MeshFilter> ().sharedMesh = MF_HARVEST.sharedMesh;
             collision = this.gameObject.AddComponent(typeof(CropCollision)) as CropCollision;
         }
     }
     else
     {
         this.gameObject.GetComponent <Renderer> ().material = dryCrop;
     }
 }
コード例 #2
0
    public void growingTree()
    {
        if (daysToNextStage < 0)
        {
            daysToNextStage = 0;
        }

        if (daysToNextStage <= 0 && state.Equals(Crops.cropStates.SEED))
        {
            daysToNextStage = dayToS2;
            state           = Crops.cropStates.ST1;
            this.gameObject.GetComponent <Renderer> ().sharedMaterials = M_ST1;
            this.GetComponent <MeshFilter> ().sharedMesh = MF_ST1.sharedMesh;
            col.sharedMesh = MF_ST1.sharedMesh;
            col.convex     = true;
        }
        else if (daysToNextStage <= 0 && state.Equals(Crops.cropStates.ST1))
        {
            daysToNextStage = dayToHarvest;
            state           = Crops.cropStates.ST2;
            this.gameObject.GetComponent <Renderer> ().sharedMaterials = M_ST2;
            this.GetComponent <MeshFilter> ().sharedMesh = MF_ST2.sharedMesh;
            col.sharedMesh = MF_ST2.sharedMesh;
            col.convex     = true;
        }
        else if (daysToNextStage <= 0 && state.Equals(Crops.cropStates.ST2) && season.Equals(timeManager.getSeason().ToString()))
        {
            daysToNextStage = dayToHarvest;
            state           = Crops.cropStates.HARVEST;
            this.gameObject.GetComponent <Renderer> ().sharedMaterials = M_HARVEST;
            this.GetComponent <MeshFilter> ().sharedMesh = MF_HARVEST.sharedMesh;
            col.sharedMesh = MF_HARVEST.sharedMesh;
            col.convex     = true;
            collision      = this.gameObject.AddComponent(typeof(TreeCollision)) as TreeCollision;
        }
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        soil        = FindObjectOfType(typeof(CreateSoil)) as CreateSoil;
        allS        = soil.allSquares;
        crops       = FindObjectOfType <MockCropDB> ();
        timeManager = FindObjectOfType <TimeManager> ();
        state       = Crops.cropStates.SEED;
        col         = this.gameObject.AddComponent(typeof(MeshCollider)) as MeshCollider;
        col.convex  = true;
        if (this.gameObject.name.Contains("cherryseeds"))
        {
            treeName        = crops.cherry.name;
            treeDescription = crops.cherry.description;
            daysToNextStage = crops.cherry.daysToStage1;
            dayToS1         = crops.cherry.daysToStage1;
            dayToS2         = crops.cherry.daysToStage2;
            dayToHarvest    = crops.cherry.daysToHarvest;
            season          = crops.cherry.season;
            staminaRecovery = crops.cherry.staminaRecovery;
            code            = crops.cherry.code;
            price           = crops.cherry.price;
        }
        else if (this.gameObject.name.Contains("peachseeds"))
        {
            treeName        = crops.peach.name;
            treeDescription = crops.peach.description;
            daysToNextStage = crops.peach.daysToStage1;
            dayToS1         = crops.peach.daysToStage1;
            dayToS2         = crops.peach.daysToStage2;
            dayToHarvest    = crops.peach.daysToHarvest;
            season          = crops.peach.season;
            staminaRecovery = crops.peach.staminaRecovery;
            code            = crops.peach.code;
            price           = crops.peach.price;
        }
        else if (this.gameObject.name.Contains("appleseeds"))
        {
            treeName        = crops.apple.name;
            treeDescription = crops.apple.description;
            daysToNextStage = crops.apple.daysToStage1;
            dayToS1         = crops.apple.daysToStage1;
            dayToS2         = crops.apple.daysToStage2;
            dayToHarvest    = crops.apple.daysToHarvest;
            season          = crops.apple.season;
            staminaRecovery = crops.apple.staminaRecovery;
            code            = crops.apple.code;
            price           = crops.apple.price;
        }
        else if (this.gameObject.name.Contains("orangeseeds"))
        {
            treeName        = crops.orange.name;
            treeDescription = crops.orange.description;
            daysToNextStage = crops.orange.daysToStage1;
            dayToS1         = crops.orange.daysToStage1;
            dayToS2         = crops.orange.daysToStage2;
            dayToHarvest    = crops.orange.daysToHarvest;
            season          = crops.orange.season;
            staminaRecovery = crops.orange.staminaRecovery;
            code            = crops.orange.code;
            price           = crops.orange.price;
        }

        M_ST1     = Resources.Load <Renderer> ("Trees/" + treeName + "Tree/" + treeName + "ST1").sharedMaterials;
        M_ST2     = Resources.Load <Renderer> ("Trees/" + treeName + "Tree/" + treeName + "ST2").sharedMaterials;
        M_HARVEST = Resources.Load <Renderer> ("Trees/" + treeName + "Tree/" + treeName + "ST3").sharedMaterials;

        MF_ST1     = Resources.Load <MeshFilter> ("Trees/" + treeName + "Tree/" + treeName + "ST1");
        MF_ST2     = Resources.Load <MeshFilter> ("Trees/" + treeName + "Tree/" + treeName + "ST2");
        MF_HARVEST = Resources.Load <MeshFilter> ("Trees/" + treeName + "Tree/" + treeName + "ST3");
    }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        soil        = FindObjectOfType(typeof(CreateSoil)) as CreateSoil;
        allS        = soil.allSquares;
        crops       = FindObjectOfType <MockCropDB> ();
        timeManager = FindObjectOfType <TimeManager> ();
        dayPlanted  = (int)timeManager.getDay();
        state       = Crops.cropStates.SEED;

        dryCrop = Resources.Load <Material> ("Materials/mockcrops/Dry");
        this.gameObject.transform.Rotate(-90, 0, 0);

        if (this.gameObject.name.Contains("turnipseeds"))
        {
            cropName        = crops.turnip.getName();
            staminaRecovery = crops.turnip.staminaRecovery;
            cropDescription = crops.turnip.getDescription();
            dayToS1         = dayPlanted + crops.turnip.getS1Days();
            dayToS2         = dayToS1 + crops.turnip.getS2Days();
            dayToHarvest    = dayToS2 + crops.turnip.getHarvestDays();
            season          = crops.turnip.getSeason();
            code            = crops.turnip.code;
            price           = crops.turnip.price;
        }
        else if (this.gameObject.name.Contains("cabbageseeds"))
        {
            cropName        = crops.cabbage.getName();
            staminaRecovery = crops.cabbage.staminaRecovery;
            cropDescription = crops.cabbage.getDescription();
            dayToS1         = dayPlanted + crops.cabbage.getS1Days();
            dayToS2         = dayToS1 + crops.cabbage.getS2Days();
            dayToHarvest    = dayToS2 + crops.cabbage.getHarvestDays();
            season          = crops.cabbage.getSeason();
            code            = crops.cabbage.code;
            price           = crops.cabbage.price;
        }
        else if (this.gameObject.name.Contains("carrotseeds"))
        {
            cropName        = crops.carrot.getName();
            staminaRecovery = crops.carrot.staminaRecovery;
            cropDescription = crops.carrot.getDescription();
            dayToS1         = dayPlanted + crops.carrot.getS1Days();
            dayToS2         = dayToS1 + crops.carrot.getS2Days();
            dayToHarvest    = dayToS2 + crops.carrot.getHarvestDays();
            season          = crops.carrot.getSeason();
            code            = crops.carrot.code;
            price           = crops.carrot.price;
        }
        else if (this.gameObject.name.Contains("onionseeds"))
        {
            cropName        = crops.onion.getName();
            staminaRecovery = crops.onion.staminaRecovery;
            cropDescription = crops.onion.getDescription();
            dayToS1         = dayPlanted + crops.onion.getS1Days();
            dayToS2         = dayToS1 + crops.onion.getS2Days();
            dayToHarvest    = dayToS2 + crops.onion.getHarvestDays();
            season          = crops.onion.getSeason();
            code            = crops.onion.code;
            price           = crops.onion.price;
        }
        else if (this.gameObject.name.Equals("radishseeds(Clone)"))
        {
            cropName        = crops.radish.getName();
            staminaRecovery = crops.radish.staminaRecovery;
            cropDescription = crops.radish.getDescription();
            dayToS1         = dayPlanted + crops.radish.getS1Days();
            dayToS2         = dayToS1 + crops.radish.getS2Days();
            dayToHarvest    = dayToS2 + crops.radish.getHarvestDays();
            season          = crops.radish.getSeason();
            code            = crops.radish.code;
            price           = crops.radish.price;
        }
        else if (this.gameObject.name.Contains("spinachseeds"))
        {
            cropName        = crops.spinach.getName();
            staminaRecovery = crops.spinach.staminaRecovery;
            cropDescription = crops.spinach.getDescription();
            dayToS1         = dayPlanted + crops.spinach.getS1Days();
            dayToS2         = dayToS1 + crops.spinach.getS2Days();
            dayToHarvest    = dayToS2 + crops.spinach.getHarvestDays();
            season          = crops.spinach.getSeason();
            code            = crops.spinach.code;
            price           = crops.spinach.price;
        }
        else if (this.gameObject.name.Contains("daikon radishseeds"))
        {
            cropName        = crops.daikonRadish.getName();
            staminaRecovery = crops.daikonRadish.staminaRecovery;
            cropDescription = crops.daikonRadish.getDescription();
            dayToS1         = dayPlanted + crops.daikonRadish.getS1Days();
            dayToS2         = dayToS1 + crops.daikonRadish.getS2Days();
            dayToHarvest    = dayToS2 + crops.daikonRadish.getHarvestDays();
            season          = crops.daikonRadish.getSeason();
            code            = crops.daikonRadish.code;
            price           = crops.daikonRadish.price;
        }
        else if (this.gameObject.name.Contains("broccoliseeds"))
        {
            cropName        = crops.broccoli.getName();
            staminaRecovery = crops.broccoli.staminaRecovery;
            cropDescription = crops.broccoli.getDescription();
            dayToS1         = dayPlanted + crops.broccoli.getS1Days();
            dayToS2         = dayToS1 + crops.broccoli.getS2Days();
            dayToHarvest    = dayToS2 + crops.broccoli.getHarvestDays();
            season          = crops.broccoli.getSeason();
            code            = crops.broccoli.code;
            price           = crops.broccoli.price;
        }

        M_ST1     = Resources.Load <Renderer> ("Crops/" + cropName + "/" + cropName + "ST1").sharedMaterials;
        M_ST2     = Resources.Load <Renderer> ("Crops/" + cropName + "/" + cropName + "ST2").sharedMaterials;
        M_HARVEST = Resources.Load <Renderer> ("Crops/" + cropName + "/" + cropName + "ST3").sharedMaterials;

        MF_ST1     = Resources.Load <MeshFilter> ("Crops/" + cropName + "/" + cropName + "ST1");
        MF_ST2     = Resources.Load <MeshFilter> ("Crops/" + cropName + "/" + cropName + "ST2");
        MF_HARVEST = Resources.Load <MeshFilter> ("Crops/" + cropName + "/" + cropName + "ST3");
    }