Ejemplo n.º 1
0
        public ActionResult Create(string name)
        {
            //if (this.db.CreateCriteria<Avatar>().CreateAlias("BaseAppearance", "A").Add(Restrictions.Eq("A.Name", name)).UniqueResult<Avatar>() == null)
            if ( (from a in this.db.Query<Avatar>() where a.Name == name select true).Count() == 0 )
            {
                Location location			= this.db.Get<Location>(l => l.X == 50 && l.Y == 50);
                ComponentType avatarType 	= db.Get<ComponentType>(x => x.Id == "avatar");
                Avatar avatar				= new Avatar(avatarType) {Name = name , User  = this.user,  Location = location};

                using (this.db.Lock(this.globals, this.user.Avatars))
                {
                    avatar.Id = this.globals.NewAvatarId();
                    this.user.Avatars.Add(avatar);
                }

                Interactor.Instance.Interact(avatar, location, "Spawn.Character", null);

                return RedirectToAction("Account", "User");
            }
            else
            {
                this.SetError("A character with the same name already exists");
                return RedirectToAction("Index");
            }
        }
Ejemplo n.º 2
0
        // Called before the action in the inherited controller is executed, allowing certain members to be set
        protected override void OnActionExecuting(ActionExecutingContext ctx)
        {
            base.OnActionExecuting(ctx);

            this.db = HengeApplication.DataProvider;
            this.globals = HengeApplication.Globals;

            // If the user has logged in then add their name to the view data
            if (this.User.Identity.IsAuthenticated)
            {
                this.user					= this.db.Get<User>(x => x.Name == this.User.Identity.Name);
                this.avatar					= Session["Avatar"] as Avatar;
                if(this.avatar != null && this.avatar.User != this.user) {
                    this.avatar = null;
                }
                this.cache					= Session["Cache"] as Cache;

                this.ViewData["User"] 		= this.User.Identity.Name;
                this.ViewData["Character"]	= (this.avatar != null) ? string.Format("{0} of {1}", this.avatar.Name, this.user.Clan) : null;
            }
            else
            {
                this.user 	= null;
                this.avatar	= null;
            }
        }
Ejemplo n.º 3
0
 public GameViewModel(Avatar avatar, string clan, IList<Avatar> others)
 {
     this.Clan = clan;
     this.Avatar = avatar;
     this.Others = others;
 }