Esempio n. 1
0
    public override IEnumerator RunJobCoroutine(ElveBehavior elve)
    {
        yield return null;

        elveMovement = elve.GetComponent<ElveMovementController>();

        //Move to the target.
        if (!elveMovement.StartPath(PlantPos))
        {
            StopJob(true, "Path is blocked");
            yield break;
        }
        while (!elveMovement.IsPathCompleted)
            yield return null;

        //Plant the seed.
        Assert.IsNull(elve.CurrentState);
        elve.CurrentState = new ElveState_UseMagic(elve, JobConstants.Instance.TimeToPlantSeed,
                                                   ElveBehavior.Surfaces.Floor);
        while (elve.CurrentState != null)
            yield return null;

        //Stop the job before creating the seed.
        //Otherwise, the changing of that voxel will cause this job to cancel itself.
        StopJob(false);

        WorldVoxels.Instance.SetVoxelAt(PlantPos, SeedType);
        SeedManager.Instance.Seeds.Add(new SeedManager.SeedData(PlantPos, GrowPattern));
    }
Esempio n. 2
0
    public override void StopJob(bool moveJobToQueue, string reason = null)
    {
        base.StopJob(moveJobToQueue, reason);

        //Destroy the UI widget.
        Assert.IsNotNull(uiWidget);
        GameObject.Destroy(uiWidget);

        Assert.IsNotNull(elveMovement);

        //The Elve is either planting the seed or moving to the planting location.
        ElveBehavior elve = elveMovement.GetComponent<ElveBehavior>();
        if (elve.CurrentState is ElveState_UseMagic)
        {
            elve.CurrentState = null;
        }
        else
        {
            elveMovement.CancelPath();
        }

        elveMovement = null;
    }
Esempio n. 3
0
 private static void DummyFunc(ElveMovementController e)
 {
 }