protected void copyFromOverlay(Overlay overlay)
 {
     copyFromImageModifer(overlay);
     _position = new IntVector2(overlay._position);
     _mirror = overlay._mirror;
     _alpha = overlay._alpha;
     _textureAlpha = overlay._textureAlpha;
     _alphaOption = overlay._alphaOption;
     _normalScale = overlay._normalScale;
     _normalOption = overlay._normalOption;
     _blendMethod = overlay._blendMethod;
     _rotation = overlay._rotation;
 }
            protected void loadOverlay(ConfigNode node)
            {
                _position = new IntVector2();
                _mirror = false;
                _alpha = 255;
                _textureAlpha = 0;
                _alphaOption = AlphaOption.USE_TEXTURE;
                _normalScale = 2.0f;
                _normalOption = NormalOption.USE_BACKGROUND;
                _blendMethod = BlendMethod.RGB;
                _rotation = Rotation.R0;

                if (node.HasValue("x")) _position.x = int.Parse(node.GetValue("x"));
                if (node.HasValue("y")) _position.y = int.Parse(node.GetValue("y"));
                if (node.HasValue("mirror")) _mirror = bool.Parse(node.GetValue("mirror"));
                if (node.HasValue("alpha")) _alpha = byte.Parse(node.GetValue("alpha"));
                if (node.HasValue("textureAlpha")) _textureAlpha = byte.Parse(node.GetValue("textureAlpha"));
                if (node.HasValue("alphaOption")) _alphaOption = (AlphaOption)ConfigNode.ParseEnum(typeof(AlphaOption), node.GetValue("alphaOption"));
                if (node.HasValue("normalScale")) _normalScale = int.Parse(node.GetValue("normalScale"));
                if (node.HasValue("normalOption")) _normalOption = (NormalOption)ConfigNode.ParseEnum(typeof(NormalOption), node.GetValue("normalOption"));
                if (node.HasValue("blendMethod")) _blendMethod = (BlendMethod)ConfigNode.ParseEnum(typeof(BlendMethod), node.GetValue("blendMethod"));
                if (node.HasValue("rotation")) _rotation = (Rotation)ConfigNode.ParseEnum(typeof(Rotation), node.GetValue("rotation"));
            }
Beispiel #3
0
        async Task VirtualVoteOptionAsync(ApplicationDbContext Context, NormalOption option, int value)
        {
            string  UserID = UserManager.GetUserId(User);
            Profile Voter  = await Context
                             .Profiles
                             .Include(p => p.Missions)
                             .Where(p => p.ProfileID == UserID)
                             .FirstOrDefaultAsync();

            if (Voter.VirtualCoins < value)
            {
                ErrorMessage = "餘額不足";
                return;
            }

            //消耗虛擬貨幣
            Voter.VirtualCoins -= value;
            CheckMissionVote(Voter);
            Context.Attach(Voter).State = EntityState.Modified;

            var Voting = await Context
                         .Votings
                         .Where(v => v.VotingID == option.VotingID)
                         .FirstOrDefaultAsync();

            Voting.TotalCoins           += value;
            Context.Attach(Voting).State = EntityState.Modified;

            var episode = await Context
                          .Episodes.Where(e => e.EpisodeID == Voting.EpisodeID)
                          .FirstOrDefaultAsync();

            var novel = await Context
                        .Novels
                        .Where(n => n.NovelID == episode.NovelID)
                        .FirstOrDefaultAsync();

            novel.MonthlyCoins         += value;
            novel.TotalCoins           += value;
            Context.Attach(novel).State = EntityState.Modified;

            var Involving = await Context.Involvings
                            .Where(i => i.NovelID == novel.NovelID)
                            .Where(i => i.InvolverID == Voter.ProfileID)
                            .FirstOrDefaultAsync();

            if (Involving != null)
            {
                Involving.Value                 = value;
                Involving.MonthlyValue         += value;
                Involving.TotalValue           += value;
                Involving.LastTime              = DateTime.Now;
                Context.Attach(Involving).State = EntityState.Modified;
            }
            else
            {
                Involving newInvolving = new Involving()
                {
                    Value        = value,
                    MonthlyValue = value,
                    TotalValue   = value,
                    LastTime     = DateTime.Now,
                    InvolverID   = UserID,
                    NovelID      = novel.NovelID
                };
                Context.Involvings.Add(newInvolving);
            }
            option.TotalCoins           += value;
            Context.Attach(option).State = EntityState.Modified;
            await Context.SaveChangesAsync();
        }
Beispiel #4
0
        async Task VoteOptionAsync(ApplicationDbContext Context, NormalOption option, int value)
        {
            string  UserID = UserManager.GetUserId(User);
            Profile Voter  = await Context
                             .Profiles
                             .Include(p => p.Missions)
                             .Where(p => p.ProfileID == UserID)
                             .FirstOrDefaultAsync();

            Profile Creator = await Context
                              .Profiles
                              .Where(p => p.ProfileID == option.OwnerID)
                              .FirstOrDefaultAsync();

            if (Voter.RealCoins < value)
            {
                ErrorMessage = "餘額不足";
                return;
            }

            var Voting = await Context
                         .Votings
                         .Where(v => v.VotingID == option.VotingID)
                         .FirstOrDefaultAsync();

            Voting.TotalCoins           += value;
            Context.Attach(Voting).State = EntityState.Modified;

            //主要用來判斷月收入的來源
            if (Voting.Policy == Voting.PolicyType.Liberty)
            {
                Creator.MonthlyCoins += (decimal)(value * 0.6);//自由模式,作者得60%分潤
            }
            else
            {
                Creator.MonthlyCoins += (decimal)(value * 0.7);//平等模式,作者得70%分潤
            }
            Context.Attach(Creator).State = EntityState.Modified;
            //消耗實體貨幣
            Voter.RealCoins -= value;
            CheckMissionVote(Voter);
            Context.Attach(Voter).State = EntityState.Modified;

            var episode = await Context
                          .Episodes.Where(e => e.EpisodeID == Voting.EpisodeID)
                          .FirstOrDefaultAsync();

            var novel = await Context
                        .Novels
                        .Where(n => n.NovelID == episode.NovelID)
                        .FirstOrDefaultAsync();

            novel.MonthlyCoins         += value;
            novel.TotalCoins           += value;
            Context.Attach(novel).State = EntityState.Modified;

            var Involving = await Context.Involvings
                            .Where(i => i.NovelID == novel.NovelID)
                            .Where(i => i.InvolverID == Voter.ProfileID)
                            .FirstOrDefaultAsync();

            if (Involving != null)
            {
                Involving.Value                 = value;
                Involving.MonthlyValue         += value;
                Involving.TotalValue           += value;
                Involving.LastTime              = DateTime.Now;
                Context.Attach(Involving).State = EntityState.Modified;
            }
            else
            {
                Involving newInvolving = new Involving()
                {
                    Value        = value,
                    MonthlyValue = value,
                    TotalValue   = value,
                    LastTime     = DateTime.Now,
                    InvolverID   = UserID,
                    NovelID      = novel.NovelID
                };
                Context.Involvings.Add(newInvolving);
            }
            option.TotalCoins           += value;
            Context.Attach(option).State = EntityState.Modified;

            await Context.SaveChangesAsync();
        }
        public void normalMapOptionSelector(TextureEditGUI gui, ref NormalOption normalOption)
        {
            GUILayout.BeginVertical(GUI.skin.box, GUILayout.ExpandHeight(true));

            GUILayout.Label("Normal Option");

            int selection = (int)normalOption;
            int oldSelection = selection;
            selection = GUILayout.SelectionGrid(selection, _normalOptionGrid, 2);

            if (oldSelection != selection)
            {
                normalOption = (NormalOption)selection;
                gui.setRemakePreview();
            }

            GUILayout.EndVertical();
        }