예제 #1
0
 public override bool TakeAction()
 {
     if (GetEnemys.LogList.Count > 0)
     {
         receipt = GetEnemys.LogList[GetEnemys.LogList.Count - 1];
     }
     return(true);
 }
 public void PushLog(EnemyLogData log)
 {
     if (LogList.Count >= DataHelper.MaxMailNum)
     {
         LogList.RemoveAt(0);
     }
     IsHaveNewLog = true;
     LogList.Add(log);
 }
예제 #3
0
        public override bool TakeAction()
        {
            receipt        = new StealReceipt();
            receipt.Result = false;

            if (GetLottery.StealTimes <= 0 || selectIndex >= 3)
            {
                return(true);
            }
            StealRobTarget target = GetLottery.StealList[selectIndex];
            var            rival  = UserHelper.FindUserBasis(target.RivalUid);

            if (rival == null)
            {
                return(true);
            }
            var rivalEnemy = UserHelper.FindUserEnemy(rival.UserID);

            if (rivalEnemy == null)
            {
                return(true);
            }

            GetLottery.StealTimes--;
            receipt.Gold = target.Gold;

            UserHelper.RewardsGold(Current.UserId, target.Gold);
            BigInteger dummyGold = BigInteger.Parse(target.Gold);
            BigInteger realGold  = rival.GoldNum <= dummyGold * 2 ? rival.GoldNum / 2 : dummyGold;

            UserHelper.ConsumeGold(rival.UserID, realGold);
            rivalEnemy.AddEnemy(new EnemyData()
            {
                UserId = Current.UserId
            });
            EnemyLogData log = new EnemyLogData()
            {
                RivalUid        = Current.UserId,
                RivalName       = GetBasis.NickName,
                RivalAvatarUrl  = GetBasis.AvatarUrl,
                LogTime         = DateTime.Now,
                LossGold        = realGold.ToString(),
                IsSteal         = true,
                RivalProfession = GetBasis.Profession
            };

            rivalEnemy.PushLog(log);
            PushMessageHelper.NewStealRobNotification(GameSession.Get(rival.UserID));

            if (target.IsPrimary)
            {
                GetLottery.StealList.Clear();
                UserHelper.RandomStealTarget(Current.UserId);
            }
            else
            {
                UserHelper.RandomStealTarget2(Current.UserId);
            }

            foreach (var v in GetLottery.StealList)
            {
                UserBasisCache      basis     = UserHelper.FindUserBasis(v.RivalUid);
                UserAttributeCache  attribute = UserHelper.FindUserAttribute(v.RivalUid);
                UserEquipsCache     equips    = UserHelper.FindUserEquips(v.RivalUid);
                CombatMatchUserData data      = new CombatMatchUserData()
                {
                    UserId        = basis.UserID,
                    NickName      = basis.NickName,
                    Profession    = basis.Profession,
                    AvatarUrl     = basis.AvatarUrl,
                    RankId        = basis.LevelRankID,
                    UserLv        = basis.UserLv,
                    VipLv         = basis.VipLv,
                    FightingValue = attribute.FightValue,
                    Equips        = equips,
                    // SkillCarryList = user.SkillCarryList
                };

                receipt.StealList.Add(data);
            }

            receipt.Lottery = GetLottery;
            receipt.Result  = true;
            return(true);
        }
예제 #4
0
        public override bool TakeAction()
        {
            receipt        = new RobReceipt();
            receipt.Result = false;

            if (GetLottery.RobTimes <= 0)
            {
                return(true);
            }
            if (GetLottery.Rob.RivalUid != selectId &&
                !GetEnemys.IsHaveEnemy(selectId) &&
                !GetFriends.IsHaveFriend(selectId))
            {
                return(true);
            }

            var rival = UserHelper.FindUserBasis(selectId);

            if (rival == null)
            {
                return(true);
            }
            var rivalEnemy = UserHelper.FindUserEnemy(rival.UserID);

            if (rivalEnemy == null)
            {
                return(true);
            }

            var lotterycfg = new ShareCacheStruct <Config_Lottery>().Find(t => (t.Type == LotteryAwardType.Rob));

            if (lotterycfg == null)
            {
                return(false);
            }

            GetLottery.RobTimes--;

            BigInteger dummyGold = 0;

            if (GetLottery.Rob.RivalUid == selectId)
            {
                dummyGold = BigInteger.Parse(GetLottery.Rob.Gold);

                GetLottery.Rob.RivalUid       = 0;
                GetLottery.Rob.RivalName      = string.Empty;
                GetLottery.Rob.RivalAvatarUrl = string.Empty;
                GetLottery.Rob.Gold           = "0";
                UserHelper.RandomRobTarget(Current.UserId);
            }
            if (GetFriends.IsHaveFriend(selectId))
            {
                var frienddata = GetFriends.FindFriend(selectId);
                dummyGold = BigInteger.Parse(frienddata.RobGold);

                frienddata.RobGold = "0";
                GetFriends.AddRobRecord(selectId);
            }
            if (GetEnemys.IsHaveEnemy(selectId))
            {
                var enemydata = GetEnemys.FindEnemy(selectId);
                dummyGold = BigInteger.Parse(enemydata.RobGold);

                GetEnemys.RemoveEnemy(rival.UserID);
            }

            if (result == EventStatus.Bad)
            {
                dummyGold = dummyGold / 5;
            }

            receipt.Gold = dummyGold.ToString();
            UserHelper.RewardsGold(Current.UserId, dummyGold);
            BigInteger realGold = rival.GoldNum <= dummyGold * 2 ? rival.GoldNum / 2 : dummyGold;

            UserHelper.ConsumeGold(rival.UserID, realGold);

            int levelDown = 0;

            if (result == EventStatus.Good)
            {
                int downlv = rival.UserLv <= 1000 ? 10 : rival.UserLv / 100;
                levelDown = Math.Max(rival.UserLv - downlv, 0);
                levelDown = Math.Min(levelDown, downlv);
                //rival.UserLv = Math.Max(rival.UserLv - levelDown, 10);
                //UserHelper.UserLvChange(rival.UserID);
                //PushMessageHelper.UserLvChangeNotification(GameSession.Get(rival.UserID));
                rival.BackLevelNum += downlv;
            }

            rivalEnemy.AddEnemy(new EnemyData()
            {
                UserId = Current.UserId
            });



            EnemyLogData log = new EnemyLogData()
            {
                RivalUid        = Current.UserId,
                RivalName       = GetBasis.NickName,
                RivalAvatarUrl  = GetBasis.AvatarUrl,
                LogTime         = DateTime.Now,
                LossGold        = realGold.ToString(),
                LevelDown       = levelDown,
                IsSteal         = false,
                Status          = result,
                RivalProfession = GetBasis.Profession
            };

            rivalEnemy.PushLog(log);
            PushMessageHelper.NewStealRobNotification(GameSession.Get(rival.UserID));



            receipt.Lottery = GetLottery;
            receipt.Result  = true;


            return(true);
        }