Ejemplo n.º 1
0
        private RadialMenuCommand CreateKnownCommand(CommandId id)
        {
            RadialMenuCommand command = null;

            switch (id)
            {
            case CommandId.Open:
                command = new OpenMenuCommand();
                break;

            case CommandId.Close:
                command = new CloseMenuCommand();
                break;

            case CommandId.NavigateToView:
                command = new NavigateCommand();
                break;

            case CommandId.NavigateBack:
                command = new NavigateBackCommand();
                break;

            default:
                throw new ArgumentException("Unknown command id!", "id");
            }

            command.Id    = id;
            command.Owner = this.Owner;

            return(command);
        }
Ejemplo n.º 2
0
    void CustomCommand( string command, bool pushCommand = false )
    {
        char[] delimiter = new char[3];
        delimiter[0] = ' ';
        delimiter[1] = '\t';
        delimiter[2] = '%';
        string[] parsedCommand = command.Split( delimiter, System.StringSplitOptions.RemoveEmptyEntries );
        switch( parsedCommand[0].ToLower() )
        {
            case "bgm":
                {

                    if (parsedCommand.Length > 1)
                    {
                        Debug.Log("<color=green>[StringParser]</color> CREATED NEW BGM COMMAND + " + parsedCommand[1].ToLower());
                        MusicCommand BGM = new MusicCommand();
                        BGM.Set(parsedCommand[1].ToLower());
                        CommandManager.Instance.AddCommand(BGM);
                    }
                }
                break;
        //NOTE(Hendry)::Add command here
        case "bg":
        BgCommand bgc = new BgCommand();
        if( parsedCommand.Length == 2 )
        {
            bgc.SetBg(parsedCommand[1].ToLower());
            if (parsedCommand.Length == 3)
            {
                bgc.SetSpd(int.Parse(parsedCommand[2]));
            }
            if( pushCommand )
            {
                CommandManager.Instance.AddPushCommand(bgc);
            }
            else
            {
                CommandManager.Instance.AddCommand( bgc );
            }
        }

        break;

        case "show":
        ShowCharacterCommand character = new ShowCharacterCommand();
        if( parsedCommand.Length >= 3 )
        {
            character.SetCharacterName( parsedCommand[1].ToLower() );
            character.SetSpawnLocation( parsedCommand[2].ToLower() );
            if( pushCommand )
            {
                CommandManager.Instance.AddPushCommand( character );
            }
            else
            {
                CommandManager.Instance.AddCommand( character );
            }
            if (parsedCommand.Length >= 4)
            {
                character.SetFacing( parsedCommand[3].ToLower() );
            }
        }
        break;

        case "pose":
        ChangePoseCommand newPoseCommand = new ChangePoseCommand();
        newPoseCommand.SetNewPose( parsedCommand[1].ToLower(), parsedCommand[2].ToLower() );
        if( pushCommand )
        {
            CommandManager.Instance.AddPushCommand( newPoseCommand );
        }
        else
        {
            CommandManager.Instance.AddCommand( newPoseCommand );
        }
        break;

        case "location":
        if( parsedCommand.Length == 3 )
        {
            bool set = false;
            if( parsedCommand[2].ToLower() == "on" )
            {
                set = true;
            }
            else if( parsedCommand[2].ToLower() == "off" )
            {
                set = false;
            }
            else
            {
                Debug.Log( "[String Parser]<color=red>wrong command</color> !! the format is icon iconName on/off" );
                //Debug.Break();
            }
            locationManager.Instance.SetButton(parsedCommand[1], set);
        }
        else
        {
            Debug.Log( "[String Parser]<color=red>wrong command</color> !! the format is icon iconName on/off" );
            //Debug.Break();
        }
        break;

        case "eff":
        EffectCommand newEffect = new EffectCommand();
        newEffect.SetEffect( parsedCommand[1] );
        if( pushCommand )
        {
            CommandManager.Instance.AddPushCommand( newEffect );
        }
        else
        {
            CommandManager.Instance.AddCommand( newEffect );
        }
        break;

        case "item":
        if(!GameManager.instance.IsDemoMode())
        ItemManager.Instance.AddItem( parsedCommand[1].ToLower() );
        break;

        case "icon":
        //Note(Hendry) : format is -> icon itemName position scale
        // position[] = middle/mid/m left/l right/r
        // scale float value
        // to destroy -> icon destroy
        IconCommand iconCommand;
        if( parsedCommand[1].ToLower() == "destroy" )
        {
            iconCommand = new IconCommand( true );
        }
        else
        {
            iconCommand = new IconCommand( parsedCommand[1], parsedCommand[2], float.Parse( parsedCommand[3] ) );
        }
        CommandManager.Instance.AddCommand( iconCommand );
        break;

        case "prompt":
        // note : prompt will call the menu then open evidence tab
        // format -> prompt itemName
        CommandManager.Instance.correctItem = parsedCommand[1];
        OpenMenuCommand menuCommand = new OpenMenuCommand();
        CommandManager.Instance.AddCommand( menuCommand );
        break;

        case "advquest":
        if (!GameManager.instance.IsDemoMode())
        SceneManager.Instance.AdvQuest();
        break;

        case "load":
        LoadCommand dialogue = new LoadCommand();
        if( parsedCommand.Length == 2 )
        {
            dialogue.SetLoad( parsedCommand[1].ToLower() );
            CommandManager.Instance.AddCommand( dialogue );
        }
        break;
            case"fade":
                {
                    if (parsedCommand.Length > 2)
                    {
                        FadeCommand foo = new FadeCommand();

                        if (parsedCommand[1].ToLower() == "in")
                            foo.SetFade(-1, float.Parse(parsedCommand[2]));
                        else
                            foo.SetFade(1, float.Parse(parsedCommand[2]));

                        CommandManager.Instance.AddCommand(foo);
                    }
                    else if(parsedCommand.Length > 1)
                    {
                        FadeCommand foo = new FadeCommand();

                        if (parsedCommand[1].ToLower() == "in")
                            foo.SetFade(-1);
                        else
                            foo.SetFade(1);

                        CommandManager.Instance.AddCommand(foo);
                    }
                    else
                    {
                        Debug.Log("STRING PARSER - FADE COMMAND NOT LONG ENOUGH");
                    }
                }
                break;
        }
    }