示例#1
0
 public void Setup(CropConfig config)
 {
     _sprites = config.Sprites;
     // _timeToGrow = config.TimeToGrow;
     _produces = config.Produces;
     _season   = config.Season;
 }
示例#2
0
        /*
         *  Construction
         */
        public void SetBuilds(TypeOfThing type)
        {
            var config = Assets.GetThingConfig(type);

            Builds   = config.ConstructionConfig.Builds;
            Requires = config.ConstructionConfig.Requires;
        }
示例#3
0
 public Construction(Game game, Thing thing, TypeOfThing?buildOn, TypeOfThing builds, ConstructionGroup group, TypeOfThing requires)
 {
     _buildOn  = buildOn;
     _builds   = builds;
     _thing    = thing;
     _game     = game;
     _group    = group;
     _requires = requires;
 }
示例#4
0
        public GetThing(GOAPAgent agent, Game game, Thing thing, Movement movement, TypeOfThing resource) : base(agent, game, movement)
        {
            _thing     = thing;
            _movement  = movement;
            _resource  = resource;
            _inventory = _thing.Inventory;

            Preconditions.Add(Effect.HAS_THING, TypeOfThing.None);
            Effects.Add(Effect.HAS_THING, resource);
        }
示例#5
0
        public Construct(GOAPAgent agent, Game game, Movement movement, TypeOfThing resource, Thing thing) : base(agent, game, movement)
        {
            Goal = GOAPGoal.Goal.IS_WORKING;

            _movement  = movement;
            _resource  = resource;
            _thing     = thing;
            _inventory = _thing.Inventory;

            Preconditions.Add(GOAPAction.Effect.HAS_THING, resource);
        }
示例#6
0
    public static Thing Create(TypeOfThing typeOfThing, int x, int y)
    {
        var id         = Guid.NewGuid().ToString();
        var config     = GetThingConfig(typeOfThing);
        var gameObject = new GameObject($"{typeOfThing}_{id}");
        var thing      = gameObject.AddComponent <Thing>();

        thing.transform.position = new Vector3(x, y);
        thing.id = id;
        thing.Setup(config);
        return(thing);
    }
示例#7
0
    public FillStorage(GOAPAgent agent, Game game, Movement movement, Inventory inventory, TypeOfThing type) : base(agent, game, movement)
    {
        _movement  = movement;
        _inventory = inventory;
        _type      = type;

        var thingConfig = Assets.GetThingConfig(type);

        // Preconditions.Add(GOAPAction.Effect.HAS_THING + thingConfig.InventorySlot, type);
        // Preconditions.Add(GOAPAction.Effect.HAS_THING_FOR_STORAGE, true);
        // Effects.Add(GOAPAction.Effect.HAS_THING_FOR_STORAGE, false);
        // Effects.Add(GOAPAction.Effect.IS_WORKING, true);
    }
示例#8
0
    public static ThingConfig GetThingConfig(TypeOfThing thingType)
    {
        if (_thingDictionary == null)
        {
            SetupThings();
        }

        if (!_thingDictionary.ContainsKey(thingType))
        {
            throw new Exception($"TypeOfThing {thingType} not found in asset dictionary");
        }

        return(_thingDictionary[thingType]);
    }
示例#9
0
        public SubmitFactoryJob(GOAPAgent agent, Game game, Thing thing, Movement movement, TypeOfThing factoryType, TypeOfThing input, TypeOfThing output, bool requiresAgentToMake) : base(agent, game, movement)
        {
            _thing               = thing;
            _movement            = movement;
            _factoryType         = factoryType;
            _inventory           = _thing.Inventory;
            _output              = output;
            _input               = input;
            _requiresAgentToMake = requiresAgentToMake;

            var inputConfig  = Assets.GetThingConfig(input);
            var outputConfig = Assets.GetThingConfig(output);

            // Preconditions.Add(GOAPAction.Effect.HAS_THING + inputConfig.InventorySlot, _input);
            // Effects.Add(GOAPAction.Effect.HAS_THING + outputConfig.InventorySlot, _output);
            // Effects.Add(GOAPAction.Effect.IS_WORKING, true);
        }
示例#10
0
文件: Game.cs 项目: alexvmvm/village
        /*
         *  Things
         */

        public Thing CreateAtPosition(TypeOfThing thingType, Vector2Int position)
        {
            var thing = Assets.Create(thingType, position.x, position.y);

            if (thing.Config.FixedToFloor)
            {
                if (IsThingOnFloor(thing.Position))
                {
                    Remove(GetThingOnFloor(thing.Position));
                }

                _floor[thing.Position] = thing;
                _things.Add(thing);
            }
            else
            {
                if (IsLooseThing(thing.Position))
                {
                    Remove(GetLooseThing(thing.Position));
                }

                _loose.Add(thing);
                _things.Add(thing);
            }

            OnThingAdded?.Invoke(thing);

            switch (thing.Config.TypeOfThing)
            {
            case TypeOfThing.Villager:
                EventManager.TriggerEvent(Constants.VILLAGER_ARRIVED);
                break;
            }

            thing.RefreshSprite();

            return(thing);
        }
示例#11
0
            // public const string IS_HOLDING_THING = "IS_HOLDING_THING";
            // public const string HAS_THING = "HAS_THING";
            // public const string HAS_EDIBLE_THING = "HAS_EDIBLE_THING";
            // public const string HAS_THING_FOR_STORAGE = "HAS_THING_FOR_STORAGE";

            public static string GET_THING(TypeOfThing thing)
            {
                return($"HAS_THING_{thing}");
            }
示例#12
0
 public void AddThingToProduce(TypeOfThing thingToProduce)
 {
     _queued[thingToProduce] += 1;
 }
示例#13
0
 public void Disallow(TypeOfThing type)
 {
     _allowed[type] = false;
 }
示例#14
0
 public bool IsAllowing(TypeOfThing type)
 {
     return(_allowed.ContainsKey(type) && _allowed[type]);
 }
示例#15
0
 public ThingAddedEvent(string id, TypeOfThing typeOfThing, decimal weight)
 {
     Id          = id;
     TypeOfThing = typeOfThing;
     Weight      = weight;
 }
示例#16
0
 public void Allow(TypeOfThing type)
 {
     _allowed[type] = true;
 }
示例#17
0
 public void SetCursor(TypeOfThing type, bool placeBluerpints)
 {
     PlaceBlueprints = placeBluerpints;
     CurrentType     = type;
 }
示例#18
0
 /// <summary>
 /// This should only be used for walls
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="game"></param>
 public EntityType(Game game, TypeOfThing _type)
 {
     scale = 64.0f;
     type  = _type;
 }
示例#19
0
 public HasEdibleThing(GOAPAgent agent, Game game, TypeOfThing thing) : base(agent, game)
 {
     Preconditions.Add(GOAPAction.Effect.HAS_THING, thing);
     Effects.Add(GOAPAction.Effect.HAS_EDIBLE_THING, true);
 }
示例#20
0
 public bool IsQueuedForProduction(TypeOfThing type)
 {
     return(_queued[type] > 0);
 }
示例#21
0
 public void RemoveThingToProduce(TypeOfThing thingToProduce)
 {
     _queued[thingToProduce] -= 1;
     _queued[thingToProduce]  = Mathf.Max(_queued[thingToProduce], 0);
 }
示例#22
0
 public void Craft(TypeOfThing thing)
 {
     RemoveThingToProduce(thing);
     _jobs.Enqueue(thing);
     _timer = _timeToProduce;
 }
示例#23
0
        /*
         *  Survival
         */


        public override void Awake()
        {
            base.Awake();

            _thing = GetComponent <Thing>();

            _game = FindObjectOfType <Game>();

            _movement  = transform.gameObject.AddComponent <Movement>();
            _inventory = _thing.Inventory;

            Needs = transform.gameObject.AddComponent <Needs>();

            _firstname = NameGenerator.GenerateFirstName();
            _lastname  = NameGenerator.GenerateLastName();

            _thing.name = string.Format("{0} {1}", _firstname, _lastname);

            _villagerManager = MonoBehaviour.FindObjectOfType <VillageManager>();

            //IdleAction = new Idle(this, _game, _movement);

            AddGoal(new IdleGoal());
            AddGoal(new WorkingGoal());

            AddGoal(new DrinkGoal(Needs));
            AddGoal(new EatGoal(Needs));
            AddGoal(new RestGoal(_game, Needs));

            /*
             *  Misc
             */

            AddAction(new Drop(this, _game));
            AddAction(new Sleep(this, _game, _thing, _movement, this, Needs));
            AddAction(new Idle(this, _game, _movement));


            AddAction(new ChopWood(this, _game, _movement));
            AddAction(new PickMushroom(this, _game, _movement));
            AddAction(new GetClayFromGround(this, _game, _movement));

            /*
             *  Survival
             */

            AddAction(new DrinkFromStream(this, _game, _movement));
            AddAction(new EastSomething(this, _game, _thing));


            AddAction(new HasEdibleThing(this, _game, TypeOfThing.Mushroom));


            /*
             *  Resources
             */
            var resources = new TypeOfThing[]
            {
                TypeOfThing.Water,
                TypeOfThing.Stream,
                TypeOfThing.Rock,
                TypeOfThing.Stone,
                TypeOfThing.MushroomGrowing,
                TypeOfThing.Mushroom,
                TypeOfThing.Tree,
                TypeOfThing.FallenWood,
                TypeOfThing.Wood,
                TypeOfThing.WoodenPlanks,
                TypeOfThing.ClayFloor,
                TypeOfThing.Clay,
                TypeOfThing.OreFloor,
                TypeOfThing.Ore,
                TypeOfThing.Iron,
                TypeOfThing.CabbageSeed,
                TypeOfThing.PotatoSeed,
                TypeOfThing.CarrotSeed,
                TypeOfThing.PumpkinSeed,
                TypeOfThing.HopSeed,
                TypeOfThing.TomatoSeed,
                TypeOfThing.Cabbage,
                TypeOfThing.PotatoSeed,
                TypeOfThing.Carrot,
                TypeOfThing.Hops,
                TypeOfThing.Axe,
                TypeOfThing.Hoe,
                TypeOfThing.WateringPot
            };

            foreach (var resource in resources)
            {
                AddAction(new GetThing(this, _game, _thing, _movement, resource));
                //AddAction(new GetThingToMoveToStorage(this, _game, _thing, _movement, resource, this));
                //AddAction(new FillStorage(this, _game, _movement, _thing.Inventory, resource));
            }

            /*
             *  Factory Job
             */

            // var factoryJobs = new List<Tuple<TypeOfThing, TypeOfThing, TypeOfThing, bool>>()
            // {
            //     Tuple.Create(TypeOfThing.ClayForge, TypeOfThing.Ore, TypeOfThing.Iron, false),
            //     Tuple.Create(TypeOfThing.Workbench, TypeOfThing.Iron, TypeOfThing.Axe, true),
            //     Tuple.Create(TypeOfThing.Workbench, TypeOfThing.Iron, TypeOfThing.Hoe, true),
            //     Tuple.Create(TypeOfThing.CarpentersBench, TypeOfThing.Wood, TypeOfThing.WoodenPlanks, true),
            //     Tuple.Create(TypeOfThing.Kiln, TypeOfThing.Clay, TypeOfThing.WateringPot, false)
            // };

            // foreach(var job in factoryJobs)
            // {
            //     AddAction(new SubmitFactoryJob(this, _game, _thing, _movement, job.Item1, job.Item2, job.Item3, job.Item4));
            // }

            /*
             *  Construction
             */

            AddAction(new Construct(this, _game, _movement, TypeOfThing.Wood, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.WoodenPlanks, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.Stone, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.Clay, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.Hoe, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.CabbageSeed, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.PotatoSeed, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.TomatoSeed, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.PumpkinSeed, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.CarrotSeed, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.Water, _thing));
            AddAction(new Construct(this, _game, _movement, TypeOfThing.None, _thing));
        }
示例#24
0
 public int GetQueuedCount(TypeOfThing thing)
 {
     return(_queued[thing]);
 }
示例#25
0
 void DrawThing(float x, float y, float width, float height, TypeOfThing thing)
 {
     GUI.Box(new Rect(x, y, width, height), thing.ToString());
 }