Esempio n. 1
0
        public static Settlement GetPreferableHideout(Clan preferredFaction, bool secondCall = false)
        {
            Settlement settlement;
            Hideout    hideout = TaleWorldsCode.BanditsCampaignBehaviour.SelectARandomHideout(preferredFaction, true, true, false);

            settlement = ((hideout != null) ? hideout.Owner.Settlement : null);
            if (settlement == null)
            {
                hideout    = TaleWorldsCode.BanditsCampaignBehaviour.SelectARandomHideout(preferredFaction, false, true, false);
                settlement = ((hideout != null) ? hideout.Owner.Settlement : null);
                if (settlement == null)
                {
                    hideout    = TaleWorldsCode.BanditsCampaignBehaviour.SelectARandomHideout(preferredFaction, false, false, false);
                    settlement = ((hideout != null) ? hideout.Owner.Settlement : null);
                    if (settlement == null && !secondCall) //in case the selected faction is invalid
                    {
                        List <Clan> clans  = Clan.BanditFactions.ToList();
                        Random      rnd    = new Random();
                        Clan        chosen = clans[rnd.Next(0, clans.Count)];
                        return(GetPreferableHideout(chosen, true));
                    }
                }
            }
            return(settlement);
        }
Esempio n. 2
0
 public L2HideoutManager(HideoutTemplate hideout)
 {
     this.hideout        = (Hideout)hideout;
     structureControlled = true;
     ai    = new AgitManagerAI();
     CurMP = 5000;
 }
Esempio n. 3
0
 public L2HideoutManager(HideoutTemplate hideout)
 {
     _hideout            = (Hideout)hideout;
     StructureControlled = true;
     _ai   = new AgitManagerAi();
     CurMp = 5000;
 }
Esempio n. 4
0
 public L2HideoutManager(int objectId, NpcTemplate template, HideoutTemplate hideout) : base(objectId, template)
 {
     _hideout            = (Hideout)hideout;
     StructureControlled = true;
     _ai   = new AgitManagerAi();
     CurMp = 5000;
 }
Esempio n. 5
0
    void initHideoutObjectInDecor(Hideout h, GameObject parent)
    {
        GameObject elem = InstantiatePrefabWithName(h.name);

        moveObjectToPlaceWithName(elem, h.pos);
        // specific case of hidout within a decor element => set parent
        elem.transform.SetParent(parent.transform);

        foreach (Element element in h.hiddenElements)
        {
            initElementInHiddedPos(element, elem);
        }
    }
Esempio n. 6
0
 public Room GetRoomFromHideout(Hideout hideout)
 {
     foreach (Room r in Rooms)
     {
         foreach (Hideout h in r.Hideouts)
         {
             if (h == hideout)
             {
                 return(r);
             }
         }
     }
     return(null);
 }
Esempio n. 7
0
    void initHideoutObject(Hideout h)
    {
        GameObject elem = InstantiatePrefabWithName(h.name);

        moveObjectToPlaceWithName(elem, h.pos);

        // change layer of subplaces with the new layer of the hideout that just moved
        string newLayer = elem.transform.GetComponent <SpriteRenderer>().sortingLayerName;
        int    order    = elem.transform.GetComponent <SpriteRenderer>().sortingOrder;

        for (int i = 0; i < elem.transform.childCount; i++)
        {
            Transform child = elem.transform.GetChild(i);
            child.GetComponent <SpriteRenderer>().sortingLayerName = newLayer;
            child.GetComponent <SpriteRenderer>().sortingOrder     = order;
        }

        foreach (Element element in h.hiddenElements)
        {
            initElementInHiddedPos(element, elem);
        }
    }
Esempio n. 8
0
    public List <Node> GetRandomPathToHideout(Node currentNode, Room currentRoom, HideoutType type)
    {
        List <Node> hideouts = new List <Node> ();

        while (hideouts.Count < 3)
        {
            Room r = Rooms [Random.Range(0, Rooms.Length)];
            if (r == currentRoom)
            {
                continue;
            }

            Hideout h = r.GetRandomHideoutOfType(type);
            if (!h.Available || hideouts.Contains(h))
            {
                continue;
            }

            hideouts.Add(h);
        }

        return(FindPath(currentNode, hideouts[Random.Range(0, 3)]));
    }
Esempio n. 9
0
        // Methods
        public override bool Test(Sim a, RabbitHole target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            if (!(a.Occupation is OmniCareer))
            {
                return(false);
            }

            GreyedOutTooltipCallback callback = null;
            LawEnforcement           job      = OmniCareer.Career <LawEnforcement>(a.Occupation);

            if ((job != null) && job.CanRaidCriminalWarehouses)
            {
                Hideout hideout = target as Hideout;
                if (hideout != null)
                {
                    DateAndTime time;
                    if (!hideout.mSimToLastRaidTimestamp.TryGetValue(a, out time))
                    {
                        return(true);
                    }
                    if (SimClock.ElapsedTime(TimeUnit.Hours, time, SimClock.CurrentTime()) >= Hideout.kMinimumDurationBetweenCriminalRaids)
                    {
                        return(true);
                    }
                    if (callback == null)
                    {
                        callback = delegate
                        {
                            return(Hideout.RaidCriminals.LocalizeString("CannotUseHideout", new object[] { a }));
                        };
                    }
                    greyedOutTooltipCallback = callback;
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 10
0
        public void Initialize()
        {
            using (StreamReader reader = new StreamReader(new FileInfo(@"scripts\structure_spawn.txt").FullName))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (line.Length == 0 || line.StartsWith("#"))
                    {
                        continue;
                    }

                    string[]       pt    = line.Split('\t');
                    StructureSpawn spawn = new StructureSpawn();
                    spawn.npcId = Convert.ToInt32(pt[0]);

                    for (byte ord = 1; ord < pt.Length; ord++)
                    {
                        string parameter = pt[ord];
                        string value     = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);

                        switch (parameter.Split('{')[0].ToLower())
                        {
                        case "spawn":
                            spawn.SetLocation(value.Split(' '));
                            break;

                        case "resp":
                            spawn.respawnSec = Convert.ToInt32(value);
                            break;
                        }
                    }

                    spawns.Add(spawn.npcId, spawn);
                }
            }

            using (StreamReader reader = new StreamReader(new FileInfo(@"scripts\structures.txt").FullName))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (line.Length == 0 || line.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] pt = line.Split('\t');

                    HideoutTemplate template = null;
                    switch (pt[1])
                    {
                    case "hideout":
                        template = new Hideout();
                        break;
                    }

                    template.ID = Convert.ToInt32(pt[0]);

                    for (byte ord = 2; ord < pt.Length; ord++)
                    {
                        string parameter = pt[ord];
                        string value     = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);

                        switch (parameter.Split('{')[0].ToLower())
                        {
                        case "npc":
                        {
                            foreach (string str in value.Split(' '))
                            {
                                template.SetNpc(Convert.ToInt32(str));
                            }
                        }
                        break;

                        case "door":
                        {
                            foreach (string str in value.Split(' '))
                            {
                                template.SetDoor(Convert.ToInt32(str));
                            }
                        }
                        break;

                        case "spawn":
                            template.SetOwnerRespawn(value.Split(' '));
                            break;

                        case "outside":
                            template.SetOutsideRespawn(value.Split(' '));
                            break;

                        case "banish":
                            template.SetBanishRespawn(value.Split(' '));
                            break;

                        case "zone":
                        {
                            foreach (string str in value.Split(';'))
                            {
                                template.SetZoneLoc(str.Split(' '));
                            }
                        }
                        break;
                        }
                    }

                    structures.Add(template.ID, template);
                }
            }

            CLogger.info("Structs: loaded " + structures.Count + " templates.");
            CLogger.info("Hideouts: " + hideouts.Count + ".");

            foreach (HideoutTemplate st in structures.Values)
            {
                st.init();
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            int[]     arr  = { 1, 2, 3, 4, 5, 6, 6, 7, 41, 8, 52, 5869, 5674, 4 }; //new int[8];
            ArrayList alst = new ArrayList();

            alst.Add(1);
            alst.Add(2);
            alst.Add(5);
            alst.Add(654);
            alst.Add(541);
            alst.Add("Hello");
            alst.Add(new Citizen());
            alst.Add(new Button());

            List <int> ilst = new List <int>();

            ilst.Add(1);
            ilst.Add(2);
            ilst.Add(5);
            ilst.Add(654);
            ilst.Add(541);

            //int sum = 0;
            //for (int i = 0; i < alst.Count; i++) {
            //    sum += ilst[i];
            //}
            //MessageBox.Show(sum.ToString());

            SuperHero[] sups = new SuperHero[4];
            sups[0] = new SuperHero("mad", "mike");
            sups[1] = new SuperHero("mad", "mike");
            sups[2] = new SuperHero("mad", "mike");
            sups[3] = new SuperHero("mad", "mike");
            // sups[4] = new SuperHero("mad","mike");

            List <SuperHero> supd = new List <SuperHero>(5);
            SuperHero        s    = new SuperHero("Bob", "Awesome");
            //MessageBox.Show(sups.Length + " | " + supd.Count().ToString());


            Hideout <SuperHero> hallOfJustice = new Hideout <SuperHero>();

            hallOfJustice.Members.Add(Universe.SuperHeroes[0]);
            hallOfJustice.Members.Add(Universe.SuperHeroes[1]);
            hallOfJustice.Members.Add(Universe.SuperHeroes[2]);
            hallOfJustice.Members.Add(Universe.SuperHeroes[3]);
            //hallOfJustice.Members.Add(Universe.Villians[0]);

            Hideout <Villian> hallOfDoom = new Hideout <Villian>();

            hallOfDoom.Members.Add(Universe.Villians[0]);
            hallOfDoom.Members.Add(Universe.Villians[2]);
            hallOfDoom.Members.Add(Universe.Villians[3]);
            hallOfDoom.Members.Add(Universe.Villians[1]);

            Hideout <int> calculator = new Hideout <int>();

            calculator.Members.Add(1);
            calculator.Members.Add(2);
            calculator.Members.Add(4);
            calculator.Members.Add(5);
            //calculator.Members.Add(87.3);

            Hideout <Person> poweredAnonymous = new Hideout <Person>();

            poweredAnonymous.Members.Add(Universe.SuperHeroes[0]);
            poweredAnonymous.Members.Add(Universe.SuperHeroes[1]);
            poweredAnonymous.Members.Add(Universe.Villians[2]);
            poweredAnonymous.Members.Add(Universe.Villians[3]);

            Prison <SuperHero, Villian> arkamAsylum = new Prison <SuperHero, Villian>();

            arkamAsylum.Jailor = Universe.SuperHeroes[0];
            arkamAsylum.Inmates.Add(Universe.Villians[2]);
            arkamAsylum.Inmates.Add(Universe.Villians[3]);

            Prison <Villian, SuperHero> smampPlace = new Prison <Villian, SuperHero>();

            smampPlace.Jailor = Universe.Villians[0];
            smampPlace.Inmates.Add(Universe.SuperHeroes[2]);
            smampPlace.Inmates.Add(Universe.SuperHeroes[3]);

            Prison <SuperHero, Citizen> p = new Prison <SuperHero, Citizen>();

            List <int> mInts = new List <int>();
            Dictionary <int, string> dict = new Dictionary <int, string>();

            Tuple <string, int, int, string, double> t;// = new Tuple<string, int, int, string, double>()



            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);
            supd.Add(s);

            //MessageBox.Show(sups.Length + " | " + supd.Count().ToString());
        }
Esempio n. 12
0
        public void read()
        {
            StreamReader reader = new StreamReader(new FileInfo(@"scripts\structure_spawn.txt").FullName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line.Length == 0 || line.StartsWith("#"))
                {
                    continue;
                }

                string[]       pt    = line.Split('\t');
                StructureSpawn spawn = new StructureSpawn();
                spawn.npcId = Convert.ToInt32(pt[0]);

                for (byte ord = 1; ord < pt.Length; ord++)
                {
                    string parameter = pt[ord];
                    string value     = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);

                    switch (parameter.Split('{')[0].ToLower())
                    {
                    case "spawn":
                        spawn.SetLocation(value.Split(' '));
                        break;

                    case "resp":
                        spawn.respawnSec = Convert.ToInt32(value);
                        break;
                    }
                }

                spawns.Add(spawn.npcId, spawn);
            }
            reader.Close();

            reader = new StreamReader(new FileInfo(@"scripts\structures.txt").FullName);
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line.Length == 0 || line.StartsWith("#"))
                {
                    continue;
                }

                string[] pt = line.Split('\t');

                HideoutTemplate template = null;
                switch (pt[1])
                {
                case "hideout":
                    template = new Hideout();
                    break;
                }

                template.ID = Convert.ToInt32(pt[0]);

                for (byte ord = 2; ord < pt.Length; ord++)
                {
                    string parameter = pt[ord];
                    string value     = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);

                    switch (parameter.Split('{')[0].ToLower())
                    {
                    case "npc":
                    {
                        foreach (string str in value.Split(' '))
                        {
                            template.SetNpc(Convert.ToInt32(str));
                        }
                    }
                    break;

                    case "door":
                    {
                        foreach (string str in value.Split(' '))
                        {
                            template.SetDoor(Convert.ToInt32(str));
                        }
                    }
                    break;

                    case "spawn":
                        template.SetOwnerRespawn(value.Split(' '));
                        break;

                    case "outside":
                        template.SetOutsideRespawn(value.Split(' '));
                        break;

                    case "banish":
                        template.SetBanishRespawn(value.Split(' '));
                        break;

                    case "zone":
                    {
                        foreach (string str in value.Split(';'))
                        {
                            template.SetZoneLoc(str.Split(' '));
                        }
                    }
                    break;
                    }
                }

                structures.Add(template.ID, template);
            }
            reader.Close();

            //{
            //    MySqlConnection connection = SQLjec.getInstance().conn();
            //    MySqlCommand cmd = connection.CreateCommand();

            //    connection.Open();

            //    cmd.CommandText = "SELECT * FROM st_hideouts";
            //    cmd.CommandType = CommandType.Text;


            //    MySqlDataReader msreader = cmd.ExecuteReader();

            //    while (msreader.Read())
            //    {
            //        int id = msreader.GetInt32("id");
            //        Hideout hideout = (Hideout)structures[id];

            //        hideout.Name = msreader.GetString("name");
            //        hideout.Descr = msreader.GetString("descr");
            //        //TODO paytime

            //        for (byte a = 1; a <= 12; a++)
            //            hideout.Decoration[a] = msreader.GetInt32("func_" + a);

            //        hideouts.Add(hideout.ID, hideout);
            //    }

            //    reader.Close();
            //    connection.Close();
            //}

            CLogger.info("Structs: loaded " + structures.Count + " templates.");
            CLogger.info("Hideouts: " + hideouts.Count + ".");
        }
Esempio n. 13
0
 public L2Doormen(int objectId, NpcTemplate template, HideoutTemplate hideout) : base(objectId, template)
 {
     _hideout            = (Hideout)hideout;
     StructureControlled = true;
 }
Esempio n. 14
0
 public L2Doormen(HideoutTemplate hideout)
 {
     this.hideout        = (Hideout)hideout;
     structureControlled = true;
 }
Esempio n. 15
0
    public void LoadMyXML()
    {
        Debug.Log("Load XML file...");
        XmlDocument xmlDoc = new XmlDocument();         // xmlDoc is the new xml document.
        WWW         www;
        //#if UNITY_EDITOR

        /*if (xmlLocalFile != null) {
         *      print ("Local XML file found => load default local file");
         *      xmlDoc.LoadXml (xmlLocalFile.text);
         * } else {
         *      // Start a download of the given URL
         *      www = new WWW ("file:///Users/plaforcade/Documents/Boulot/iWorkspaces/workspace4ESCAPEGAMERK/FlatModel4Unity/model/Scenario_OUT.flatmodel");
         *      print("local xml file not found... => load scenario from generator");
         *      xmlDoc.LoadXml(www.text);
         * }*/
        //#endif

        //#if UNITY_ANDROID
        string path         = Application.persistentDataPath + "/XMLFiles/";
        string completeFile = "file://" + path + localFileName4Android + ".xml";

        print(completeFile);
        www = new WWW(completeFile);
        //yield return www;
        //string xml = File.ReadAllText(www.text);
        xmlDoc.LoadXml(www.text);
        //#endif

        XmlNodeList levelsList = xmlDoc.GetElementsByTagName("level");         // array of the level nodes.

        maxScenes = levelsList.Count;

        levels = new LevelData[maxScenes];
        int cpt = 0;

        foreach (XmlNode levelInfo in levelsList)
        {
            LevelData newLevel = new LevelData();
            newLevel.sceneName       = levelInfo.Attributes["scene"].Value;
            newLevel.difficulty      = levelInfo.Attributes["difficulty"].Value;
            newLevel.nbObjectsToFind = int.Parse(levelInfo.Attributes["nbElementsToPlace"].Value);
            levels [cpt++]           = newLevel;


            XmlNodeList levelcontent = levelInfo.ChildNodes;

            List <Element>        elems    = new List <Element> ();
            List <SolutionObject> sols     = new List <SolutionObject> ();
            List <PlacedDecor>    decors   = new List <PlacedDecor> ();
            List <Hideout>        hideouts = new List <Hideout> ();

            foreach (XmlNode levelsItens in levelcontent)             // levels itens nodes.
            {
                if (levelsItens.Name == "element")
                {
                    Element elem = new Element();
                    elem.name = levelsItens.Attributes ["name"].Value;
                    elem.pos  = levelsItens.Attributes ["pos"].Value;
                    elems.Add(elem);
                    //obj.Add("name",levelsItens.InnerText); // put this in the dictionary.
                }
                if (levelsItens.Name == "solutionobject")
                {
                    SolutionObject elem = new SolutionObject();
                    elem.name             = levelsItens.Attributes ["name"].Value;
                    elem.pos              = levelsItens.Attributes ["pos"].Value;
                    elem.acceptedElements = levelsItens.Attributes ["acceptedElements"].Value;
                    elem.targetedSkill    = levelsItens.Attributes ["targetedSkill"].Value;
                    elem.nbElem2Find      = int.Parse(levelsItens.Attributes ["nbSol2Find"].Value);
                    List <Element>      subElem  = new List <Element> ();
                    List <SolutionArea> solAreas = new List <SolutionArea> ();

                    foreach (XmlNode sub in levelsItens.ChildNodes)
                    {
                        if (sub.Name == "element")
                        {
                            Element subelement = new Element();
                            subelement.name = sub.Attributes ["name"].Value;
                            subelement.pos  = sub.Attributes ["pos"].Value;
                            subElem.Add(subelement);
                            //obj.Add("name",levelsItens.InnerText); // put this in the dictionary.
                        }
                        if (sub.Name == "solutionarea")
                        {
                            SolutionArea area = new SolutionArea();
                            area.pos             = sub.Attributes ["pos"].Value;
                            area.acceptedElement = sub.Attributes ["acceptedElement"].Value;

                            solAreas.Add(area);
                        }
                    }
                    elem.elements      = (Element[])subElem.ToArray();
                    elem.solutionAreas = (SolutionArea[])solAreas.ToArray();
                    sols.Add(elem);
                    //obj.Add("name",levelsItens.InnerText); // put this in the dictionary.
                }

                if (levelsItens.Name == "placeddecor")
                {
                    PlacedDecor elem = new PlacedDecor();
                    elem.name = levelsItens.Attributes ["name"].Value;

                    List <Element> subElem    = new List <Element> ();
                    List <Hideout> subHidouts = new List <Hideout> ();

                    foreach (XmlNode sub in levelsItens.ChildNodes)
                    {
                        if (sub.Name == "element")
                        {
                            Element subelement = new Element();
                            subelement.name = sub.Attributes ["name"].Value;
                            subelement.pos  = sub.Attributes ["pos"].Value;
                            subElem.Add(subelement);
                        }

                        if (sub.Name == "hideout")
                        {
                            Hideout hidoutInDecor = new Hideout();
                            hidoutInDecor.name = sub.Attributes ["name"].Value;
                            subHidouts.Add(hidoutInDecor);

                            List <Element> subHidoutElem = new List <Element> ();

                            foreach (XmlNode sub2 in sub.ChildNodes)
                            {
                                if (sub2.Name == "element")
                                {
                                    Element hidoutElement = new Element();
                                    hidoutElement.name = sub2.Attributes ["name"].Value;
                                    hidoutElement.pos  = sub2.Attributes ["pos"].Value;
                                    subHidoutElem.Add(hidoutElement);
                                }
                            }
                            hidoutInDecor.hiddenElements = (Element[])subHidoutElem.ToArray();
                        }
                    }
                    elem.elements = (Element[])subElem.ToArray();
                    elem.hideouts = (Hideout[])subHidouts.ToArray();
                    decors.Add(elem);
                    //obj.Add("name",levelsItens.InnerText); // put this in the dictionary.
                }

                if (levelsItens.Name == "hideout")
                {
                    Hideout elem = new Hideout();
                    elem.name = levelsItens.Attributes ["name"].Value;
                    elem.pos  = levelsItens.Attributes ["pos"].Value;

                    List <Element> subElem = new List <Element> ();

                    foreach (XmlNode sub in levelsItens.ChildNodes)
                    {
                        if (sub.Name == "element")
                        {
                            Element subelement = new Element();
                            subelement.name = sub.Attributes ["name"].Value;
                            subelement.pos  = sub.Attributes ["pos"].Value;
                            subElem.Add(subelement);
                        }
                    }
                    elem.hiddenElements = (Element[])subElem.ToArray();
                    hideouts.Add(elem);
                    //obj.Add("name",levelsItens.InnerText); // put this in the dictionary.
                }
            }

            newLevel.elements        = (Element[])elems.ToArray();
            newLevel.solutionObjects = (SolutionObject[])sols.ToArray();
            newLevel.placedDecors    = (PlacedDecor[])decors.ToArray();
            newLevel.hideouts        = (Hideout[])hideouts.ToArray();
            currentScene             = 0;
        }
    }
Esempio n. 16
0
 public L2Doormen(HideoutTemplate hideout)
 {
     _hideout            = (Hideout)hideout;
     StructureControlled = true;
 }
Esempio n. 17
0
 public AgitDecoInfo(Hideout hideout)
 {
     _hideout = hideout;
 }
Esempio n. 18
0
 public AgitDecoInfo(Hideout hideout)
 {
     this.hideout = hideout;
 }