Exemple #1
0
        public void AddActorAction(IActor Actor, Object callback = null, String saveDictionary = "", bool IsDynamic = false)
        {
            String       id          = null;
            CallbackDTO  cdo         = new CallbackDTO();
            PropertyInfo Description = null;
            PropertyInfo Name        = null;
            PropertyInfo Scene       = null;

            if (callback != null)
            {
                Description = callback.GetType().GetProperty("Description");
                Name        = callback.GetType().GetProperty("Name");
                Scene       = callback.GetType().GetProperty("Scene");
                var t = callback.GetType().GetProperty("t");
                var c = callback.GetType().GetProperty("c");

                if (c != null)
                {
                    id                 = Guid.NewGuid().ToString("N");
                    cdo.c              = (Action)c.GetValue(callback, null);
                    cdo.Scene          = (Scene == null) ? data.CurrentScene : Scene.GetValue(callback, null).ToString();
                    cdo.CurrentScene   = data.CurrentScene;
                    cdo.IsDynamicScene = IsDynamic;
                    if (saveDictionary != "")
                    {
                        if (!GLTempData.CallBackSaveList.ContainsKey(saveDictionary))
                        {
                            GLTempData.CallBackSaveList.Add(saveDictionary, cdo.c);
                        }
                        else
                        {
                            GLTempData.CallBackSaveList[saveDictionary] = cdo.c;
                        }
                    }
                }
                if (t != null)
                {
                    id               = Guid.NewGuid().ToString("N");
                    cdo.t            = Convert.ToInt32(t.GetValue(callback, null).ToString());
                    cdo.Scene        = (Scene == null) ? data.CurrentScene : Scene.GetValue(callback, null).ToString();
                    cdo.CurrentScene = data.CurrentScene;
                }
                if (id != null)
                {
                    sc.Callbacks.Add(id, cdo);
                }
            }
            ActorsDTO adt = new ActorsDTO()
            {
                id          = id,
                Name        = (Name == null) ? Actor.Name : Name.GetValue(callback, null).ToString(),
                Scene       = (Scene == null) ? data.CurrentScene : Scene.GetValue(callback, null).ToString(),
                Description = (Description == null) ? "" : Description.GetValue(callback, null).ToString(),
                t           = Actor.t,
                c           = Actor.c
            };

            sc.Actors.Add(adt);
        }
Exemple #2
0
 public GLScene RunCallBackTime(CallbackDTO cb)
 {
     if (cb.t > 0)
     {
         game.data.time.AddTime(cb.t);
     }
     return(game);
 }
Exemple #3
0
        public String RegisterHtmlEvent(Func <String> ev, String Scene = "")
        {
            CallbackDTO cdo = new CallbackDTO();
            String      id  = Guid.NewGuid().ToString("N");

            cdo.html  = ev;
            cdo.Scene = (!String.IsNullOrEmpty(Scene)) ? Scene : data.CurrentScene;
            sc.InternalCallbacks.Add(id, cdo);
            return(id);
        }
Exemple #4
0
        public void AddDirection(ILocation Location, Object callback = null, bool CopyToAction = false)
        {
            String       id          = null;
            CallbackDTO  cdo         = new CallbackDTO();
            PropertyInfo Name        = null;
            PropertyInfo Description = null;

            if (callback != null)
            {
                Description = callback.GetType().GetProperty("Description");
                var t = callback.GetType().GetProperty("t");
                var c = callback.GetType().GetProperty("c");
                Name = callback.GetType().GetProperty("Name");

                if (c != null)
                {
                    id               = Guid.NewGuid().ToString("N");
                    cdo.c            = (Action)c.GetValue(callback, null);
                    cdo.Scene        = Location.Scene;
                    cdo.CurrentScene = data.CurrentScene;
                }
                if (t != null)
                {
                    id               = Guid.NewGuid().ToString("N");
                    cdo.t            = Convert.ToInt32(t.GetValue(callback, null).ToString());
                    cdo.Scene        = Location.Scene;
                    cdo.CurrentScene = data.CurrentScene;
                }
                if (id != null)
                {
                    sc.Callbacks.Add(id, cdo);
                }
            }

            DirectionDTO ddt = new DirectionDTO()
            {
                id          = id,
                Name        = (Name != null) ? Name.GetValue(callback, null).ToString() : Location.Name,
                Description = (Description != null) ? Description.GetValue(callback, null).ToString() : Location.Description,
                Scene       = Location.Scene
            };

            sc.Directions.Add(ddt);
            if (CopyToAction)
            {
                ActionDTO adto = new ActionDTO()
                {
                    id          = id,
                    Name        = (Name != null) ? Name.GetValue(callback, null).ToString() : Location.Name,
                    Description = (Description != null) ? Description.GetValue(callback, null).ToString() : Location.Description,
                    Scene       = Location.Scene
                };
                sc.Actions.Add(adto);
            }
        }
Exemple #5
0
        public String RegisterEvent(Action ev, String Scene = "")
        {
            CallbackDTO cdo = new CallbackDTO();
            String      id  = Guid.NewGuid().ToString("N");

            cdo.c            = ev;
            cdo.Scene        = (!String.IsNullOrEmpty(Scene)) ? Scene : data.CurrentScene;
            cdo.CurrentScene = data.CurrentScene;
            sc.Callbacks.Add(id, cdo);
            return(id);
        }
Exemple #6
0
 public GLScene RunCallBack(CallbackDTO cb)
 {
     game.LastCallBack = cb;
     if (cb.c != null)
     {
         cb.c();
     }
     if (cb.t > 0)
     {
         game.data.time.AddTime(cb.t);
     }
     return(game);
 }
Exemple #7
0
        public void AddDynamicAction(Object Action, bool IsDynamic = false)
        {
            var          Description = Action.GetType().GetProperty("Description");//.GetValue(Action, null).ToString();
            var          t           = Action.GetType().GetProperty("t");
            var          c           = Action.GetType().GetProperty("c");
            var          LoadLast    = Action.GetType().GetProperty("LoadLast");
            String       id          = null;
            CallbackDTO  cdo         = new CallbackDTO();
            PropertyInfo Scene       = Action.GetType().GetProperty("Scene");

            if (c != null)
            {
                id                 = Guid.NewGuid().ToString("N");
                cdo.c              = (Action)c.GetValue(Action, null);
                cdo.Scene          = (Scene == null) ? data.CurrentScene : Scene.GetValue(Action, null).ToString();
                cdo.CurrentScene   = data.CurrentScene;
                cdo.IsDynamicScene = IsDynamic;
            }
            if (LoadLast != null && (Boolean)LoadLast.GetValue(Action, null) == true)
            {
                cdo.LoadLast = LastCallBack;
            }
            if (t != null)
            {
                id               = Guid.NewGuid().ToString("N");
                cdo.t            = Convert.ToInt32(t.GetValue(Action, null).ToString());
                cdo.Scene        = (Scene == null) ? data.CurrentScene : Scene.GetValue(Action, null).ToString();
                cdo.CurrentScene = data.CurrentScene;
            }
            if (id != null)
            {
                sc.Callbacks.Add(id, cdo);
            }

            ActionDTO adto = new ActionDTO()
            {
                id          = id,
                Name        = Action.GetType().GetProperty("Name").GetValue(Action, null).ToString(),
                Scene       = (Scene == null) ? data.CurrentScene : Scene.GetValue(Action, null).ToString(),
                Description = (Description == null) ? "" : Description.GetValue(Action, null).ToString()
            };

            sc.Actions.Add(adto);
        }
    private void PrintResults(CallbackDTO callback)
    {
        foreach (var result in callback.Links)
        {
            if (result.Rel.Equals("results"))
            {
                var request = WebRequest.Create(result.Href);
                request.Method = result.Method;
                request.Headers.Add("Authorization", $"Basic {EncodedAuth()}");

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream stream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            var data = reader.ReadToEnd();
                            Console.WriteLine(data);
                        }

                break;
            }
        }
    }
Exemple #9
0
        public GLScene GetView(String SceneID, bool newGame = false)
        {
            CurrentScenes(SceneID);
            String className  = SceneID.Replace("/", ".");
            var    gameObject = RunClass(className, newGame);

            if (gameObject == null)
            {
                return(new GLScene(new Exception("Game scene " + className + " not found")));
            }

            if (game.data.CurrentLocation != null && game.data.CurrentLocation.LocationBags != null && game.data.CurrentLocation.LocationBags.Count > 0)
            {
                foreach (var lb in game.data.CurrentLocation.LocationBags)
                {
                    CallbackDTO cdo = new CallbackDTO();
                    String      id  = Guid.NewGuid().ToString("N");
                    cdo.c = (Action)(() =>
                    {
                        ((Room)(game.data.CurrentLocation)).GetBag(game.data.player, lb);
                    });
                    cdo.Scene        = game.data.CurrentLocation.Scene;
                    cdo.CurrentScene = game.data.CurrentScene;
                    game.sc.Callbacks.Add(id, cdo);

                    ActorsDTO adto = new ActorsDTO()
                    {
                        id          = id,
                        Name        = "Взять " + lb.Name,
                        Scene       = game.data.CurrentLocation.Scene,
                        Description = "Забрать сумку " + lb.Name
                    };
                    game.sc.Actors.Add(adto);
                }
            }

            return(game);
        }