Beispiel #1
0
    void OnMessage(MessageResponse resp, string customData)
    {
        if (resp != null && (resp.intents.Length > 0 || resp.entities.Length > 0))
        {
            string intent = resp.intents[0].intent;
            Debug.Log("Intent: " + intent);
            string currentMat   = null;
            string currentScale = null;
            if (intent == "create")
            {
                bool createdObject = false;
                foreach (EntityResponse entity in resp.entities)
                {
                    Debug.Log("entityType: " + entity.entity + " , value: " + entity.value);
                    if (entity.entity == "material")
                    {
                        currentMat = entity.value;
                    }
                    if (entity.entity == "scale")
                    {
                        currentScale = entity.value;
                    }
                    else if (entity.entity == "object")
                    {
                        gameManager.CreateObject(entity.value, currentMat, currentScale);
                        createdObject = true;
                        currentMat    = null;
                        currentScale  = null;
                    }
                }

                if (!createdObject)
                {
                    gameManager.PlayError(sorryClip);
                }
            }
            else if (intent == "destroy")
            {
                gameManager.DestroyAtRight();
                gameManager.DestroyAtLeft();
            }
            else if (intent == "help")
            {
                if (helpClips.Count > 0)
                {
                    gameManager.PlayClip(helpClips[Random.Range(0, helpClips.Count)]);
                }
            }
            else if (intent == "screenshot")
            {
                //Assumes is attached to the [CameraRig]
                Camera camera = transform.parent.FindChild("Camera (eye)").GetComponent <Camera>();
                DemoScreen.takeScreenshot(camera);
            }
        }
        else
        {
            Debug.Log("Failed to invoke OnMessage();");
        }
    }
Beispiel #2
0
    public void Run()
    {
        Console.WriteLine("Welcome");
        Console.WriteLine("1-Game");
        Console.WriteLine("2-Help");
        Console.WriteLine("3-Demo");
        Console.WriteLine("ESC-Quit");
        ConsoleKeyInfo key = Console.ReadKey();

        switch (key.Key)
        {
        case ConsoleKey.D1: Game g = new Game(); g.Run(); break;

        case ConsoleKey.D2: HelpScreen h = new HelpScreen(); h.Run(); break;

        case ConsoleKey.D3: DemoScreen d = new DemoScreen(); d.Run(); break;
        }
    }
    void OnMessage(object resp, Dictionary <string, object> customData)
    {
        //  Convert resp to fsdata

        fsData   fsdata = null;
        fsResult r      = _serializer.TrySerialize(resp.GetType(), resp, out fsdata);

        if (!r.Succeeded)
        {
            throw new WatsonException(r.FormattedMessages);
        }

        //  Convert fsdata to MessageResponse
        MessageResponse messageResponse = new MessageResponse();
        object          obj             = messageResponse;

        r = _serializer.TryDeserialize(fsdata, obj.GetType(), ref obj);
        if (!r.Succeeded)
        {
            throw new WatsonException(r.FormattedMessages);
        }

        if (resp != null && (messageResponse.intents.Length > 0 || messageResponse.entities.Length > 0))
        {
            string intent = messageResponse.intents[0].intent;
            Debug.Log("Intent: " + intent);
            string currentMat   = null;
            string currentScale = null;
            if (intent == "create")
            {
                bool createdObject = false;
                foreach (RuntimeEntity entity in messageResponse.entities)
                {
                    Debug.Log("entityType: " + entity.entity + " , value: " + entity.value);
                    if (entity.entity == "material")
                    {
                        currentMat = entity.value;
                    }
                    if (entity.entity == "scale")
                    {
                        currentScale = entity.value;
                    }
                    else if (entity.entity == "object")
                    {
                        gameManager.CreateObject(entity.value, currentMat, currentScale);
                        createdObject = true;
                        currentMat    = null;
                        currentScale  = null;
                    }
                }

                if (!createdObject)
                {
                    gameManager.PlayError(sorryClip);
                }
            }
            else if (intent == "destroy")
            {
                gameManager.DestroyAtRight();
                gameManager.DestroyAtLeft();
            }
            else if (intent == "help")
            {
                if (helpClips.Count > 0)
                {
                    gameManager.PlayClip(helpClips[Random.Range(0, helpClips.Count)]);
                }
            }
            else if (intent == "screenshot")
            {
                //Assumes is attached to the [CameraRig]
                Camera camera = transform.parent.Find("Camera (eye)").GetComponent <Camera>();
                DemoScreen.takeScreenshot(camera);
            }
        }
        else
        {
            Debug.Log("Failed to invoke OnMessage();");
        }
    }
Beispiel #4
0
    public void Run()
    {
        Console.ForegroundColor = ConsoleColor.Red;
        string text = "Welcome To DamMan!";

        Console.SetCursorPosition(40 - text.Length / 2, 12);
        Console.WriteLine(text);
        Console.ReadKey();
        Console.Clear();

        do
        {
            Console.SetCursorPosition(40, 12);
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("D. Demo");
            Console.SetCursorPosition(40, 13);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("H. HighScore");
            Console.SetCursorPosition(40, 14);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("C. Credits");
            Console.SetCursorPosition(40, 15);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("G. Game");
            Console.ResetColor();
            char option = Convert.ToChar(Console.ReadLine().ToLower());

            switch (option)
            {
            case 'd':
                Console.Clear();
                myDemoScreen = new DemoScreen();
                myDemoScreen.Run();
                Console.Clear();
                break;

            case 'h':
                Console.Clear();
                myHiScoresScreen = new HiScoresScreen();
                myHiScoresScreen.Run();
                Console.Clear();
                break;

            case 'c':
                Console.Clear();
                myCreditsScreen = new CreditsScreen();
                myCreditsScreen.Run();
                Console.Clear();
                break;

            case 'g':
                Console.Clear();
                Console.SetCursorPosition(40, 15);
                Console.ForegroundColor = ConsoleColor.Red;
                //Console.WriteLine("Bye!");
                exit = true;
                break;

            default:
                Console.WriteLine("Wrong Option!");
                break;
            }
        }while (!exit);
    }