示例#1
0
        public override void OnCanceled()
        {
            Farm.FarmTile tile = Creature.AI.Blackboard.GetData <Farm.FarmTile>("ClosestTile");

            if (tile != null)
            {
                tile.Farmer = null;
            }

            base.OnCanceled();
        }
示例#2
0
 public IEnumerable <Status> GetClosestTile()
 {
     Farm.FarmTile closestTile = FarmToWork.GetNearestFreeFarmTile(Creature.AI.Position);
     if (closestTile == null)
     {
         yield return(Status.Fail);
     }
     else
     {
         closestTile.Farmer = Agent;
         Creature.AI.Blackboard.SetData("ClosestTile", closestTile);
         Creature.AI.Blackboard.SetData("ClosestVoxel", closestTile.Vox);
         yield return(Status.Success);
     }
 }
示例#3
0
        public override void Initialize()
        {
            if (FarmToWork != null)
            {
                Farm.FarmTile closestTile = FarmToWork.GetNearestFreeFarmTile(Creature.AI.Position);
                if (closestTile != null)
                {
                    Tree = new Sequence(
                        new Wrap(GetClosestTile),
                        new GoToVoxelAct("ClosestVoxel", PlanAct.PlanType.Adjacent, Creature.AI),
                        new StopAct(Creature.AI),
                        new Wrap(() => FarmATile("ClosestTile")));
                }
            }

            base.Initialize();
        }
示例#4
0
        public IEnumerable <Status> FarmATile(string tileName)
        {
            Farm.FarmTile tile = Creature.AI.Blackboard.GetData <Farm.FarmTile>(tileName);
            if (tile == null)
            {
                yield return(Status.Fail);
            }
            else if (tile.PlantExists())
            {
                tile.Farmer = null;
                yield return(Status.Success);
            }
            else
            {
                if (tile.Plant != null && tile.Plant.IsDead)
                {
                    tile.Plant = null;
                }
                while (tile.Progress < 100.0f && !tile.PlantExists())
                {
                    Creature.CurrentCharacterMode = Creature.CharacterMode.Attacking;
                    Creature.Physics.Velocity    *= 0.1f;
                    tile.Progress += Creature.Stats.BaseFarmSpeed;

                    Drawer2D.DrawLoadBar(Agent.Position + Vector3.Up, Color.White, Color.Black, 100, 16,
                                         tile.Progress / 100.0f);
                    if (tile.Progress >= 100.0f && !tile.PlantExists())
                    {
                        tile.Progress = 0.0f;
                        FarmToWork.CreatePlant(tile);
                    }

                    yield return(Status.Running);
                }
                Creature.CurrentCharacterMode = Creature.CharacterMode.Idle;
                Creature.AI.AddThought(Thought.ThoughtType.Farmed);
                Creature.AI.AddXP(10);
                tile.Farmer = null;
                yield return(Status.Success);
            }
        }