Ejemplo n.º 1
0
    public MinesIndicator(int[] dims)
    {
        _dims = dims;
        _matrix = new int[dims[0],dims[1],dims[2]];

        for (int i=0; i<_dims[0]; i++)
            for(int j=0; j<_dims[1]; j++)
                for (int k=0; k< _dims[2]; k++)
                    _matrix[i,j,k] = 0;
        self = new Self();
    }
Ejemplo n.º 2
0
        private VcallSubsystem(VcallConfiguration vconfig)
        {
            _connectivityTag = Helpers.GetRandomName();

            Logger.Config = vconfig.Logging;
            _countersDb = CountersDb.New();

            using (Context.With(_countersDb))
            {
                _self = new Self();
                _engine = new Engine(_self);

                var resolvingConfig = FillPropertiesOf<HostResolverConfiguration>.From(vconfig);

                _self.mutex = new Object();
                _self.vconfig = vconfig;
                _self.repo = Repository.New();
                _self.resolver = HostResolver.New(resolvingConfig);
                _self.connectivity = ConnectivityManager.New();

                _self.counters = _countersDb.NewCounters();
            }
        }
Ejemplo n.º 3
0
        void connectAndPrepare()
        {
            Console.WriteLine(welcomeText);

            //read previous conversation ID
            try
            {
                StreamReader idFile = new StreamReader(appDataPath + programFolder + @"\nextConvId.txt");
                nextConvId = int.Parse(idFile.ReadLine());
                consoleWriteLine("Last conversation number found: " + nextConvId);
            }
            catch(Exception _ex)
            {
                nextConvId = 1;
                consoleWriteLine("No previous conversation number found. Using default.");
            }

            LyncClient client = null;
            bool tryAgain = false;
            int attempts = 0;
            int waittime = 5;
            do
            {
                tryAgain = false;
                attempts++;
                try
                {
                    if (attempts > 1)
                        consoleWriteLine(String.Format("Connecting to Lync Client. Attempt {0}...", attempts));
                    else
                        consoleWriteLine("Connecting to Lync Client...");
                    client = LyncClient.GetClient();
                }
                catch (LyncClientException _exception)
                {
                    tryAgain = true;
                    if (attempts <= 20)
                    {
                        consoleWriteLine(String.Format("Client not found. Trying again in {0} seconds.", waittime));
                        System.Threading.Thread.Sleep(waittime * 1000);
                    }
                    else
                    {
                        consoleWriteLine("Client not found. Too many attempts. Giving up.");
                        Console.ReadLine();
                        return;
                    }
                }
            } while (tryAgain);
            myself = client.Self;
            if (!Directory.Exists(mydocpath + programFolder))
                Directory.CreateDirectory(mydocpath + programFolder);
            if (!Directory.Exists(appDataPath + programFolder))
                Directory.CreateDirectory(appDataPath + programFolder);
            client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
            client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;
            consoleWriteLine("Ready!");
            consoleWriteLine();
            Console.ReadLine();
        }
Ejemplo n.º 4
0
 public StandardDateFilter getStandardDateFilter()
 {
     return(Self.getStandardDateFilter());
 }
Ejemplo n.º 5
0
 public bool equals(object obj)
 {
     return(Self.equals(obj));
 }
Ejemplo n.º 6
0
 public int hashCode()
 {
     return(Self.hashCode());
 }
Ejemplo n.º 7
0
        public static void handleGameState(string uri, string serverreply = "", string POST = "", string GET = "")
        {
            var SBRW_XML = new XmlDocument();

            string[] splitted_uri = uri.Split('/');

            if (uri == "/User/SecureLoginPersona")
            {
                canUpdateProfileField = true;
            }
            if (uri == "/User/SecureLogoutPersona")
            {
                PersonaId       = String.Empty;
                PersonaName     = String.Empty;
                PersonaLevel    = String.Empty;
                PersonaAvatarId = String.Empty;
                PersonaCarId    = String.Empty;
                PersonaCarName  = String.Empty;
            }

            //FIRST PERSONA EVER LOCALIZED IN CODE
            if (uri == "/User/GetPermanentSession")
            {
                try {
                    SBRW_XML.LoadXml(serverreply);

                    PersonaName     = SBRW_XML.SelectSingleNode("UserInfo/personas/ProfileData/Name").InnerText.Replace("¤", "[S]");
                    PersonaLevel    = SBRW_XML.SelectSingleNode("UserInfo/personas/ProfileData/Level").InnerText;
                    PersonaAvatarId = (SBRW_XML.SelectSingleNode("UserInfo/personas/ProfileData/IconIndex").InnerText == "26") ? "nfsw" : "avatar_" + SBRW_XML.SelectSingleNode("UserInfo/personas/ProfileData/IconIndex").InnerText;
                    PersonaId       = SBRW_XML.SelectSingleNode("UserInfo/personas/ProfileData/PersonaId").InnerText;

                    //Let's get rest of PERSONAIDs
                    XmlNode     UserInfo = SBRW_XML.SelectSingleNode("UserInfo");
                    XmlNodeList personas = UserInfo.SelectNodes("personas/ProfileData");
                    foreach (XmlNode node in personas)
                    {
                        PersonaIds.Add(node.SelectSingleNode("PersonaId").InnerText);
                    }
                } catch (Exception) {
                }
            }

            //CREATE/DELETE PERSONA Handler
            if (uri == "/DriverPersona/CreatePersona")
            {
                SBRW_XML.LoadXml(serverreply);
                PersonaIds.Add(SBRW_XML.SelectSingleNode("ProfileData/PersonaId").InnerText);
            }

            //DRIVING CARNAME
            if (uri == "/DriverPersona/GetPersonaInfo" && canUpdateProfileField == true)
            {
                SBRW_XML.LoadXml(serverreply);
                PersonaName     = SBRW_XML.SelectSingleNode("ProfileData/Name").InnerText.Replace("¤", "[S]");
                PersonaLevel    = SBRW_XML.SelectSingleNode("ProfileData/Level").InnerText;
                PersonaAvatarId = (SBRW_XML.SelectSingleNode("ProfileData/IconIndex").InnerText == "26") ? "nfsw" : "avatar_" + SBRW_XML.SelectSingleNode("ProfileData/IconIndex").InnerText;
                PersonaId       = SBRW_XML.SelectSingleNode("ProfileData/PersonaId").InnerText;
            }
            if (uri == "/matchmaking/leavelobby")
            {
                _presence.details        = "Driving " + PersonaCarName;
                _presence.state          = serverName;
                _presence.largeImageText = PersonaName + " - Level: " + PersonaLevel;
                _presence.largeImageKey  = PersonaAvatarId;
                _presence.smallImageText = "In-Freeroam";
                _presence.smallImageKey  = "gamemode_freeroam";
                _presence.startTimestamp = RPCstartTimestamp;
                _presence.instance       = true;
                DiscordRpc.UpdatePresence(_presence);

                eventTerminatedManually = true;
            }

            //IN LOBBY
            if (uri == "/matchmaking/acceptinvite")
            {
                SBRW_XML.LoadXml(serverreply);
                EventID = Convert.ToInt32(SBRW_XML.SelectSingleNode("LobbyInfo/EventId").InnerText);

                _presence.details        = "In Lobby: " + EventList.getEventName(EventID);
                _presence.state          = serverName;
                _presence.largeImageText = PersonaName + " - Level: " + PersonaLevel;
                _presence.largeImageKey  = PersonaAvatarId;
                _presence.smallImageText = EventList.getEventName(Convert.ToInt32(EventID));
                _presence.smallImageKey  = EventList.getEventType(Convert.ToInt32(EventID));
                _presence.startTimestamp = RPCstartTimestamp;
                _presence.instance       = true;
                DiscordRpc.UpdatePresence(_presence);

                eventTerminatedManually = false;
            }

            //IN SAFEHOUSE/FREEROAM
            if (uri == "/DriverPersona/UpdatePersonaPresence")
            {
                string UpdatePersonaPresenceParam = GET.Split(';').Last().Split('=').Last();
                if (UpdatePersonaPresenceParam == "1")
                {
                    _presence.details        = "Driving " + PersonaCarName;
                    _presence.smallImageText = "In-Freeroam";
                }
                else
                {
                    _presence.details        = "In Safehouse";
                    _presence.smallImageText = "In-Safehouse";
                }

                _presence.state          = serverName;
                _presence.largeImageText = PersonaName + " - Level: " + PersonaLevel;
                _presence.largeImageKey  = PersonaAvatarId;
                _presence.smallImageKey  = "gamemode_freeroam";
                _presence.startTimestamp = RPCstartTimestamp;
                _presence.instance       = true;
                DiscordRpc.UpdatePresence(_presence);
            }

            //IN EVENT
            if (Regex.Match(uri, "/matchmaking/launchevent").Success)
            {
                EventID = Convert.ToInt32(splitted_uri[3]);

                _presence.details        = "In Event: " + EventList.getEventName(EventID);
                _presence.state          = serverName;
                _presence.largeImageText = PersonaName + " - Level: " + PersonaLevel;
                _presence.largeImageKey  = PersonaAvatarId;
                _presence.smallImageText = EventList.getEventName(EventID);
                _presence.smallImageKey  = EventList.getEventType(EventID);
                _presence.startTimestamp = RPCstartTimestamp;
                _presence.instance       = true;
                DiscordRpc.UpdatePresence(_presence);

                eventTerminatedManually = false;
            }
            if (uri == "/event/arbitration")
            {
                _presence.details        = "In Event: " + EventList.getEventName(EventID);
                _presence.state          = serverName;
                _presence.largeImageText = PersonaName + " - Level: " + PersonaLevel;
                _presence.largeImageKey  = PersonaAvatarId;
                _presence.smallImageText = EventList.getEventName(EventID);
                _presence.smallImageKey  = EventList.getEventType(EventID);
                _presence.startTimestamp = RPCstartTimestamp;
                _presence.instance       = true;
                DiscordRpc.UpdatePresence(_presence);

                eventTerminatedManually = false;
            }
            if (uri == "/event/launched" && eventTerminatedManually == false)
            {
                _presence.details        = "In Event: " + EventList.getEventName(EventID);
                _presence.state          = serverName;
                _presence.largeImageText = PersonaName + " - Level: " + PersonaLevel;
                _presence.largeImageKey  = PersonaAvatarId;
                _presence.smallImageText = EventList.getEventName(EventID);
                _presence.smallImageKey  = EventList.getEventType(EventID);
                _presence.startTimestamp = Self.getTimestamp(true);
                _presence.instance       = true;
                DiscordRpc.UpdatePresence(_presence);
            }

            //CARS RELATED
            foreach (var single_personaId in PersonaIds)
            {
                if (Regex.Match(uri, "/personas/" + single_personaId + "/carslots", RegexOptions.IgnoreCase).Success)
                {
                    carslotsXML = serverreply;

                    SBRW_XML.LoadXml(carslotsXML);

                    int DefaultID = Convert.ToInt32(SBRW_XML.SelectSingleNode("CarSlotInfoTrans/DefaultOwnedCarIndex").InnerText);
                    int current   = 0;

                    XmlNode     CarsOwnedByPersona = SBRW_XML.SelectSingleNode("CarSlotInfoTrans/CarsOwnedByPersona");
                    XmlNodeList OwnedCarTrans      = CarsOwnedByPersona.SelectNodes("OwnedCarTrans");

                    foreach (XmlNode node in OwnedCarTrans)
                    {
                        if (DefaultID == current)
                        {
                            PersonaCarName = CarList.getCarName(node.SelectSingleNode("CustomCar/Name").InnerText);
                        }
                        current++;
                    }
                }
                if (Regex.Match(uri, "/personas/" + single_personaId + "/defaultcar", RegexOptions.IgnoreCase).Success)
                {
                    if (splitted_uri.Last() != "defaultcar")
                    {
                        string receivedId = splitted_uri.Last();

                        SBRW_XML.LoadXml(carslotsXML);
                        XmlNode     CarsOwnedByPersona = SBRW_XML.SelectSingleNode("CarSlotInfoTrans/CarsOwnedByPersona");
                        XmlNodeList OwnedCarTrans      = CarsOwnedByPersona.SelectNodes("OwnedCarTrans");

                        foreach (XmlNode node in OwnedCarTrans)
                        {
                            if (receivedId == node.SelectSingleNode("Id").InnerText)
                            {
                                PersonaCarName = CarList.getCarName(node.SelectSingleNode("CustomCar/Name").InnerText);
                            }
                        }
                    }
                }
            }
        }
 public int ordinal()
 {
     return(Self.ordinal());
 }
Ejemplo n.º 9
0
 // API
 public double getDistance(Location toLocation, string unit)
 {
     return(Self.getDistance(toLocation, unit));
 }
Ejemplo n.º 10
0
 private void orderPlacedHandler(OrderPlaced orderPlaced)
 {
     //TODO: Send email to customer
     Self.Tell(new ProcessPayment(orderPlaced.OrderId, orderPlaced.PaymentInfo));
 }
Ejemplo n.º 11
0
 public List <SortColumn> getSortBy()
 {
     return(Self.getSortBy());
 }
Ejemplo n.º 12
0
 /// <summary>Class constructor overload</summary><param name="s">Self object, Core.me</param><seealso cref="Jungler.Bot.Classes.Self"/>
 public Point3D(Self s)
 {
     SetPoint(s);
 }
Ejemplo n.º 13
0
 public bool getShowSubtotals()
 {
     return(Self.getShowSubtotals());
 }
Ejemplo n.º 14
0
 public bool getShowGrandTotal()
 {
     return(Self.getShowGrandTotal());
 }
Ejemplo n.º 15
0
 public string getScope()
 {
     return(Self.getScope());
 }
Ejemplo n.º 16
0
 public bool getHasRecordCount()
 {
     return(Self.getHasRecordCount());
 }
Ejemplo n.º 17
0
 public bool getHasDetailRows()
 {
     return(Self.getHasDetailRows());
 }
Ejemplo n.º 18
0
 public string getDivision()
 {
     return(Self.getDivision());
 }
Ejemplo n.º 19
0
 public List <StandardFilter> getStandardFilters()
 {
     return(Self.getStandardFilters());
 }
Ejemplo n.º 20
0
 public double getLongitude()
 {
     return(Self.getLongitude());
 }
Ejemplo n.º 21
0
 public TopRows getTopRows()
 {
     return(Self.getTopRows());
 }
Ejemplo n.º 22
0
 public void EscalateFailure(PID who, Exception reason)
 {
     Self.SendSystemMessage(SuspendMailbox.Instance);
     Parent.SendSystemMessage(new Failure(who, reason));
 }
Ejemplo n.º 23
0
 // API
 public string format()
 {
     return(Self.format());
 }
 public string toString()
 {
     return(Self.toString());
 }
Ejemplo n.º 25
0
 public void addError(Exception msg, bool escape)
 {
     Self.addError(msg, escape);
 }
Ejemplo n.º 26
0
 public object clone()
 {
     return(Self.clone());
 }
Ejemplo n.º 27
0
 public void addError(Exception msg)
 {
     Self.addError(msg);
 }
Ejemplo n.º 28
0
 public double getBuildVersion()
 {
     return(Self.getBuildVersion());
 }
 // API
 public string getLabel()
 {
     return(Self.getLabel());
 }
 public List <StandardDateFilterDuration> getStandardDateFilterDurations()
 {
     return(Self.getStandardDateFilterDurations());
 }
Ejemplo n.º 31
0
 public override void Destroy()
 {
     base.Destroy();
     Self.GetComponent <RectBodyComponent>().Velocity = Vector2.Zero;
 }
Ejemplo n.º 32
0
 void connectAndPrepare()
 {
     Console.WriteLine(welcomeText);
     LyncClient client = null;
     bool tryAgain = false;
     int attempts = 0;
     int waittime = 5;
     do
     {
         tryAgain = false;
         attempts++;
         try
         {
             if (attempts > 1)
                 consoleWriteLine(String.Format("Connecting to Lync Client. Attempt {0}...", attempts));
             else
                 consoleWriteLine("Connecting to Lync Client...");
             client = LyncClient.GetClient();
         }
         catch (LyncClientException _exception)
         {
             tryAgain = true;
             if (attempts <= 20)
             {
                 consoleWriteLine(String.Format("Client not found. Trying again in {0} seconds.", waittime));
                 System.Threading.Thread.Sleep(waittime * 1000);
             }
             else
             {
                 consoleWriteLine("Client not found. Too many attempts. Giving up.");
                 Console.ReadLine();
                 return;
             }
         }
     } while (tryAgain);
     myself = client.Self;
     if (!Directory.Exists(mydocpath + @"\LyncIMHistory"))
         Directory.CreateDirectory(mydocpath + @"\LyncIMHistory");
     client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
     client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;
     consoleWriteLine("Ready!");
     consoleWriteLine();
     Console.ReadLine();
 }
Ejemplo n.º 33
0
            public override void Update(float dt)
            {
                base.Update(dt);

                if (timer <= T)
                {
                    Become <IdleState>();
                    return;
                }

                var v = velocity * Math.Min(1, timer - T * 0.4f);

                Self.GetComponent <RectBodyComponent>().Velocity = v;

                if (!Self.fire)
                {
                    if (Self.CanSeeTarget())
                    {
                        Self.sawTime += dt;
                    }
                    else
                    {
                        Self.sawTime = 0;
                    }

                    return;
                }

                lastBullet -= dt;

                if (lastBullet <= 0)
                {
                    lastBullet = 0.2f;

                    if (!saw && !Self.CanSeeTarget())
                    {
                        return;
                    }

                    saw = true;

                    var an = angle + Rnd.Float(-Accuracy, Accuracy) + Math.Cos(T * 6f + start) * 0.1f;
                    var a  = Self.GetComponent <MobAnimationComponent>();

                    Tween.To(1.8f, a.Scale.X, x => a.Scale.X = x, 0.1f);
                    Tween.To(0.2f, a.Scale.Y, x => a.Scale.Y = x, 0.1f).OnEnd = () => {
                        Tween.To(1, a.Scale.X, x => a.Scale.X = x, 0.2f);
                        Tween.To(1, a.Scale.Y, x => a.Scale.Y = x, 0.2f);

                        Self.GetComponent <AudioEmitterComponent>().EmitRandomized("mob_fire");

                        var projectile = Projectile.Make(Self, "circle", an, 15, scale: Rnd.Float(0.5f, 1f));

                        projectile.Color = Rnd.Chance(70) ? ProjectileColor.Orange : ProjectileColor.Red;
                        projectile.AddLight(32f, projectile.Color);
                        projectile.Center += MathUtils.CreateVector(angle, 8);

                        AnimationUtil.Poof(projectile.Center);
                    };
                }
            }
Ejemplo n.º 34
0
 /// <summary>
 /// set props from Self object
 /// </summary>
 /// <param name="cre"></param>
 public void SetPoint(Self cre)
 {
     this.X = cre.X;
     this.Y = cre.Y;
     this.Z = cre.Z;
     this.name = cre.name;
     this.type = 2;
     this.radius = cre.modelRadius;
 }
 protected override void PreStart()
 {
     base.PreStart();
     Self.Tell(new SetStore(Context.ActorOf(Props.Create <PersistentActorFailureSpec.FailingMemoryStore>())));
 }
Ejemplo n.º 36
0
        public Event(DateTime ClockStart, DateTime ClockEnd, int ClockRunTime, System.Xml.Linq.XDocument XMLEvents, ref CrashHandler Crash)
        {
            ch = Crash;
            events = new Dictionary<string, List<EventItem>>();
            clock = new PartyClock(ClockStart, ClockEnd, ClockRunTime);
            Util.ShowClock = true;
            sound = new Sound(true);
            text = new Text2D();
            chess = new Chess();
            sf = new Starfield(150);

            intro = new Intro(ref sound, ref text);
            outro = new Outro(ref sound);

            advent = new Advent(ref sound);
            birthday = new Birthday(ref sound, ref text, ref chess);
            xmas = new Christmas(ref sound);
            smurf = new Datasmurf(ref sound, ref text); // random
            dif = new Dif(ref chess, ref sound); // random
            fbk = new Fbk(ref sound); // random
            hw = new Halloween(ref chess, ref sound, 25);
            lucia = new Lucia(ref chess, ref sound);
            newyear = new NewYear();
            richard = new RMS(ref sound, ref text); // random
            scroller = new Scroller(ref chess, ref sf, ref text); // random
            semla = new Semla();
            sune = new SuneAnimation(ref sound, ref text);
            tl = new TurboLogo(ref sound, ref chess, (OpenGL.Util.SpringOrFall.Equals("Spring")? true:false)/*((ClockStart.Month >= 1 && ClockStart.Month <= 8)? false:true)*/ ); // vilken termin är det? jan till början av augusti VT, resten HT... random
            valentine = new Valentine(ref sound);
            wl = new WinLinux(ref chess); //random
            creators = new Self(ref sound); // random
            bb = new BB(ref sound); // random
            GM = new GummiBears(ref sound);
            NDay = new National(ref chess, ref sound);
            easter = new Easter(ref sound);
            hajk = new Hajk(ref sound);
            mid = new Midsummer(ref sound);
            vaf = new Vaffla();
            wp = new Walpurgis();
            crayfish = new CrayFish();

            ts = new TeknatStyle(ref chess, ref sound, ref text);
            m = new Matrix(ref text);
            q = new Quiz(ref text, false, ref sound);
            talepsin = new Talespin(ref sound);
            cd = new ChipAndDale(ref sound, ref chess);
            nerd = new Nerdy(ref chess, ref sound);
            trex = new Trex(ref sound);
            sailormoon = new Sailormoon(ref sound,ref chess);
            gb = new GhostBusters(ref sound);
            zelda = new Zelda(ref sound, ref chess);
            tardis = new Tardis(ref sound);
            f**k = new F**k(ref sound, ref chess);

            silverFang = new SilverFang(ref sound);
            mt = new MoraT(ref sound);

            swine = new Swine(ref chess, ref text);
            tjall = new Tjall(ref chess, ref text);

            ronja = new Ronja(ref sound);
            emil = new Emil(ref sound);
            djungelboken = new Djungelboken(ref sound);
            fabbe = new Fabbe(ref sound);
            drink = new Drink(ref sound);
            frozen = new Frozen(ref sound);

            eventCurrent = null; // event item for events to be triggerd in clock_NewDate
            //randomEvent = new List<string>(new string[] { "starfield", "SuneAnimation", "TurboLogo", "Datasmurf", "WinLinux", "Scroller", "BB", "GummiBears", "TeknatStyle", "Matrix"});
            randomEvent = new List<string>(new string[] { "starfield", "Nerdy", "Talespin", "Sailormoon", "GhostBusters", "Zelda", "Tardis", "F**k", "SilverFang", "MoraT" });
            //new stuff
             List<UtilXML.EventData> ed = UtilXML.Loadeffectdata();

            // TODO: Make a clean list with all events allowed to be used implement so that it is actaully usable instead of a switch at the bottom of this file.
            Dictionary<string, Effect> effects = new Dictionary<string, Effect>()
            {
                {"SuneAnimation", new Effect(sune, ed.Find(e => e.Name == "SuneAnimation"))},
                {"Dif",new Effect(dif, ed.Find(e => e.Name == "Dif"))},
                {"Fbk",new Effect(fbk, ed.Find(e => e.Name == "Fbk"))},
                {"TurboLogo",new Effect(tl, ed.Find(e => e.Name == "TurboLogo"))},
                {"Datasmurf", new Effect(smurf, ed.Find(e => e.Name == "Datasmurf"))},
                {"RMS",new Effect(richard, ed.Find(e => e.Name == "RMS"))},
                {"WinLinux",new Effect(wl, ed.Find(e => e.Name == "WinLinux"))},
                {"Scroller",new Effect(scroller, ed.Find(e => e.Name == "Scroller"))},
                {"Self",new Effect(creators, ed.Find(e => e.Name == "Self"))},
                {"BB",new Effect(bb, ed.Find(e => e.Name == "BB"))},
                {"GummiBears",new Effect(GM, ed.Find(e => e.Name == "GummiBears"))},
                {"Hajk",new Effect(hajk, ed.Find(e => e.Name == "Hajk"))},
                {"TeknatStyle",new Effect(ts, ed.Find(e => e.Name == "TeknatStyle"))},
                {"Matrix",new Effect(m, ed.Find(e => e.Name == "Matrix"))},
                {"Quiz",new Effect(q, ed.Find(e => e.Name == "Quiz"))},
                {"Talespin",new Effect(talepsin, ed.Find(e => e.Name == "Talespin"))},
                {"ChipDale",new Effect(cd, ed.Find(e => e.Name == "ChipDale"))},
                {"Nerdy",new Effect(nerd, ed.Find(e => e.Name == "Nerdy"))},
              /*  {"Trex",new Effect(trex, ed.Find(e => e.Name == "Trex"))},*/
                {"Sailormoon",new Effect(sailormoon, ed.Find(e => e.Name == "Sailormoon"))},
                {"GhostBusters",new Effect(gb, ed.Find(e => e.Name == "GhostBusters"))},
                {"Zelda",new Effect(zelda, ed.Find(e => e.Name == "Zelda"))},
                {"Tardis",new Effect(tardis, ed.Find(e => e.Name == "Tardis"))},
                {"F**k",new Effect(f**k, ed.Find(e => e.Name == "F**k"))},
                {"SilverFang",new Effect(silverFang, ed.Find(e => e.Name == "SilverFang"))},
                {"MoraT",new Effect(mt, ed.Find(e => e.Name == "MoraT"))},
                {"Ronja",new Effect(ronja, ed.Find(e => e.Name == "Ronja"))},
                {"Emil",new Effect(emil, ed.Find(e => e.Name == "Emil"))},
                {"Djungelboken",new Effect(djungelboken, ed.Find(e => e.Name == "Djungelboken"))},
                {"Fabbe",new Effect(fabbe, ed.Find(e => e.Name == "Fabbe"))},
                {"Drink",new Effect(drink, ed.Find(e => e.Name == "Drink"))},
                {"Frozen",new Effect(drink, ed.Find(e => e.Name == "Frozen"))}
            };

            runEffectInMonth = new Dictionary<string, List<objdata>>();

            string[] months = Util.monthlist();
            int counter;
            foreach (KeyValuePair<string, Effect> pair in effects)
            {
                counter = 0;
                foreach (bool b in pair.Value.RunAllowedlist)
                {
                    if (b == true)
                    {
                        if (!runEffectInMonth.ContainsKey(months[counter]))
                        {
                            runEffectInMonth.Add(months[counter], new List<objdata>());
                        }

                        runEffectInMonth[months[counter]].Add(new objdata(pair.Key, pair.Value.Vetolist[counter], pair.Value.Priolist[counter], pair.Value.Runslist[counter]));
                    }
                    counter++;
                }
            }

            clock.NewDate += clock_NewDate; // Event listener

            if (ch.CrashDialogResult == System.Windows.Forms.DialogResult.Yes)
            {
                clock.clock = ch.CrashClock;
            }

            string name, date, type;
            // Event dates setup
            foreach (var item in XMLEvents.Descendants("event"))
            {
                name = item.Element("name").Value;
                date = item.Element("date").Value;
                type = item.Element("type").Value.ToLower();
                EventItem ei = new EventItem(name, type, date);
                if (!events.ContainsKey(date))
                {
                    List<EventItem> list = new List<EventItem>(); // seems most bad in my eyes...
                    events.Add(date, list);
                }

                for (int i = 0; i < events[date].Count; i++)
                {
                    EventItem e = events[date][i];
                    if ("birthday".Equals(e.Type) && "birthday".Equals(ei.Type))
                    {
                        e.Name += "\n\n" + ei.Name;
                        events[date][i] = e;
                    }
                }
                events[date].Add(ei);
                name = date = type = string.Empty;
            }

            // this needs to be fixed nicer...
            if (events.ContainsKey(ClockEnd.ToShortDateString()))
            {
                events[ClockEnd.ToShortDateString()].Clear(); // force this to be top..
                events[ClockEnd.ToShortDateString()].Add( new EventItem("outro", "outro", ClockEnd.ToShortDateString()) );
            }
            else
            {
                events.Add(ClockEnd.ToShortDateString(), new List<EventItem>() { new EventItem("outro", "outro", ClockEnd.ToShortDateString()) });
            }

            // Random effects on dates with no effects and check against new list of allowed things for them...
            DateTime dt = ClockStart;
            bool star = (Util.Rnd.Next(0, 1000) < 500 ? true:false); // make this random at the start too?
            int num = 0;

            while (dt <= ClockEnd)
            {
                date = dt.ToShortDateString();
                if (!events.ContainsKey(date))
                {
                    EventItem ei;

                    if (num == 0 || num == 1)
                    {
                        ei = new EventItem("starfield", "random", date);
                    }
                    else
                    {
                        //ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);

                        string month = "";
                        if (dt != null)
                            month = dt.Month.ToString();

                        switch (month)
                        {
                            case "1": month = "jan"; break;
                            case "2": month = "feb"; break;
                            case "3": month = "mar"; break;
                            case "4": month = "apr"; break;
                            case "5": month = "maj"; break;
                            case "6": month = "jun"; break;
                            case "7": month = "jul"; break;
                            case "8": month = "aug"; break;
                            case "9": month = "sep"; break;
                            case "10": month = "okt"; break;
                            case "11": month = "nov"; break;
                            case "12": month = "dec"; break;
                        }//switch

                        if (runEffectInMonth.ContainsKey(month))
                        {
                            List<objdata> mobj = runEffectInMonth[month];

                            List<objdata> vetolist = new List<objdata>();
                            List<objdata> novetolist = new List<objdata>();

                            foreach (objdata n in mobj)
                            {

                                if ("Quiz".Equals(n.Name) && eventnum == 4)
                                {
                                    n.vetoAgain();
                                    eventnum = 0;
                                }

                                if (n.Veto == true)
                                {
                                    if (n.Runs > 0)
                                        vetolist.Add(n);
                                }
                                else
                                {
                                    if (n.Runs > 0)
                                        novetolist.Add(n);
                                }
                            }

                            vetolist.Sort();
                            novetolist.Sort();

                            if (vetolist.Count > 0)
                            {
                                ei = new EventItem(vetolist[0].Name, "random", date);
                                vetolist[0].noMoreVeto();
                            }
                            else if (novetolist.Count > 0)
                            {
                                ei = new EventItem(novetolist[0].Name, "random", date);
                                novetolist[0].decRuns();
                                if (eventnum < 4)
                                    eventnum++;
                            }
                            else
                            {
                                ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);
                            }
                        }
                        else
                        {
                            ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);
                        }
                    }

                    num++;
                    if (num == 3)
                    {
                        num = 0;
                    }
                    ei = new EventItem("Self", "random", date); // this is for debuging new events
                    events.Add(date, new List<EventItem>());
                    events[date].Add(ei);
                }

                dt = dt.AddDays(1);
                date = string.Empty;
            }
        }
Ejemplo n.º 37
0
 public string getDescription()
 {
     return(Self.getDescription());
 }