public void Init(VillageManager reference)
    {
        main   = reference;
        sorted = main.villagers.OrderByDescending(o => o.happiness).ToList();

        Schedule();
    }
Beispiel #2
0
    public bool GetNextTask()
    {
        double t               = VillageManager.Get().GetDayTime();
        Task   cur             = GetCurrent();
        int    currentTask_tmp = currentTask;

        if (cur != null)
        {
            //0 uhr umsprung
            if (t < cur.ParseTime())
            {
                currentTask_tmp = -1;
            }
        }

        int nextTask = currentTask_tmp + 1;

        if (nextTask < 0 || nextTask >= tasks.Count)
        {
            return(false);
        }

        Task next = tasks[nextTask];

        if (t >= next.ParseTime())
        {
            //Debug.Log(next.Info() + " - t:" + t + " parse:" + next.ParseTime());
            currentTask = nextTask;
            return(true);
        }

        return(false);
    }
 // Start is called before the first frame update
 void Start()
 {
     if (!villageManager)
     {
         villageManager = FindObjectOfType <VillageManager>();
     }
     Hide();
 }
Beispiel #4
0
 public EntityManager()
 {
     Guilds      = new GuildManager("guilds.json");
     Characters  = new CharacterManager("characters.xml");
     Map         = new MapManager("map.xml");
     Villages    = new VillageManager("villages.json");
     Inventories = new InventoryManager("inventories.xml");
 }
Beispiel #5
0
    // Start is called before the first frame update
    void Start()
    {
        villageManager = GameObject.Find("SceneManager").GetComponent <VillageManager>();

        stats          = GetComponent <Combat>();
        currentStamina = MaxStamina;
        currentText    = passOutText;
    }
Beispiel #6
0
 public override void OnInspectorGUI()
 {
     DrawDefaultInspector();
     if (GUILayout.Button("Add New Villager"))
     {
         VillageManager myTarget = (VillageManager)target;
         myTarget.AddNewWorker();
     }
 }
Beispiel #7
0
 void Awake()
 {
     villageManager = GameObject.FindObjectOfType<VillageManager>();
     spriteRender = GetComponent<SpriteRenderer>();
     animator = GetComponent<Animator>();
     if(animator == null)
     {
         Debug.LogError("EnemyAi need an animator");
         animator.SetTrigger("Reset");
     }
     enemyStats = GetComponent<EnemyStats>();
 }
Beispiel #8
0
    //86400  seconds in a day
    //3600 seconds in a hour

    private void Awake()
    {
        if (TimeManagerInstance == null)
        {
            TimeManagerInstance = this;
        }
        else if (TimeManagerInstance != this)
        {
            Destroy(gameObject);
        }
        villageManager = GetComponent <VillageManager>();
    }
Beispiel #9
0
        /// <summary>
        ///     Initializes a new instance of the Server class.
        /// </summary>
        /// <param name="name">Server name.</param>
        /// <param name="speed">Server speed.</param>
        /// <param name="address">Server url address.</param>
        public Server(string name, int speed, string address)
        {
            Name           = name;
            Speed          = speed;
            Address        = address;
            ClientManager  = new ClientManager(this);
            AccountManager = new AccountManager();
            PlayerManager  = new PlayerManager(this);
            VillageManager = new VillageManager(this);
            AllyManager    = new AllyManager(this);

            ClientManager.NewClient += OnNewClientCreated;
        }
Beispiel #10
0
        /// <summary>
        ///     Initializes a new instance of the Server class.
        /// </summary>
        /// <param name="name">Server name.</param>
        /// <param name="speed">Server speed.</param>
        /// <param name="address">Server url address.</param>
        public Server(string name, int speed, string address)
        {
            Name = name;
            Speed = speed;
            Address = address;
            ClientManager = new ClientManager(this);
            AccountManager = new AccountManager();
            PlayerManager = new PlayerManager(this);
            VillageManager = new VillageManager(this);
            AllyManager = new AllyManager(this);

            ClientManager.NewClient += OnNewClientCreated;
        }
Beispiel #11
0
 public void StartGame()
 {
     Panel.SetActive( false);
     char[,] AiMap = new char[1, 1];
     AiMap = MapGen.GetMap();
     TreeMgr.GenerateTrees(AiMap);
     for (int i = 0; i < NumofVillages; ++i)
     {
         VillageManager newmanager = new VillageManager();
         if(i == 0 && NewScenario.Created)
             newmanager.Initialise(StartingLocations[i], i, VillageManager.AI_Bias.Balanced,TreeMgr, ref AiMap,NewScenario);
         else
             newmanager.Initialise(StartingLocations[i], i, VillageManager.AI_Bias.Balanced, TreeMgr, ref AiMap);
         TaskExecutives.Add(newmanager);
     }
 }
Beispiel #12
0
    //Now, i call functions to draw everyting
    private void DrawMap()
    {
        drawMap.Init(World.Map);
        drawMap.Draw();

        IEnumerator <Village> iterator = World.GetVillages();

        while (iterator.MoveNext())
        {
            Village    currentVillage       = iterator.Current;
            GameObject villageManagerObject =
                Instantiate(PrefabLoader.GetVillage(), Vector3.zero, Quaternion.identity) as GameObject;
            villageManagerObject.name = currentVillage.Name;
            VillageManager villageManager = villageManagerObject.GetComponent <VillageManager>();
            villageManager.Init(currentVillage);
            villageManagers.Add(villageManager);
        }
    }
Beispiel #13
0
    public Building ParseTarget()
    {
        if (target == "" || target == null)
        {
            return(null);
        }
        //MAYBE add villagers later
        List <Building> builds = VillageManager.Get().GetBuildings();

        for (int i = 0; i < builds.Count; i++)
        {
            if (builds[i].objectName == target)
            {
                return(builds[i]);
            }
        }

        return(null);
    }
Beispiel #14
0
    public ActionHandler(VillageManager villageManager, GameManager gameManager, TechModel techModel)
    {
        this.techModel      = techModel;
        ActionDict          = new Dictionary <string, float>();
        this.gameManager    = gameManager;
        this.villageManager = villageManager;
        actionStatList      = new List <ActionStat>();
        actionStatList.Add(new ActionStat {
            ID = StatFlag.ActionStat.Quarantine, apCost = 1
        });
        actionStatList.Add(new ActionStat {
            ID = StatFlag.ActionStat.Lab, apCost = 1
        });
        actionStatList.Add(new ActionStat {
            ID = StatFlag.ActionStat.Cure, apCost = 1
        });
        actionStatList.Add(new ActionStat {
            ID = StatFlag.ActionStat.Investigate, apCost = 0
        });

        Reset();
    }
 // Use this for initialization
 void Start()
 {
     outline = Shader.Find("Glow");
     GameObject go = GameObject.Find("VillageManager");
     vm = go.GetComponent<VillageManager> ();
     //Debug.Log (vm);
     wage = 0;
     health = 1;
     //		playerName = this.controlledBy.getName ();
 }
Beispiel #16
0
    protected void addBuildingToScene(Vector3 position)
    {
        //GameObject currentObject = FindObjectOfType<All3DObjects>().getCurrentObject();

        // Ici ajouter currentObject = batiment selectionné

        if (currentObject != null)
        {
            Debug.Log("OK");
            //Instantiate

            _myVillage = FindObjectOfType <VillageManager>();
            Debug.Log(currentObject.name);
            switch (currentObject.name)
            {
            case "BasicHousePrefab":
                if (player.getGold() >= 100 && _myVillage.getWood() >= 60 && _myVillage.getStone() >= 30)
                {
                    _myVillage.setStone(_myVillage.getStone() - 30);
                    _myVillage.setWood(_myVillage.getWood() - 60);
                    player.setGold(player.getGold() - 100);
                    _myVillage.setPeople(_myVillage.getPeople() + 5);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }

                break;

            case "MediumHousePrefab":
                if (player.getGold() >= 180 && _myVillage.getWood() >= 150 && _myVillage.getStone() >= 100)
                {
                    _myVillage.setStone(_myVillage.getStone() - 100);
                    _myVillage.setWood(_myVillage.getWood() - 150);
                    player.setGold(player.getGold() - 180);
                    _myVillage.setPeople(_myVillage.getPeople() + 10);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "BigHousePrefab":
                if (player.getGold() >= 300 && _myVillage.getWood() >= 350 && _myVillage.getStone() >= 220)
                {
                    _myVillage.setStone(_myVillage.getStone() - 220);
                    _myVillage.setWood(_myVillage.getWood() - 350);
                    _myVillage.setPeople(_myVillage.getPeople() + 25);
                    player.setGold(player.getGold() - 300);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "LumberPrefab":
                if (player.getGold() >= 220 && _myVillage.getWood() >= 250)
                {
                    _myVillage.setWood(_myVillage.getWood() - 250);
                    _myVillage.setLumber(_myVillage.getLumber() + 1);
                    player.setGold(player.getGold() - 220);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "MinerPrefab":
                if (player.getGold() >= 220 && _myVillage.getStone() >= 180)
                {
                    _myVillage.setStone(_myVillage.getStone() - 180);
                    _myVillage.setMiner(_myVillage.getMiner() + 1);
                    player.setGold(player.getGold() - 220);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "WareHousePrefab":
                if (player.getGold() >= 350 && _myVillage.getStone() >= 350 && _myVillage.getWood() >= 400 && _myVillage.getPeople() >= 30)
                {
                    _myVillage.setWood(_myVillage.getWood() - 400);
                    _myVillage.setStone(_myVillage.getStone() - 350);
                    player.setGold(player.getGold() - 350);
                    player.setMaxWood(player.getMaxWood() + 800);
                    player.setMaxStone(player.getMaxStone() + 600);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 30)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "GoldWareHousePrefab":
                if (player.getGold() >= 400 && _myVillage.getStone() >= 450 && _myVillage.getWood() >= 500 && _myVillage.getPeople() >= 50)
                {
                    _myVillage.setWood(_myVillage.getWood() - 500);
                    _myVillage.setStone(_myVillage.getStone() - 450);
                    player.setGold(player.getGold() - 400);
                    player.setMaxGold(player.getMaxGold() + 700);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 50)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "ForgePrefab":
                if (player.getGold() >= 320 && _myVillage.getStone() >= 250 && _myVillage.getWood() >= 300 && _myVillage.getPeople() >= 40)
                {
                    _myVillage.setWood(_myVillage.getWood() - 300);
                    _myVillage.setStone(_myVillage.getStone() - 250);
                    player.setGold(player.getGold() - 320);
                    Instantiate(currentObject, position, Quaternion.identity);
                    player.setDEF(player.getDEF() + 10);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 40)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "ArmureriePrefab":
                if (player.getGold() >= 320 && _myVillage.getStone() >= 240 && _myVillage.getWood() >= 320 && _myVillage.getPeople() >= 40)
                {
                    _myVillage.setWood(_myVillage.getWood() - 320);
                    _myVillage.setStone(_myVillage.getStone() - 240);
                    player.setGold(player.getGold() - 320);
                    player.setATK(player.getATK() + 10);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 40)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;
            }
        }
    }
Beispiel #17
0
    Vector2 FindBuilding(string name, VillageManager.GoalState Goal,ref Building SelectedBuilding,ref Tree SelectedTree)
    {
        
        if (name.Split('_')[0].Equals( "Start", System.StringComparison.InvariantCultureIgnoreCase))
            return FindVillager(name, Goal).Position;
        if (name.Split('_')[0].Equals("building", System.StringComparison.InvariantCultureIgnoreCase))
        {
            SelectedBuilding = Goal.GameState.OwnedLocations[int.Parse(name.Split('_')[1])];
            return Goal.GameState.OwnedLocations[int.Parse(name.Split('_')[1])].Position;
        }
        else if (name.Split('_')[0].Equals("tree", System.StringComparison.InvariantCultureIgnoreCase))
        {
            SelectedTree = Goal.GameState.Trees[int.Parse(name.Split('_')[1])];
            return Goal.GameState.Trees[int.Parse(name.Split('_')[1])].Pos;
        }
        else if (name.Split('_')[0].Equals("buildingSite", System.StringComparison.InvariantCultureIgnoreCase))
        {
            SelectedBuilding = Goal.Site;
            return Goal.Site.Position;
        }

        return new Vector2(float.MaxValue,float.MaxValue);
    }
Beispiel #18
0
 public void Start()
 {
     dialogueDisplayer = GameObject.Find("SceneManager").GetComponent <InkDisplayer>();
     villageManager    = GameObject.Find("SceneManager").GetComponent <VillageManager>();
 }
Beispiel #19
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));
        }
Beispiel #20
0
    public void InterpretSolution(VillageManager.GoalState Goal)
    {
        // here we interpret the actions and generate the tasks
		List<Task> TotalTasks = new List<Task> ();
        for (int i = 0; i < TempPlanStorage.Count;i++ ) // each string array is 1 action N params
        {
            Task newTask = new Task();
            for (int j = 0; j < DomainActions.Count; j++)// if we first match to an action, we can limit the number of required searchs, i.e only search for buildings
            {
                var action = TempPlanStorage[i][0].Split('_');
                if (action[0].Equals(DomainActions[j].ActionName, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    if(action.Length>1)
                    {
                        if (!action[1].Equals(DomainActions[j].BuildType.ToString(), System.StringComparison.InvariantCultureIgnoreCase) &&
                            !action[1].Equals(DomainActions[j].ItemType.ToString(), System.StringComparison.InvariantCultureIgnoreCase) &&
                            !action[1].Equals(DomainActions[j].SkillType.ToString(), System.StringComparison.InvariantCultureIgnoreCase))
                            continue;
                    }
                    newTask.Action = DomainActions[j].ActionType;
                    //1st we get the villagers involved
                    newTask.villager = new List<Villager>();
                    foreach (int paramloc in DomainActions[j].PersonParams)
                        newTask.villager.Add(FindVillager(TempPlanStorage[i][paramloc], Goal));
                    newTask.ItemRequired = DomainActions[j].ItemType;
                    newTask.SkillToBeLearnt = DomainActions[j].SkillType;
                    newTask.ToBeBuilt = DomainActions[j].BuildType;
                    newTask.Path = new PathPlanning.PathInfo();
                    
                    if (DomainActions[j].LocationParams.Count > 1)
                    {
                        // is move too action

                        newTask.Path.Start = FindBuilding(TempPlanStorage[i][DomainActions[j].LocationParams[0]], Goal, ref newTask.BuildingInUse,ref newTask.TreeInUse);
                        newTask.Path.End = FindBuilding(TempPlanStorage[i][DomainActions[j].LocationParams[1]], Goal, ref newTask.BuildingInUse, ref newTask.TreeInUse);
                        newTask.Path.Complete = false;
                        // otherwise goal is primary location
                    }
                    else
                    {
                        newTask.Path.Start = new Vector2(float.MaxValue,float.MaxValue);
                        newTask.Path.End = FindBuilding(TempPlanStorage[i][DomainActions[j].LocationParams[0]], Goal, ref newTask.BuildingInUse, ref newTask.TreeInUse);
                    }
                    newTask.complete = true;
				TotalTasks.Add(newTask);
                }
            }

        }
            // at the end empty it

        Plans[TempPlanID] = TotalTasks;
        TempPlanStorage = null;
    }
Beispiel #21
0
 public VillageManager()
 {
     instance = this;
 }
Beispiel #22
0
 Villager FindVillager(string name,VillageManager.GoalState Goal)
 {
     return Goal.GameState.Villagers[int.Parse(name.Split('_')[1])];
 }
Beispiel #23
0
 void Start()
 {
     VM = GameObject.Find("GameManager").GetComponent <VillageManager>();
 }
Beispiel #24
0
    bool CreateProblem(VillageManager.GoalState Goal)
    {
        // now we need to encode the problemfile
        
        var writer = File.CreateText(problemfileloc);
        writer.WriteLine("(define(problem prob)");
        writer.WriteLine("(:domain dom)");
        writer.WriteLine("(:objects");
        //here we add in all the objects
        //we need access to the current game state to define the objects
        for (int i = 0; i < Goal.GameState.Villagers.Count; i++)
        {
            writer.WriteLine("villager_" + i.ToString() + " - person");
			writer.WriteLine("Start_" + i.ToString() + " - location");
        }
        for (int i = 0; i < Goal.GameState.OwnedLocations.Count; i++)
        {
            writer.WriteLine("building_" + i.ToString() + " - location");
        }
        if (Goal.NewBuildings != Building.BuildingType.None )
            writer.WriteLine("buildingSite" + " - location");
        if(Goal.GameState.Trees != null)
            for (int i = 0; i < Goal.GameState.Trees.Count; i++)
            {
                writer.WriteLine("Tree_" + i.ToString() + "- Tree");
            }
        writer.Write(")");
        writer.WriteLine("(:init ");
        //here we loop through the initial state and set up the predicates such as which items are where
        for (int i = 0; i < Goal.GameState.Villagers.Count; i++)
        {
            string skill = "";
            string item = "";
           // writer.WriteLine(Goal.GameState.Villagers[i].Key + " - person");
            if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Blacksmith)
                skill = "BlacksmithS";
            else if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Carpenter)
                skill = "Carpenter";
            else if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Labourer)
                skill = "Labourer";
            else if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Lumberjack)
                skill = "Lumberjack";
            else if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Miner)
                skill = "Miner";
            else if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Rifleman)
                skill = "Rifleman";
            else if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Trader)
                skill = "Trader";
            else
                continue;
            writer.WriteLine("(has-"+skill+"  "+"villager_"+i.ToString()+")");
            if (Goal.GameState.Villagers[i].Inventory == Villager.Items.Stone)
                item = "Stone";
            else if (Goal.GameState.Villagers[i].Inventory == Villager.Items.Wood)
                item = "Wood";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Iron)
                item = "Iron";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Timber)
                item = "Timber";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Ore)
                item = "Ore";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Coal)
                item = "Coal";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Money)
                item = "Money";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Goods)
                item = "Goods";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Axe)
                item = "Axe";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Cart)
                item = "Cart";
            else if(Goal.GameState.Villagers[i].Inventory == Villager.Items.Rifle)
                item = "Rifle";
            else
                item  = "";
			if(item != "")
            	writer.WriteLine("(has-" + item + "  " + "villager_" + i.ToString() + ")");
            writer.WriteLine("(at villager_"+i.ToString()+"  Start_"+i.ToString() + ")"); // so all villagers start at an arbitrary possition based on their current position at time of planning
        }
       
        for (int i = 0; i < Goal.GameState.OwnedLocations.Count; i++)
        {
            string location = "";
            if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Barracks)
                location = "Barracks";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Blacksmith)
                location = "Blacksmith";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.House)
                location = "house";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Market)
                location = "Market_Stall";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Mine)
                location = "Mine";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Quarry)
                location = "Quarry";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Sawmill)
                location = "Sawmill";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.School)
                location = "School";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Smelter)
                location = "Smelter";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Storage)
                location = "Storage";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Turf)
                location = "turfhut";
            else if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.buildingSite)
                continue;
            writer.WriteLine("(is-" + location + "  building_" + i.ToString() + ")");
            foreach(var Item in Goal.GameState.OwnedLocations[i].Items)
            {
                string item;
                if(Item == Villager.Items.Stone)
                    item = "Stone";
                else if(Item == Villager.Items.Wood)
                    item = "Wood";
                else if(Item == Villager.Items.Iron)
                    item = "Iron";
                else if(Item == Villager.Items.Timber)
                    item = "Timber";
                else if(Item == Villager.Items.Ore)
                    item = "Ore";
                else if(Item == Villager.Items.Coal)
                    item = "Coal";
                else if(Item == Villager.Items.Money)
                    item = "Money";
                else if(Item == Villager.Items.Goods)
                    item = "Goods";
                else if(Item == Villager.Items.Axe)
                    item = "Axe";
                else if(Item == Villager.Items.Cart)
                    item = "Cart";
                else if(Item == Villager.Items.Rifle)
                    item = "Rifle";
                else
                    continue;
                writer.WriteLine("(has-"+item+" "+"building_"+i.ToString()+")");
            }

        }
		if(Goal.NewBuildings != Building.BuildingType.None)
			writer.WriteLine("(is-BuildingSite buildingSite)");

        writer.Write(")");
        writer.WriteLine("(:goal ");
        //here we loop through the goal state

        writer.WriteLine("(and");
        if (Goal.NewBuildings != Building.BuildingType.None)
        {

            if (Goal.NewBuildings == Building.BuildingType.Barracks)
            {
                writer.WriteLine("(is-Barracks buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.Turf)
            {
                writer.WriteLine("(is-turfhut buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.Quarry)
            {
                writer.WriteLine("(is-Quarry buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.House)
            {
                writer.WriteLine("(is-House buildingSite)"); ;
            }
            else if (Goal.NewBuildings == Building.BuildingType.School)
            {
                writer.WriteLine("(is-School buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.Storage)
            {
                writer.WriteLine("(is-Storage buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.Mine)
            {
                writer.WriteLine("(is-Mine buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.Smelter)
            {
                writer.WriteLine("(is-Smelter buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.Sawmill)
            {
                writer.WriteLine("(is-Sawmill buildingSite)");
            }
            else if (Goal.NewBuildings == Building.BuildingType.Blacksmith)
            {
                writer.WriteLine("(is-Blacksmith buildingSite)");
            }
        }
        else if(Goal.NewSkills != null)
        {
            //labourers will be assigned skills here based on number of new skills
            if (Goal.NewSkills.Contains(Villager.Skills.Labourer))
            {
                // means they want to hump
                writer.WriteLine("(isParent villager_0)");
                writer.WriteLine("(isParent villager_1)");
            }
            else
            {
                // here we learn existing skills so its any labourer taught by ANYONE
                List<string> StudentName = new List<string>();
                List<string> ItemName = new List<string>();
                for (int i = 0; i < Goal.NewSkills.Count; i++)
                {
                    if (Goal.GameState.Villagers[i].Skill == Villager.Skills.Labourer)
                        StudentName.Add("villager_" + i.ToString());
                }
                foreach (var skill in Goal.NewSkills)
                {
                    if (skill == Villager.Skills.Blacksmith)
                        ItemName.Add("BlacksmithS");
                    else if (skill == Villager.Skills.Carpenter)
                        ItemName.Add("Carpenter");
                    else if (skill == Villager.Skills.Lumberjack)
                        ItemName.Add("Lumberjack");
                    else if (skill == Villager.Skills.Miner)
                        ItemName.Add("Miner");
                    else if (skill == Villager.Skills.Rifleman)
                        ItemName.Add("Rifleman");
                    else if (skill == Villager.Skills.Trader)
                        ItemName.Add("Trader");
                }
                for (int i = 0; i < Goal.NewSkills.Count; i++)
                    writer.WriteLine("(has-" + ItemName[i]+" " + StudentName[i] + ")");
            }
        }
        else if(Goal.NewItems != null)
        {
            //check whether raw or derivative resources
            // there are no storage facilities, and so raw resources will only be collected when we require the tools / buildings
            if (Goal.NewItems.Contains(Villager.Items.Rifle))
            {
                for (int i = 0; i < Goal.GameState.OwnedLocations.Count; i++)
                {
                  if(Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Blacksmith)
                    {
                        writer.WriteLine("(has-Rifle " + "building_" + i.ToString() + ")");
                        break;
                    }
                }
            }
            else if (Goal.NewItems.Contains(Villager.Items.Axe))
            {
                for (int i = 0; i < Goal.GameState.OwnedLocations.Count; i++)
                {
                    if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Blacksmith)
                    {
                        writer.WriteLine("(has-Axe " + "building_" + i.ToString() + ")");
                        break;
                    }
                }
            }
            else if (Goal.NewItems.Contains(Villager.Items.Cart))
            {
                for (int i = 0; i < Goal.GameState.OwnedLocations.Count; i++)
                {
                    if (Goal.GameState.OwnedLocations[i].Type == Building.BuildingType.Blacksmith)
                    {
                        writer.WriteLine("(has-Cart " + "building_" + i.ToString() + ")");
                        break;
                    }
                }
            }
        }
        writer.Write(")");
        writer.Write(")");
        writer.Write(")");
        writer.Close();
        writer.Dispose();
        return true;
    }
Beispiel #25
0
 void Awake()
 {
     VillageManager.Get().AddBuilding(this);
 }
Beispiel #26
0
	// Use this for initialization
	void Awake () {
        animator = GetComponent<Animator>();
        villageManager = FindObjectOfType<VillageManager>();
	}
Beispiel #27
0
 void Start()
 {
     VillageManager.Get().AddVillager(this);
     schedule.Reset();
 }
Beispiel #28
0
    void Movement()
    {
        Vector3 tmp = target;

        if (schedule.GetTarget() == null)
        {
            return;
        }
        //Debug.Log(tmp);
        if (Vector3.Distance(transform.position, tmp) != 0)
        {
            target             = new Vector3(target.x, 1, target.z);
            transform.position = Vector3.MoveTowards(transform.position, target, speed * VillageManager.Get().deltaTime);

            if (transform.position == target && !arrived)
            {
                //arrived at building
                Debug.Log("arrived");
                arrived = true;
                workplace.AddWorker(this);
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     villageManager = GameObject.Find ("VillageManager").GetComponent<VillageManager>();
     tileManager = GameObject.Find ("TileManager").GetComponent<TileManager> ();
     gameGUI = GameObject.Find ("attachingGUI").GetComponent<InGameGUI>();
 }
Beispiel #30
0
 void Start()
 {
     VM = GetComponent <VillageManager>();
 }
 // Use this for initialization
 void Start()
 {
     myCamera =  GameObject.FindGameObjectWithTag("MainCamera").camera;
     villageManager = GameObject.Find("VillageManager").GetComponent<VillageManager>();
     villageManager.isInGame = true;
     unitManager = GameObject.Find("UnitManager").GetComponent<UnitManager>();
     gameManager = GameObject.Find("preserveGM").GetComponent<GameManager> ();
     gameManager.isInGame = true;
     HUDCanvas.enabled = true;
     ErrorCanvas.enabled = false;
     disableAllCanvases ();
     myTurn = gameManager.getLocalTurn ();
     if (myTurn == 0)
     {
         gameObject.networkView.RPC ("updateEndTurnButtonsNet",RPCMode.AllBuffered);
     }
 }
Beispiel #32
0
    void Production()
    {
        if (GetComponent <SeasonFilter>() != null && GetComponent <SeasonFilter>().filter.Contains(VillageManager.Get().GetSeason()))
        {
            return;
        }                                                                                                                                              //if this building can't produce during current season
        if (workers.Count > 0)
        {
            productionTimer += VillageManager.Get().deltaTime;

            switch (currentProduction)
            {
            case ProductionEnum.NONE:
                break;

            case ProductionEnum.HAPPINESS:
                if (productionTimer > VillageManager.oneHour)
                {
                    productionTimer = 0;
                    TickCycle();
                }
                break;

            case ProductionEnum.IRON:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().pickaxe >= 1)
                    {
                        VillageManager.Get().pickaxe -= 1;
                        VillageManager.Get().iron    += 2;
                        productionTimer = 0;

                        TickCycle();                                 //only ticks if villager is actually working, since he's chilling otherwise having a "jolly good" time*
                    }
                }
                break;

            case ProductionEnum.PICKAXE:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().iron >= 1)
                    {
                        VillageManager.Get().pickaxe += 1;
                        VillageManager.Get().iron    -= 1;
                        productionTimer = 0;

                        TickCycle();
                    }
                }

                break;

            case ProductionEnum.BREAD:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().flour >= 1)
                    {
                        VillageManager.Get().bread += 4;
                        VillageManager.Get().flour -= 1;
                        productionTimer = 0;

                        TickCycle();
                    }
                }
                break;

            case ProductionEnum.FLOUR:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().wheat >= 3)
                    {
                        VillageManager.Get().flour += 1;
                        VillageManager.Get().wheat -= 3;
                        productionTimer = 0;

                        TickCycle();
                    }
                }
                break;

            case ProductionEnum.WHEAT:
                if (productionTimer > VillageManager.oneHour)
                {
                    VillageManager.Get().wheat += 1;
                    productionTimer = 0;

                    TickCycle();
                }
                break;
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     villageManager = GameObject.Find ("VillageManager").GetComponent<VillageManager> ();
     game = gameObject.GetComponent<Game> ();
 }
Beispiel #34
0
 public LeaveVillage(GOAPAgent agent, Game game, Movement movement, Thing thing, Villager villager) : base(agent, game, movement)
 {
     _thing          = thing;
     _villager       = villager;
     _villageManager = MonoBehaviour.FindObjectOfType <VillageManager>();
 }
Beispiel #35
0
 void Awake()
 {
     _villageManager = FindObjectOfType <VillageManager>();
 }
Beispiel #36
0
    // Start is called before the first frame update
    void Start()
    {
        if (!dropEventManager)
        {
            dropEventManager = GetComponent <DropEventManager>();
        }
        if (!ferryProgress)
        {
            ferryProgress = FindObjectOfType <FerryProgress>();
        }
        if (!gameCamera)
        {
            gameCamera = FindObjectOfType <GameCamera>();
        }

        if (!playerLogoManager)
        {
            playerLogoManager = GetComponent <PlayerLogoManager>();
        }
        if (!villageManager)
        {
            villageManager = FindObjectOfType <VillageManager>();
        }

        if (!settings)
        {
            settings = GetComponent <GameSettings>();
        }
        if (!subEventManager)
        {
            subEventManager = GetComponent <TwitchEventManager>();
        }
        if (!subEventManager)
        {
            subEventManager = gameObject.AddComponent <TwitchEventManager>();
        }

        if (!commandServer)
        {
            commandServer = GetComponent <CommandServer>();
        }
        if (!islandManager)
        {
            islandManager = GetComponent <IslandManager>();
        }
        if (!itemManager)
        {
            itemManager = GetComponent <ItemManager>();
        }
        if (!playerManager)
        {
            playerManager = GetComponent <PlayerManager>();
        }
        if (!chunkManager)
        {
            chunkManager = GetComponent <ChunkManager>();
        }
        if (!craftingManager)
        {
            craftingManager = GetComponent <CraftingManager>();
        }
        if (!raidManager)
        {
            raidManager = GetComponent <RaidManager>();
        }
        if (!streamRaidManager)
        {
            streamRaidManager = GetComponent <StreamRaidManager>();
        }
        if (!arenaController)
        {
            arenaController = FindObjectOfType <ArenaController>();
        }

        if (!ferryController)
        {
            ferryController = FindObjectOfType <FerryController>();
        }
        if (!musicManager)
        {
            musicManager = GetComponent <MusicManager>();
        }

        RegisterGameEventHandler <ItemAddEventHandler>(GameEventType.ItemAdd);
        RegisterGameEventHandler <ResourceUpdateEventHandler>(GameEventType.ResourceUpdate);
        RegisterGameEventHandler <ServerMessageEventHandler>(GameEventType.ServerMessage);

        RegisterGameEventHandler <VillageInfoEventHandler>(GameEventType.VillageInfo);
        RegisterGameEventHandler <VillageLevelUpEventHandler>(GameEventType.VillageLevelUp);

        RegisterGameEventHandler <PlayerRemoveEventHandler>(GameEventType.PlayerRemove);
        RegisterGameEventHandler <PlayerAddEventHandler>(GameEventType.PlayerAdd);
        RegisterGameEventHandler <PlayerExpUpdateEventHandler>(GameEventType.PlayerExpUpdate);
        RegisterGameEventHandler <PlayerJoinArenaEventHandler>(GameEventType.PlayerJoinArena);
        RegisterGameEventHandler <PlayerJoinDungeonEventHandler>(GameEventType.PlayerJoinDungeon);
        RegisterGameEventHandler <PlayerJoinRaidEventHandler>(GameEventType.PlayerJoinRaid);
        RegisterGameEventHandler <PlayerNameUpdateEventHandler>(GameEventType.PlayerNameUpdate);
        RegisterGameEventHandler <PlayerTaskEventHandler>(GameEventType.PlayerTask);


        RegisterGameEventHandler <StreamerWarRaidEventHandler>(GameEventType.WarRaid);
        RegisterGameEventHandler <StreamerRaidEventHandler>(GameEventType.Raid);
        RegisterGameEventHandler <PlayerAppearanceEventHandler>(GameEventType.PlayerAppearance);
        RegisterGameEventHandler <ItemBuyEventHandler>(GameEventType.ItemBuy);
        RegisterGameEventHandler <ItemSellEventHandler>(GameEventType.ItemSell);

        commandServer.StartServer(this);
        musicManager.PlayBackgroundMusic();
    }
Beispiel #37
0
 public int RequestTask(VillageManager.GoalState newTask)
 {
     List<Task> newTaskList = new List<Task>();
     GoalsToAcheive.Add(GoalsToAcheive.Count,newTask);
     var intref = GoalsToAcheive.Count - 1;
     Plans.Add(intref, newTaskList);
     
     // add the struct 
     // get the value added at and then return
     return intref;
 }