Exemple #1
0
        public async Task <TokenMetadata> LookupTokenAsync(AToken body, CancellationToken cancellationToken = default)
        {
            var response = await GetTokensUrl()
                           .AppendPathSegment("lookup")
                           .PostJsonAsync(body, cancellationToken)
                           .ReceiveJsonWithErrorChecking <TokenMetadata>()
                           .ConfigureAwait(false);

            return(response);
        }
Exemple #2
0
        protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details)
        {
            if (details.Equals("association"))
            {
                AToken token = (lObjectTo as AToken);

                /*DialogueObject dialogue = world.GetObjectFromId((lObject as FieldToken).AssociatedToken) as DialogueObject;
                 * dialogue.ResetDialogue();*/
                token.DisplayText = string.Empty;

                this.isValidated = true;
                this.timeElapsed = Time.Zero;
            }
        }
Exemple #3
0
        public static List <AToken[]> Tokenize(string text)
        {
            Tokenizer     reader = new Tokenizer(text);
            List <AToken> tokens = new List <AToken> {
                new NewLineToken(text, 0, -1)
            };

            while (reader.Current != '\0')
            {
                AToken current = reader.Advance();

                if (current is EofToken)
                {
                    break;
                }

                tokens.Add(current);
            }

            List <AToken[]> asmInstructions = new List <AToken[]>();
            List <AToken>   asmInstruction  = new List <AToken>();

            for (int i = 0; i < tokens.Count; i++)
            {
                if (tokens[i] is NewLineToken)
                {
                    if (asmInstruction.Count != 0)
                    {
                        asmInstructions.Add(asmInstruction.ToArray());
                    }

                    asmInstruction.Clear();

                    continue;
                }

                asmInstruction.Add(tokens[i]);
            }

            if (asmInstruction.Count != 0)
            {
                asmInstructions.Add(asmInstruction.ToArray());
            }

            asmInstruction.Clear();

            return(asmInstructions);
        }
Exemple #4
0
        protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details)
        {
            if (this.moment == ThinkPhaseMoment.START_TIMER)
            {
                if (details.Equals("timerPassed"))
                {
                    this.EndTimerAction(world);
                }
                else if (details.Equals("association"))
                {
                    AToken tokenTo = lObjectTo as AToken;

                    if (lObject != null)
                    {
                        AToken tokenFrom = lObject as AToken;
                        tokenFrom.DisplayText = tokenFrom.Text;
                    }
                    tokenTo.DisplayText = string.Empty;
                }
            }
        }
Exemple #5
0
        private void EndTimerAction(OfficeWorld world)
        {
            world.NotifyGameStateChanged(world.CurrentLevel.LevelName, new GameEvent(EventType.END_TIMER, string.Empty));

            DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject;

            dialogue.ResetDialogue();

            DialogueObject dialogueAnswer = world.GetObjectFromId("dialogue answer") as DialogueObject;

            dialogueAnswer.ResetDialogue();

            AObject noteblock = world.GetObjectFromId("notebook main");

            (noteblock as NotebookObject).SetTransition(new Vector2f(-600, 150), new Vector2f(0, 150), Time.FromSeconds(3));

            AObject bubble = world.GetObjectFromId("bubble main");

            bubble.SetAnimationIndex(3);

            AToken timerToken = world.GetObjectFromId("timerToken main") as AToken;

            timerToken.DisplayText = string.Empty;

            AObject queueDream = world.GetObjectFromId("queueDream main");

            queueDream.SetKinematicParameters(new Vector2f(1000, 1000), new Vector2f(0f, 0f));

            AObject timer = world.GetObjectFromId("timer main");

            timer.SetAnimationIndex(3);

            this.timeElapsed = Time.Zero;
            this.periodPhase = Time.FromSeconds(3);
            this.moment      = ThinkPhaseMoment.END;
        }
Exemple #6
0
        public static void StartJob(string[] users, string domain, string[] passwords, string[] hashes, string ticket, KERB_ETYPE encType, string dc, string[] computernames, string module, string moduleargument, List <string> flags)
        {
            string ticketoutput;

            if (String.IsNullOrEmpty(ticket))
            {
                foreach (string user in users)
                {
                    var secrets = hashes.Length > 0 ? hashes : passwords;
                    foreach (string secret in secrets)
                    {
                        string hash;
                        if (passwords.Length > 0)
                        {
                            string salt = String.Format("{0}{1}", domain.ToUpper(), user);
                            hash = Crypto.KerberosPasswordHash(encType, secret, salt);
                        }
                        else
                        {
                            hash = secret;
                        }
                        AToken.MakeToken("Fake", "Fake", "Fake");
                        Console.WriteLine("------------------");
                        Console.WriteLine(string.Format("[*] User:   {0}", user));
                        Console.WriteLine(string.Format("[*] domain: {0}", domain));
                        Console.WriteLine(string.Format("[*] secret: {0}", secret));
                        ticketoutput = SecurityContext.AskTicket(user, domain, hash, encType, dc);
                        if (ticketoutput.Contains("[+] Ticket successfully imported!"))
                        {
                            Console.WriteLine("[+] Ticket successfully imported!");
                        }
                        else
                        {
                            Console.WriteLine("[-] Could not request TGT");
                            continue;
                        }
                        Console.WriteLine();
                        foreach (string computername in computernames)
                        {
                            Console.WriteLine(String.Format("[*] Checking {0}", computername));
                            if (!Misc.CheckHostPort(computername, 445))
                            {
                                Console.WriteLine(String.Format("[-] Could Not Reach {0}:445", computername));
                                Console.WriteLine();
                                continue;
                            }
                            if (!Directory.Exists(Path.Combine("loot", computername)))
                            {
                                Directory.CreateDirectory(Path.Combine("loot", computername));
                            }
                            Smb.CheckLocalAdmin(computername, module);
                            Console.WriteLine("");
                        }
                        AToken.RevertFromToken();
                    }
                }
            }
            else
            {
                AToken.MakeToken("Fake", "Fake", "Fake");
                Console.WriteLine("------------------");
                Console.WriteLine(string.Format("[*] Ticket: {0}", ticket));
                ticketoutput = SecurityContext.ImportTicket(ticket);
                if (ticketoutput.Contains("[+] Ticket successfully imported!"))
                {
                    Console.WriteLine("[+] TGT imported successfully!");
                }
                else
                {
                    Console.WriteLine("[-] Could not import TGT");
                    return;
                }
                Console.WriteLine();
                foreach (string computername in computernames)
                {
                    Console.WriteLine(String.Format("[*] Checking {0}", computername));
                    if (!Misc.CheckHostPort(computername, 445))
                    {
                        Console.WriteLine(String.Format("[-] Could Not Reach {0}:445", computername));
                        Console.WriteLine();
                        continue;
                    }
                    if (!Directory.Exists(Path.Combine("loot", computername)))
                    {
                        Directory.CreateDirectory(Path.Combine("loot", computername));
                    }
                    Smb.CheckLocalAdmin(computername, module);
                    Console.WriteLine("");
                }
                AToken.RevertFromToken();
            }
        }
Exemple #7
0
        public override void UpdateLogic(OfficeWorld world, Time timeElapsed)
        {
            this.timeElapsed += timeElapsed;

            if (this.timeElapsed > periodPhase)
            {
                switch (this.moment)
                {
                case ThinkPhaseMoment.START:
                    DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject;
                    dialogue.LaunchDialogue(6);

                    AObject queueDream = world.GetObjectFromId("queueDream main");
                    queueDream.SetKinematicParameters(new Vector2f(100f, 100f), new Vector2f(0f, 0f));

                    AObject bubble = world.GetObjectFromId("bubble main");
                    bubble.SetAnimationIndex(2);

                    this.timeElapsed = Time.Zero;
                    this.periodPhase = Time.FromSeconds(2);
                    this.moment      = ThinkPhaseMoment.BUBBLE_APPEARED;
                    break;

                case ThinkPhaseMoment.BUBBLE_APPEARED:

                    DialogueObject dialogueAnswer = world.GetObjectFromId("dialogue answer") as DialogueObject;
                    dialogueAnswer.SetKinematicParameters(new Vector2f(-550f, 200f), new Vector2f(0f, 0f));
                    dialogueAnswer.LaunchDialogue(6);

                    this.timeElapsed = Time.Zero;
                    this.periodPhase = Time.FromSeconds(world.CurrentLevel.Data.Timer);

                    AObject timer = world.GetObjectFromId("timer main");
                    timer.SetAnimationIndex(2);

                    this.moment = ThinkPhaseMoment.START_TIMER;
                    break;

                case ThinkPhaseMoment.START_TIMER:

                    this.EndTimerAction(world);
                    break;

                case ThinkPhaseMoment.END:
                    dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject;
                    dialogue.ValidateDialogue(world);

                    timer = world.GetObjectFromId("timer main");
                    timer.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0f, 0f));

                    this.NodeState = NodeState.NOT_ACTIVE;
                    break;
                }
            }

            if (this.moment == ThinkPhaseMoment.START_TIMER)
            {
                AToken timerToken = world.GetObjectFromId("timerToken main") as AToken;
                timerToken.DisplayText = ((int)(world.CurrentLevel.Data.Timer - this.timeElapsed.AsSeconds())).ToString();
            }
        }
Exemple #8
0
        public static void StartJob(string[] users, string domain, string[] passwords, string[] hashes, string ticket, KERB_ETYPE encType, string dc, string[] computernames, string module, string moduleargument, string path, string destination, List <string> flags)
        {
            AToken.MakeToken("Fake", "Fake", "Fake");
            string ticketoutput;

            if (String.IsNullOrEmpty(ticket))
            {
                foreach (string user in users)
                {
                    var secrets = hashes.Length > 0 ? hashes : passwords;
                    foreach (string secret in secrets)
                    {
                        string hash;
                        if (passwords.Length > 0)
                        {
                            string salt = String.Format("{0}{1}", domain.ToUpper(), user);
                            hash = Crypto.KerberosPasswordHash(encType, secret, salt);
                        }
                        else
                        {
                            hash = secret;
                        }

                        Console.WriteLine("------------------");
                        Console.WriteLine(string.Format("[*] User:   {0}", user));
                        Console.WriteLine(string.Format("[*] domain: {0}", domain));
                        Console.WriteLine(string.Format("[*] secret: {0}", secret));
                        ticketoutput = SecurityContext.AskTicket(user, domain, hash, encType, dc);
                        if (ticketoutput.Contains("[+] Ticket successfully imported!"))
                        {
                            Console.WriteLine("[+] Ticket successfully imported!");
                        }
                        else
                        {
                            Console.WriteLine("[-] Could not request TGT");
                            continue;
                        }
                        //ticket debugging
                        //List<LSA.SESSION_CRED> sessionCreds = LSA.EnumerateTickets(false, new LUID(), "", "", "", true);
                        //LSA.DisplaySessionCreds(sessionCreds, LSA.TicketDisplayFormat.Klist);
                        Console.WriteLine();
                        foreach (string computername in computernames)
                        {
                            Console.WriteLine(String.Format("[*] Checking {0}", computername));
                            if (!Misc.CheckHostPort(computername, 5985))
                            {
                                Console.WriteLine(String.Format("[-] Could Not Reach {0}:5985", computername));
                                Console.WriteLine();
                                continue;
                            }
                            if (!Directory.Exists(Path.Combine("loot", computername)))
                            {
                                Directory.CreateDirectory(Path.Combine("loot", computername));
                            }
                            if (module.Length == 0 || module.Contains("exec"))
                            {
                                Wsman.CheckLocalAdmin(computername, moduleargument, flags);
                            }
                            else if (module.Contains("comsvcs"))
                            {
                                Wsman.InvokeComSvcsLsassDump(computername);
                            }
                            else if (module.Contains("secrets") || module.Contains("secret"))
                            {
                                Wsman.GetSecrets(computername);
                            }
                            else if (module.Contains("assembly"))
                            {
                                Wsman.ExecuteAssembly(computername, path, moduleargument, flags);
                            }
                            else if (module.Contains("download"))
                            {
                                Wsman.CopyFile(computername, path, destination);
                            }
                            else if (module.Contains("upload"))
                            {
                                Wsman.UploadFile(computername, path, destination);
                            }
                            Console.WriteLine("");
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("------------------");
                Console.WriteLine(string.Format("[*] Ticket: {0}", ticket));
                ticketoutput = SecurityContext.ImportTicket(ticket);
                if (ticketoutput.Contains("[+] Ticket successfully imported!"))
                {
                    Console.WriteLine("[+] TGT imported successfully!");
                }
                else
                {
                    Console.WriteLine("[-] Could not import TGT");
                    return;
                }
                //ticket debugging
                //List<LSA.SESSION_CRED> sessionCreds = LSA.EnumerateTickets(false, new LUID(), "", "", "", true);
                //LSA.DisplaySessionCreds(sessionCreds, LSA.TicketDisplayFormat.Klist);
                Console.WriteLine();
                foreach (string computername in computernames)
                {
                    Console.WriteLine(String.Format("[*] Checking {0}", computername));
                    if (!Misc.CheckHostPort(computername, 5985))
                    {
                        Console.WriteLine(String.Format("[-] Could Not Reach {0}:5985", computername, flags));
                        Console.WriteLine();
                        continue;
                    }
                    if (!Directory.Exists(Path.Combine("loot", computername)))
                    {
                        Directory.CreateDirectory(Path.Combine("loot", computername));
                    }
                    if (module.Length == 0 || module.Contains("exec"))
                    {
                        Wsman.CheckLocalAdmin(computername, moduleargument, flags);
                    }
                    else if (module.Contains("comsvcs"))
                    {
                        Wsman.InvokeComSvcsLsassDump(computername);
                    }
                    else if (module.Contains("secrets") || module.Contains("secret"))
                    {
                        Wsman.GetSecrets(computername);
                    }
                    else if (module.Contains("assembly"))
                    {
                        Wsman.ExecuteAssembly(computername, path, moduleargument, flags);
                    }
                    else if (module.Contains("download"))
                    {
                        Wsman.CopyFile(computername, path, destination);
                    }
                    else if (module.Contains("upload"))
                    {
                        Wsman.UploadFile(computername, path, destination);
                    }
                    Console.WriteLine("");
                }
            }
            AToken.RevertFromToken();
        }
Exemple #9
0
        public static void StartJob(string[] users, string domain, string[] passwords, string[] hashes, string ticket, KERB_ETYPE encType, string dc, string[] computernames, string module, string moduleargument, string path, string destination, List <string> flags, string protocol)
        {
            AToken.MakeToken("Fake", "Fake", "Fake");
            Console.WriteLine("------------------");

            if (String.IsNullOrEmpty(ticket))
            {
                var secrets = hashes.Length > 0 ? hashes : passwords;
                foreach (string user in users)
                {
                    foreach (string secret in secrets)
                    {
                        string hash;
                        if (passwords.Length > 0)
                        {
                            string salt = String.Format("{0}{1}", domain.ToUpper(), user);
                            hash = Crypto.KerberosPasswordHash(encType, secret, salt);
                        }
                        else
                        {
                            hash = secret;
                        }
                        Console.WriteLine(string.Format("[*] User:   {0}", user));
                        Console.WriteLine(string.Format("[*] Domain: {0}", domain));
                        Console.WriteLine(string.Format("[*] Secret: {0}", secret));
                        string ticketoutput = SecurityContext.AskTicket(user, domain, hash, encType, dc);
                        if (ticketoutput.Contains("[+] Ticket successfully imported!"))
                        {
                            Console.WriteLine("[+] Ticket successfully imported!");
                        }
                        else
                        {
                            Console.WriteLine("[-] Could not request TGT");
                            continue;
                        }
                        if (protocol.ToLower() == "smb")
                        {
                            Scan.SMB(computernames, module);
                        }
                        else if (protocol.ToLower() == "winrm")
                        {
                            Scan.WINRM(computernames, module, moduleargument, path, destination, flags);
                        }
                        else if (protocol.ToLower() == "reg32")
                        {
                            Scan.REG32(computernames, module);
                        }
                        else if (protocol.ToLower() == "ldap")
                        {
                            Scan.LDAP(module, domain, dc);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine(string.Format("[*] Ticket: {0}", ticket));
                string ticketoutput = SecurityContext.ImportTicket(ticket);
                if (ticketoutput.Contains("[+] Ticket successfully imported!"))
                {
                    Console.WriteLine("[+] TGT imported successfully!");
                }
                else
                {
                    Console.WriteLine("[-] Could not import TGT");
                    return;
                }
                if (protocol.ToLower() == "smb")
                {
                    Scan.SMB(computernames, module);
                }
                else if (protocol.ToLower() == "winrm")
                {
                    Scan.WINRM(computernames, module, moduleargument, path, destination, flags);
                }
                else if (protocol.ToLower() == "reg32")
                {
                    Scan.REG32(computernames, module);
                }
                else if (protocol.ToLower() == "ldap")
                {
                    Scan.LDAP(module, domain, dc);
                }
            }

            AToken.RevertFromToken();
        }
Exemple #10
0
        public override List <byte> Assemble(LinkerResult result)
        {
            List <byte> instrBytes = new List <byte>();

            AssemblyGeneratorSettings settings = SettingsManager.GetSettings <AssemblyGeneratorSettings>();

            Log("Using format: {0}", settings.Format);

            uint emptyVarSize = GetTotalEmptyVarSize(result);

            if (settings.Format.Contains("-ovars"))
            {
                float savedSpace = emptyVarSize / (float)GetTotalVarCount(result);
                Log("Saved Space: {0}%", Math.Round(savedSpace, 2) * 100);
            }

            if (settings.Format.StartsWith("v2"))
            {
                if (settings.Format.Contains("-ovars"))
                {
                    instrBytes.AddRange(BitConverter.GetBytes(emptyVarSize));
                }
                else
                {
                    instrBytes.AddRange(BitConverter.GetBytes(0u));
                }
                instrBytes.AddRange(BitConverter.GetBytes(( uint )1));
                instrBytes.AddRange(BitConverter.GetBytes(settings.GlobalOffset));
                instrBytes.AddRange(BitConverter.GetBytes(( uint )0));
            }

            Dictionary <string, AddressItem> consts =
                result.Constants.ApplyOffset(settings.GlobalOffset).ToDictionary(x => x.Key, x => x.Value);

            Dictionary <string, AddressItem> labels =
                result.Labels.ApplyOffset(settings.GlobalOffset).ToDictionary(x => x.Key, x => x.Value);

            FileCompilation.ApplyToAllTokens(
                result.LinkedBinary,
                consts,
                new List <uint>()
                );                             //Apply global constants

            List <uint> indexList = new List <uint>();

            FileCompilation.ApplyToAllTokens(result.LinkedBinary, labels, indexList);

            FixEmptyVars(( uint )result.DataSection.Count, CleanEmptyItems(result));

            Dictionary <string, AddressItem> ds =
                result.DataSectionHeader.
                ApplyOffset(
                    settings.GlobalOffset +
                    ( uint )result.LinkedBinary.Count * CpuSettings.InstructionSize
                    ).
                ToDictionary(x => x.Key, x => x.Value);

            result.ApplyDataOffset(
                ( int )(settings.GlobalOffset +
                        result.LinkedBinary.Count * CpuSettings.InstructionSize)
                );

            FileCompilation.ApplyToAllTokens(result.LinkedBinary, ds, indexList);



            foreach (KeyValuePair <(int, int), Dictionary <string, AddressItem> > resultHiddenAddressItem in result.
                     HiddenConstantItems)
            {
                FileCompilation.ApplyToTokens(
                    result.LinkedBinary,
                    resultHiddenAddressItem.Value,
                    new List <uint>(),
                    resultHiddenAddressItem.Key.Item1,
                    resultHiddenAddressItem.Key.Item2
                    );                          //Apply global constants
            }

            foreach (KeyValuePair <(int, int), Dictionary <string, AddressItem> > resultHiddenAddressItem in result.
                     HiddenLabelItems)
            {
                Dictionary <string, AddressItem> hiddenLabels =
                    resultHiddenAddressItem.Value.ApplyOffset(settings.GlobalOffset).
                    ToDictionary(x => x.Key, x => x.Value);

                FileCompilation.ApplyToTokens(
                    result.LinkedBinary,
                    hiddenLabels,
                    indexList,
                    resultHiddenAddressItem.Key.Item1,
                    resultHiddenAddressItem.Key.Item2
                    );                          //Apply global constants
            }

            foreach (KeyValuePair <(int, int), Dictionary <string, AddressItem> > resultHiddenAddressItem in result.
                     HiddenDataSectionItems)
            {
                Dictionary <string, AddressItem> hds = resultHiddenAddressItem.Value.ApplyOffset(
                    settings.GlobalOffset +
                    ( uint )result.LinkedBinary.Count *
                    CpuSettings.InstructionSize
                    ).
                                                       ToDictionary(
                    x => x.Key,
                    x => x.Value
                    );

                FileCompilation.ApplyToTokens(
                    result.LinkedBinary,
                    hds,
                    indexList,
                    resultHiddenAddressItem.Key.Item1,
                    resultHiddenAddressItem.Key.Item2
                    );                          //Apply global constants
            }

            for (int i = 0; i < result.LinkedBinary.Count; i++)
            {
                List <byte>          bytes = new List <byte>();
                AToken               instr = result.LinkedBinary[i][0];
                IEnumerable <AToken> args  = result.LinkedBinary[i].Skip(1);

                uint opCode =
                    CpuSettings.InstructionSet.GetInstruction(
                        CpuSettings.InstructionSet.GetInstruction(
                            instr.GetValue(),
                            result.LinkedBinary[i].Length - 1
                            )
                        );

                bytes.AddRange(BitConverter.GetBytes(opCode));

                foreach (AToken aToken in args)
                {
                    if (aToken is ValueToken vToken)
                    {
                        bytes.AddRange(BitConverter.GetBytes(vToken.Value));
                    }
                    else
                    {
                        EventManager <ErrorEvent> .SendEvent(new TokenRecognitionFailureEvent( aToken.GetValue()));
                    }
                }

                if (bytes.Count > CpuSettings.ByteSize)
                {
                    EventManager <ErrorEvent> .SendEvent(new InvalidArgumentCountEvent( i ));
                }

                bytes.AddRange(Enumerable.Repeat(( byte )0, ( int )CpuSettings.ByteSize - bytes.Count));

                instrBytes.AddRange(bytes);
            }

            List <byte> v = result.DataSection.SelectMany(BitConverter.GetBytes).ToList();

            instrBytes.AddRange(v);

            if (settings.Format.StartsWith("v3"))
            {
                instrBytes.InsertRange(0, indexList.SelectMany(BitConverter.GetBytes));

                instrBytes.InsertRange(0, BitConverter.GetBytes(0u));
                instrBytes.InsertRange(0, BitConverter.GetBytes(( uint )indexList.Count));
                instrBytes.InsertRange(0, BitConverter.GetBytes(2u));
                if (settings.Format.Contains("-ovars"))
                {
                    instrBytes.InsertRange(0, BitConverter.GetBytes(emptyVarSize));
                }
                else
                {
                    instrBytes.InsertRange(0, BitConverter.GetBytes(0u));
                }

                if (settings.Format.StartsWith("v3-pic"))
                {
                    List <uint> symbolTable = new List <uint>();
                    symbolTable.Add(( uint )result.Labels.Count);

                    foreach (KeyValuePair <string, AddressItem> keyValuePair in result.Labels)
                    {
                        uint[] bs = keyValuePair.Key.ToCharArray().
                                    Select(x => ( uint )x).
                                    ToArray();

                        symbolTable.Add(( uint )keyValuePair.Key.Length);
                        symbolTable.Add(keyValuePair.Value.Address);
                        symbolTable.AddRange(bs);
                    }

                    instrBytes.InsertRange(0, symbolTable.SelectMany(BitConverter.GetBytes));
                }
            }

            return(instrBytes);
        }
Exemple #11
0
        public override void VisitStart(OfficeWorld world)
        {
            base.VisitStart(world);

            this.levelData = Serializer.Deserialize(this.pathLevel);

            // Create Objects
            OfficeObject office = new OfficeObject();

            PatientObject patient = new PatientObject();

            patient.Alias = "main";
            ToubibObject toubib = new ToubibObject();

            toubib.Alias = "main";
            NotebookObject notebook = new NotebookObject();

            notebook.Alias = "main";
            BubbleObject bubble = new BubbleObject();

            bubble.Alias = "main";
            TimerObject timer = new TimerObject();

            timer.Alias = "main";

            QueueTalkObject queueTalk = new QueueTalkObject();

            queueTalk.Alias = "main";
            QueueDreamObject queueDream = new QueueDreamObject();

            queueDream.Alias = "main";

            //TestObject test = new TestObject();

            DialogueObject dialoguePatient = DialogueFactory.CreateDialogueFactory(60, this.levelData.PatientDialogue);

            dialoguePatient.Alias = "patient";

            DialogueObject dialogueToubib = DialogueFactory.CreateDialogueFactory(60, this.levelData.ToubibDialogue);

            dialogueToubib.Alias = "toubib";

            DialogueObject dialogueAnswer = DialogueFactory.CreateDialogueFactory(30, this.levelData.AnswerTokens);

            dialogueAnswer.Alias = "answer";

            DialogueObject dialogueSuccessAnswer = DialogueFactory.CreateDialogueFactory(60, this.levelData.PatientSuccessAnswer, TokenType.NORMAL);

            dialogueSuccessAnswer.Alias = "successAnswer";

            DialogueObject dialogueFailAnswer = DialogueFactory.CreateDialogueFactory(60, this.levelData.PatientFailAnswer, TokenType.NORMAL);

            dialogueFailAnswer.Alias = "failAnswer";

            DialogueObject dialogueComing = DialogueFactory.CreateDialogueFactory(30, "Hum, Entrez ...", TokenType.NORMAL);

            dialogueComing.Alias = "coming";

            AToken timerToken = DialogueFactory.CreateToken(string.Empty, TokenType.TIMER);

            timerToken.Alias = "main";

            // Create layers
            Layer background   = new Layer();
            Layer middleground = new Layer();
            Layer foreground   = new Layer();
            Layer textLayer    = new Layer();
            Layer answerLayer  = new Layer();

            // Add Resources
            List <string> resourcesToLoad = new List <string>();

            resourcesToLoad.Add(this.LevelName);

            resourcesToLoad.Add(office.Id);

            resourcesToLoad.Add(toubib.Id);
            resourcesToLoad.Add(patient.Id);

            resourcesToLoad.Add(notebook.Id);
            resourcesToLoad.Add(bubble.Id);

            resourcesToLoad.Add(queueTalk.Id);
            resourcesToLoad.Add(queueDream.Id);

            resourcesToLoad.Add(timer.Id);

            resourcesToLoad.Add("normalToken");
            resourcesToLoad.Add("sanctuaryToken");
            resourcesToLoad.Add("answerToken");

            resourcesToLoad.Add("lampClipped");
            resourcesToLoad.Add("wordPicked");
            resourcesToLoad.Add("bubbleClosed");
            resourcesToLoad.Add("bubbleOpened");
            resourcesToLoad.Add("wordInserted");
            resourcesToLoad.Add("wordDroped");

            resourcesToLoad.Add("dialoguePatient");
            resourcesToLoad.Add("dialogueToubib");
            resourcesToLoad.Add("dialogueReflexion");
            resourcesToLoad.Add("dialoguePatientSuccess");
            resourcesToLoad.Add("dialoguePatientFail");
            resourcesToLoad.Add("doorKnock");
            resourcesToLoad.Add("endTimer");

            resourcesToLoad.Add("validationSuccess");
            resourcesToLoad.Add("validationFail");

            /*resourcesToLoad.Add(patient.Id);
             * resourcesToLoad.Add(toubib.Id);*/
            world.NotifyResourcesToLoad(resourcesToLoad);

            // Add Layers
            world.AddLayer(background);
            world.AddLayer(middleground);
            world.AddLayer(foreground);
            world.AddLayer(textLayer);
            world.AddLayer(answerLayer);

            // Add Objects

            /*world.AddObject(test, 0);
             * world.AddObject(patient, 0);
             * world.AddObject(toubib, 0);*/
            world.AddObject(office, 0);

            world.AddObject(toubib, 1);
            world.AddObject(patient, 1);

            world.AddObject(queueTalk, 2);
            world.AddObject(queueDream, 2);

            world.AddObject(timer, 2);
            world.AddObject(timerToken, 3);

            world.AddObject(notebook, 2);
            world.AddObject(bubble, 2);

            world.AddObject(dialoguePatient, 3);
            world.AddObject(dialogueToubib, 3);
            world.AddObject(dialogueAnswer, 4);
            world.AddObject(dialogueFailAnswer, 3);
            world.AddObject(dialogueSuccessAnswer, 3);
            world.AddObject(dialogueComing, 3);

            // Set Object Position.
            office.SetKinematicParameters(new Vector2f(0, 0), new Vector2f(0, 0));

            toubib.SetKinematicParameters(new Vector2f(150, 160), new Vector2f(0, 0));
            patient.SetKinematicParameters(new Vector2f(-550, 140), new Vector2f(0, 0));

            notebook.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0));
            bubble.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0));

            queueTalk.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0));
            queueDream.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0));

            timer.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0));
            timerToken.SetKinematicParameters(new Vector2f(400, 260), new Vector2f(0f, 0f));

            queueTalk.SetAnimationIndex(1);
            queueDream.SetAnimationIndex(1);
        }
Exemple #12
0
 /// <summary>
 /// Allows you to register a new token in the lexer.
 /// Thus being able to extend the calculator.
 /// </summary>
 /// <param name="recognizedToken"></param>
 public void RegisterToken(AToken recognizedToken)
 {
     _knownTokens.Add(recognizedToken);
 }