Example #1
0
 public void loadMusic()
 {
     if (Directory.Exists("advdata") && Directory.Exists("advdata" + World.separator + "music"))
     {
         foreach (string filename in Directory.GetFiles("advdata" + World.separator + "music"))
         {
             if (filename.Contains(".wav") || filename.Contains(".ogg"))
             {
                 World.log("Found music file: " + filename);
                 DirectoryInfo dir    = new DirectoryInfo(".");
                 string        target = "file://" + dir.FullName + World.separator + filename;
                 World.log(target);
                 WWW www = new WWW(target);//You'd be a fool NOT to treat a local file as if it were a web page
                 while (!www.isDone)
                 {
                     //Wait till whatever the f**k does whatever the f**k
                 }
                 AudioClip clip = www.GetAudioClip();
                 //clip.LoadAudioData();
                 if (filename.Contains("TITLE.ogg"))
                 {
                     titleTheme = clip;
                 }
                 else
                 {
                     loadedMusic.Add(clip);
                 }
             }
         }
     }
     doneLoading = true;
     shuffle();
 }
        public override void implement(VoteOption option)
        {
            if (society.people.Contains(option.person) == false)
            {
                World.log("Invalid option. Person cannot hold title."); return;
            }
            base.implement(option);
            if (title.heldBy == option.person)
            {
                World.log("Title: " + title.getName() + " remains held by " + option.person.getFullName());
            }

            //Title already has a person
            if (title.heldBy != null)
            {
                World.log(title.heldBy.getFullName() + " is losing title " + title.getName());
                title.heldBy.titles.Remove(title);
                title.heldBy = null;
            }

            World.log(option.person.getFullName() + " has been granted the title of " + title.getName());
            title.heldBy = option.person;
            option.person.titles.Add(title);

            society.turnSovreignAssigned = society.map.turn;
            title.turnLastAssigned       = society.map.turn;
        }
Example #3
0
        public void selectableClicked(string text)
        {
            if (text == "Standard")
            {
                currentMode = aiMode.TESTDARK;
            }
            if (text == "Flesh")
            {
                currentMode = aiMode.FLESH;
            }
            if (text == "Flesh Only")
            {
                currentMode = aiMode.FLESH_ONLY;
            }
            if (text == "Fog")
            {
                currentMode = aiMode.FOG;
            }
            if (text == "Cold")
            {
                currentMode = aiMode.COLD;
            }
            if (text == "Chthonian")
            {
                currentMode = aiMode.CHTHONIAN;
            }
            World.log("AI mode is set to " + currentMode);

            map.world.prefabStore.popMsgTreeBackground("Welcome to the automatic testing interface. This allows games to be played automatically, with both the human and the dark sides played "
                                                       + " by AI control. This is designed to allow rapid testing for rough balancing and for AI behaviour analysis. \n\nHold CTRL to end one turn per half second, hold ALT to progress turns as fast as possible.");
        }
        public override void implement(VoteOption option)
        {
            base.implement(option);
            if (option.index == 1)
            {
                bool            canVassalise = false;
                Society         receiever    = (Society)target;
                List <Location> trans        = new List <Location>();
                foreach (Location loc in society.map.locations)
                {
                    if (loc.soc == society)
                    {
                        trans.Add(loc);
                    }
                    if (loc.soc == target && loc.settlement != null)
                    {
                        canVassalise = true;
                    }
                }
                if (canVassalise)
                {
                    World.log(society.getName() + " VASSALISES UNDER " + target.getName());
                    society.map.turnMessages.Add(new MsgEvent(society.getName() + " vassalises under " + target.getName() + ", transferring all lands and landed nobles.", MsgEvent.LEVEL_RED, true));

                    foreach (Location loc in trans)
                    {
                        receiever.map.takeLocationFromOther(receiever, society, loc);
                    }
                }
            }
        }
        public static void onEnthralledUnitMove(Map m, Unit u)
        {
            World.Log("narrEvents to check " + events.Count);
            foreach (var kv in events)
            {
                var e = kv.Value;

                EventContext?       nctx     = null;
                List <EventContext> contices = new List <EventContext>();
                contices.Add(EventContext.withUnit(m, u));
                switch (e.type)
                {
                case EventData.Type.MOVE:
                    nctx = chooseContext(e, contices);
                    break;

                default:
                    //Another type we're not involved in here
                    break;
                }

                if (nctx is EventContext ctx)
                {
                    World.log("Found a narr event to trigger");
                    m.world.prefabStore.popEvent(e.data, ctx);
                    break;
                }
            }
        }
Example #6
0
        // Update is called once per frame
        void Update()
        {
            if (needed == false)
            {
                try
                {
                    if (hex.location != null)
                    {
                        foreach (Property p in hex.location.properties)
                        {
                            if (p.outer != null)
                            {
                                Destroy(p.outer.gameObject);
                            }
                        }
                    }
                    Destroy(this.gameObject);
                }
                catch (Exception e)
                {
                    World.log(e.ToString());
                }
                return;
            }
            transform.localPosition = GraphicalMap.getLoc(this);

            if (this.societyNameTag != null)
            {
                this.societyNameTag.gameObject.SetActive((GraphicalMap.scale != GraphicalMap.minScale) == Input.GetKey(KeyCode.LeftControl));
            }
        }
Example #7
0
        public void agent_Standard()
        {
            overmind.map.overmind.availableEnthrallments -= 1;
            World.log("Spawning tester dark at turn " + overmind.map.turn);
            Location spawn = null;

            foreach (Unit u in overmind.map.units)
            {
                if (u is Unit_TesterDark)
                {
                    spawn = u.location.getNeighbours()[0];
                }
            }
            if (spawn == null)
            {
                spawn = overmind.map.locations[Eleven.random.Next(overmind.map.locations.Count)];
            }

            Unit agent = new Unit_TesterDark(spawn, overmind.map.soc_dark);

            agent.person       = new Person(overmind.map.soc_dark);
            agent.person.state = Person.personState.enthralledAgent;
            agent.person.unit  = agent;
            overmind.map.units.Add(agent);

            Evidence ev = new Evidence(overmind.map.turn);

            ev.pointsTo = agent;
            ev.weight   = 0.66;
            agent.location.evidence.Add(ev);

            agent.task = null;

            GraphicalMap.panTo(spawn.hex.x, spawn.hex.y);
        }
Example #8
0
        public override void turnTick(Unit unit)
        {
            Property disease = null;

            foreach (Property pr in unit.location.properties)
            {
                if (pr.proto.isDisease)
                {
                    disease = pr;
                    World.log("On disease");
                    break;
                }
            }
            if (disease == null)
            {
                World.log("No disease present");
                unit.task = null; return;
            }

            disease.charge -= 2;
            if (disease.charge < 0)
            {
                disease.charge = 0;
            }
        }
        public void setTextFieldsToCurrentValues()
        {
            World.log("Setting seed " + currentSeed);
            if (suspicionGain != null)
            {
                suspicionGain.text            = "" + susGainPercent;
                powerGain.text                = "" + powerGainPercent;
                awarenessGain.text            = "" + awarenessGainSpeed;
                investigatorPercentField.text = "" + investigatorCount;
                armyStrengthField.text        = "" + armyHPMult;
                secField.text = "" + bonusSecurity;
            }
            seedField.text       = "" + currentSeed;
            sizeXField.text      = "" + sizeX;
            sizeYField.text      = "" + sizeY;
            historicalField.text = "" + burnIn;
            agentCount.text      = "" + nAgents;

            if (difficultySetting == 0)
            {
                tDifficulty.text = "Difficulty: Easy";
            }
            if (difficultySetting == 1)
            {
                tDifficulty.text = "Difficulty: Medium";
            }
            if (difficultySetting == 2)
            {
                tDifficulty.text = "Difficulty: Hard";
            }
            if (difficultySetting == 3)
            {
                tDifficulty.text = "Difficulty: Harder";
            }
        }
 public void takeCheatCommand()
 {
     World.log("World.map: " + world.map);
     World.log("Cheatfield.text " + cheatField.text);
     Cheat.takeCommand(world.map, cheatField.text);
     cheatField.text = "";
 }
Example #11
0
        public void warAI()
        {
            World.log("UNDEAD WAR AI");
            HashSet <Location> closed = new HashSet <Location>();
            HashSet <Location> open   = new HashSet <Location>();
            HashSet <Location> open2  = new HashSet <Location>();

            closed.Add(location);
            open.Add(location);

            int      c      = 0;
            Location target = null;

            for (int tries = 0; tries < 128; tries++)
            {
                open2.Clear();
                foreach (Location loc in open)
                {
                    foreach (Location l2 in loc.getNeighbours())
                    {
                        if (!closed.Contains(l2))
                        {
                            closed.Add(l2);
                            open2.Add(l2);
                        }
                        if (l2.soc != null && l2.soc.getRel(this.society).state == DipRel.dipState.war)
                        {
                            c += 1;
                            if (Eleven.random.Next(c) == 0)
                            {
                                target = l2;
                            }
                        }
                        foreach (Unit u2 in l2.units)
                        {
                            if (this.society.getRel(u2.society).state == DipRel.dipState.war)
                            {
                                c += 1;
                                if (Eleven.random.Next(c) == 0)
                                {
                                    target = l2;
                                }
                            }
                        }
                    }
                }
                if (target != null)
                {
                    break;
                }                             //Now found the closest unit set
                open  = open2;
                open2 = new HashSet <Location>();
            }

            if (target != null)
            {
                task = new Task_GoToLocationAgressively(target);
            }
        }
Example #12
0
        public override void implement(VoteOption option)
        {
            base.implement(option);
            EconEffect effect = new EconEffect(society.map, option.econ_from, option.econ_to);

            World.log(society.getName() + " implements economic policy, moving focus from " + option.econ_from.name + " to " + option.econ_to.name);
            society.econEffects.Add(effect);
        }
        private void declarePeace(DipRel rel)
        {
            World.log("Peace breaks out between " + rel.a.getName() + " and " + rel.b.getName());

            turnMessages.Add(new MsgEvent("The war between " + rel.war.att.getName() + " and " + rel.war.def.getName() + " winds down", MsgEvent.LEVEL_YELLOW, false));

            rel.war   = null;
            rel.state = DipRel.dipState.none;
        }
 public void inputFieldEditEnd()
 {
     World.log("Trying to write " + customSaveLocation.text + " as custom save location");
     if (Directory.Exists(customSaveLocation.text))
     {
         World.log("Success on previous");
         World.saveFolder = customSaveLocation.text + World.separator;
     }
 }
        internal override void takeAssault(SocialGroup sg, SocialGroup defender, double theirLosses)
        {
            int deltaP = Eleven.random.Next(location.map.param.combat_popDamageMax + 1);
            int deltaI = Eleven.random.Next(location.map.param.combat_infraDamageMax + 1);

            World.log("Damage received " + deltaP + " " + deltaI);
            population     = Math.Max(1, population - deltaP);
            infrastructure = Math.Max(1, infrastructure - deltaI);
        }
 public static void shutdownSteamAPI()
 {
     if (!apiShutdown)
     {
         apiShutdown = true;
         SteamAPI.Shutdown();
         World.log("Steam shutdown call issued");
     }
 }
        public void dismissToNextAge()
        {
            ui.world.audioStore.playClick();

            World.log("Progressing to next age");

            World.staticMap.overmind.progressToNextAge();

            ui.removeBlocker(this.gameObject);
        }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);

            Property.addProperty(map, hex.location, "Cult of the Deep");
            World.log("Properties: " + hex.location.properties.Count);

            map.world.prefabStore.popImgMsg("You call to the land, starting a cult in " + hex.location.getName() + ". Humans will slowly convert and join your Deep One Forces, but the rest will fear them.",
                                            map.world.wordStore.lookup("ABILITY_FISHMAN_CALL"));
        }
 public virtual void cast(Map map, Hex hex)
 {
     map.overmind.power -= getCost();
     if (map.param.overmind_singleAbilityPerTurn)
     {
         map.overmind.hasTakenAction = true;
     }
     World.log("Cast " + this.ToString() + " " + this.getName());
     turnLastCast = map.turn;
 }
 public void cast(Map map, Person person)
 {
     if (map.param.overmind_singleAbilityPerTurn)
     {
         map.overmind.hasTakenAction = true;
     }
     World.log("Cast " + this.ToString() + " " + this.getName());
     turnLastCast = map.turn;
     castInner(map, person);
 }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);

            Property.addProperty(map, hex.location, "Cult of the Deep");
            World.log("Properties: " + hex.location.properties.Count);

            map.world.prefabStore.popImgMsg("You call to the land, starting a cult in " + hex.location.getName() + ". " +
                                            "Humans will slowly convert and join your Deep One Forces, but the rest will fear them. Those which are present allow you to gain access to the settlement, as they yield to your dark will, increasing infiltration.",
                                            map.world.wordStore.lookup("ABILITY_FISHMAN_CALL"));
        }
Example #22
0
 public override string ToString()
 {
     try
     {
         return("Rebalance Economy (" + econFrom.name + "/" + econTo.name + ")");
     }catch (Exception e)
     {
         World.log("Null pointer in econ rebalance");
         return("Rebalance economy");
     }
 }
Example #23
0
        public void takeLocationFromOther(SocialGroup att, SocialGroup def, Location taken)
        {
            World.log(att.getName() + " takes " + taken.getName() + " from " + def.getName());
            int  priority = MsgEvent.LEVEL_YELLOW;
            bool benefit  = !def.hasEnthralled();

            if (att.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_GREEN;
            }
            else if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            else
            {
                priority = MsgEvent.LEVEL_YELLOW;
            }


            addMessage(new MsgEvent(att.getName() + " takes " + taken.getName() + " from " + def.getName(), priority, benefit));

            if (taken.settlement != null)
            {
                if (taken.settlement.isHuman == false)
                {
                    taken.settlement = null;//Burn it down
                }
                else if (taken.settlement.title != null && taken.settlement.title.heldBy != null)
                {
                    Person lord = taken.settlement.title.heldBy;
                    if (att is Society)
                    {
                        Society socAtt = (Society)att;
                        lord.prestige *= param.combat_prestigeLossFromConquest;
                        foreach (Title t in lord.titles)
                        {
                            t.heldBy = null;
                        }
                        lord.titles.Clear();


                        movePerson(lord, socAtt);
                    }
                    else
                    {
                        lord.die("Killed by " + att.getName() + " when " + taken.getName() + " fell");
                    }
                }
            }

            taken.soc = att;
            att.takeLocationFromOther(def, taken);
        }
Example #24
0
 public void setTextFieldsToCurrentValues()
 {
     World.log("Setting seed " + currentSeed);
     suspicionGain.text   = "" + susGainPercent;
     powerGain.text       = "" + powerGainPercent;
     awarenessGain.text   = "" + awarenessGainSpeed;
     seedField.text       = "" + currentSeed;
     sizeXField.text      = "" + sizeX;
     sizeYField.text      = "" + sizeY;
     historicalField.text = "" + burnIn;
 }
Example #25
0
        public void save(string filename)
        {
            try
            {
                World world = this;
                // world.ui.setToMainMenu();
                GraphicalMap.purge();
                GraphicalSociety.purge();
                world.map.world = null;


                //foreach (SocialGroup sg in map.socialGroups)
                //{
                //    if (sg is Society)
                //    {
                //        Society soc = (Society)sg;
                //        soc.voteSession = null;
                //    }
                //}

                fsSerializer _serializer = new fsSerializer();
                fsData       data;
                _serializer.TrySerialize(typeof(Map), map, out data).AssertSuccessWithoutWarnings();

                // emit the data via JSON
                string saveString = fsJsonPrinter.CompressedJson(data);
                World.Log("Save exit point");

                if (File.Exists(filename))
                {
                    World.Log("Overwriting old save: " + filename);
                    File.Delete(filename);
                }
                File.WriteAllLines(filename, new string[] { saveString });

                world.map.world = world;
                staticMap       = map;

                world.prefabStore.popMsg("Game saved as: " + filename);

                //// step 1: parse the JSON data
                //fsData data = fsJsonParser.Parse(serializedState);

                //// step 2: deserialize the data
                //object deserialized = null;
                //_serializer.TryDeserialize(data, type, ref deserialized).AssertSuccessWithoutWarnings();
            }catch (Exception e)
            {
                World.log(e.Message);
                World.log(e.StackTrace);
                prefabStore.popMsg("Failure to save");
                prefabStore.popMsg("Exception: " + e.StackTrace);
            }
        }
        public void checkPopulation()
        {
            foreach (Person p in people)
            {
                p.turnTick();
            }

            int nUntitled = 0;

            foreach (Person p in people)
            {
                if (p.title_land == null)
                {
                    nUntitled += 1;
                }
            }
            int nNeeded = map.param.soc_untitledPeople - nUntitled;

            //Insta-add enough to make up the numbers
            for (int i = 0; i < nNeeded; i++)
            {
                Person p = new Person(this);
                log(p.getFullName() + " has risen to note in the society of " + this.getName());
                people.Add(p);
            }

            if (nUntitled > map.param.soc_untitledPeople)
            {
                Person lastUntitled = null;
                foreach (Person p in people)
                {
                    if (p.state == Person.personState.enthralled)
                    {
                        continue;
                    }
                    if (p.title_land == null)
                    {
                        lastUntitled = p;
                    }
                }
                if (lastUntitled != null)
                {
                    string str = lastUntitled.getFullName() + " has no title, and has lost lordship in " + this.getName();
                    log(str);
                    World.log(str);
                    people.Remove(lastUntitled);
                    if (this.hasEnthralled())
                    {
                        map.addMessage(str);
                    }
                }
            }
        }
        static void loadMod(string mod)
        {
            foreach (var path in Directory.EnumerateFiles(mod, "*.json"))
            {
                try
                {
                    string    data = File.ReadAllText(path);
                    EventData ev   = JsonUtility.FromJson <EventData>(data);

                    // The above pattern will also load mod.json, stop this.
                    if (String.IsNullOrEmpty(ev.id))
                    {
                        continue;
                    }

                    if (!events.ContainsKey(ev.id))
                    {
                        events.Add(ev.id, new ActiveEvent(ev));
                    }
                    else
                    {
                        World.Log("Ignoring duplicate event " + ev.id);
                        World.self.ui.uiMainMenu.errorMessage.text = "Duplicate event ID detected: " + ev.id;
                    }
                }
                catch (Exception e)
                {
                    string msg = "[" + path + "] could not load event: " + e.Message;
                    World.Log(msg);
                    World.self.ui.uiMainMenu.errorMessage.text = msg;
                    //World.self.prefabStore.popMsg("[" + path + "] could not load event: " + e.Message);
                }
            }
            foreach (var imgpath in Directory.EnumerateFiles(mod, "*.jpg"))
            {
                try
                {
                    World.log("Narr Event img found " + imgpath);
                    string[] split   = imgpath.Split(World.separator[0]);
                    string   imgName = split[split.Length - 2] + "." + split[split.Length - 1];
                    //Sprite loaded = TextureStore.LoadPNG(imgpath);
                    LoadImage(imgpath, imgName);
                    World.log("Narr Event Saving loaded image " + imgName);
                }
                catch (Exception e)
                {
                    string msg = "[" + imgpath + "] could not load img: " + e.Message;
                    World.Log(msg);
                    World.self.ui.uiMainMenu.errorMessage.text = msg;
                    //World.self.prefabStore.popMsg("[" + path + "] could not load event: " + e.Message);
                }
            }
        }
Example #28
0
        public void victory()
        {
            endOfGameAchieved = true;
            AchievementManager.unlockAchievement(SteamManager.achievement_key.VICTORY);
            World.log("VICTORY DETECTED");
            map.world.prefabStore.popVictoryBox();

            if (!map.hasEnthralledAnAgent)
            {
                AchievementManager.unlockAchievement(SteamManager.achievement_key.POLITICS_ONLY);
            }
        }
Example #29
0
        public override void implement(VoteOption option)
        {
            base.implement(option);
            Person target = option.person;
            bool   isGood = (target.state != Person.personState.enthralled) && (target.state != Person.personState.broken) && (target.shadow < 0.5);

            society.map.turnMessages.Add(new MsgEvent(society.getName() + " has voted to dismiss " + target.getFullName() + " from court.", MsgEvent.LEVEL_RED, isGood));

            World.log("Dismiss from court");
            //World.staticMap.world.prefabStore.popMsg("Dismiss from court " + option.person.getFullName());
            option.person.removeFromGame("Dismissed from court");
        }
        public void startGame_Simplified()
        {
            useSimplified     = true;
            investigatorsSee  = false;
            useAwareness      = false;
            usePaladins       = false;
            allowLightbringer = false;

            World.log("Start streamlined");
            ui.removeBlocker(this.gameObject);
            ui.world.bStartGame(currentSeed, this);
        }