예제 #1
0
    public void init(Seed seedInfo, GardenCrop gardenCrop, GameControl gc, bool onPlant)
    {
        base.init(seedInfo, gardenCrop, gc, onPlant);

        G_PlanesMesh.GetComponent <MeshRenderer>().material.mainTextureOffset = new Vector2(0f, 0);

        G_PlanesMesh.GetComponent <MeshRenderer>().materials = new Material[1] {
            planesMat
        };
        G_ProduceMesh.GetComponent <MeshRenderer>().materials = new Material[1] {
            produceMat
        };
    }
예제 #2
0
    public void tryPlantSeed(Vector3 plantPos)
    {
        if (!isPlantingSeed)
        {
            return;
        }

        GameObject Map = GameObject.FindGameObjectWithTag("Map");

        Vector3 plantPosLocal = plantPos / Map.transform.localScale.x;

        RaycastHit hit;
        int        layerMask = 1 << LayerMask.NameToLayer("House") | 1 << LayerMask.NameToLayer("FarmPlot");

        if (Physics.SphereCast(plantPosLocal + (Vector3.up * 50), 6.5f * Map.transform.localScale.x, Vector3.down, out hit, 1000, layerMask))
        {
            queueRewardText("Something is blocking!", new Color(0.8f, 0.5f, 0.5f));
            return;
        }

        queueRewardText("Planted seed!", new Color(0.8f, 0.5f, 0.5f));

        GameObject farmPlot = Instantiate(P_FarmPlots[(int)seedToPlant.seedType], plantPosLocal + (Vector3.up * 0.4f), Quaternion.identity);

        farmPlot.transform.SetParent(Map.transform, false);
        farmPlot.transform.localScale = Vector3.one;

        string longLat = VectorExtensions.GetGeoPosition(
            farmPlot.transform.position,
            Map.GetComponent <BasicMap>().CenterMercator,
            Map.GetComponent <BasicMap>().WorldRelativeScale
            ).ToString();

        GardenCrop newCrop = new GardenCrop(seedToPlant.seedType, DateTime.Now.Ticks, longLat);

        PetKeeper.pet.Base.gardenCrops.Add(newCrop);

        farmPlot.GetComponent <FarmPlot>().init(seedToPlant, newCrop, this, true);

        PetKeeper.pet.inventory.seedCounts[(int)seedToPlant.seedType] -= 1;

        InventoryUI.reRender = true;

        PetKeeper.pet.Save(false);

        if (PetKeeper.pet.inventory.seedCounts[(int)seedToPlant.seedType] <= 0)
        {
            exitModePressed();
        }
    }
예제 #3
0
파일: FarmPlot.cs 프로젝트: DigohD/Augotchi
    public virtual void init(Seed seedInfo, GardenCrop gardenCrop, GameControl gc, bool onPlant)
    {
        if (onPlant)
        {
            delayedSpawnTime = 0;
        }
        else
        {
            delayedSpawnTime = UnityEngine.Random.Range(0.5f, 1.5f);
        }

        Debug.Log("FARMTIME " + seedInfo.growthTime);
        initialGrowthTime = seedInfo.growthTime;

        long growthTimeTicks   = TimeSpan.TicksPerSecond * seedInfo.growthTime;
        long finishedTimeStamp = gardenCrop.plantedTimeStamp + growthTimeTicks;

        if (DateTime.Now.Ticks > finishedTimeStamp)
        {
            T_FinishedLabel.gameObject.SetActive(true);
        }
        else
        {
            TimeSpan diff = new TimeSpan(DateTime.Now.Ticks - finishedTimeStamp);
            timeLeft = diff.Duration();

            T_TimerLabel.gameObject.SetActive(true);

            setLabel();
        }

        representedCrop = gardenCrop;

        cameraT = GameObject.FindGameObjectWithTag("MainCamera").transform.parent;

        this.gc = gc;

        timer = 0;
    }