コード例 #1
0
ファイル: FightBusinessCC.cs プロジェクト: abel/sinan
        /// <summary>
        /// 处理结果(PK)
        /// </summary>
        /// <param name="winTeam">获胜的一方</param>
        /// <param name="lostTeam">失败的一方</param>
        protected virtual void FightEnd(FightObject[] winTeam, FightObject[] lostTeam)
        {
            SendToTeam(winTeam, FightCommand.FightEndR, (int)FightResult.Win, null, null);
            SendToTeam(lostTeam, FightCommand.FightEndR, (int)FightResult.Lose, null, null);

            if (m_changeLife)
            {
                List<string> names = new List<string>(winTeam.Length);
                foreach (FightPlayer f in winTeam)
                {
                    if (f.FType == FighterType.Player)
                    {
                        names.Add(f.Player.Name);
                        if (f.Online)
                        {
                            //记录PK胜利次数
                            f.Player.FinishNote(FinishCommand.PKWin, new object[] { 1 });
                        }
                    }
                }

                //记录死亡日志
                foreach (FightPlayer f in lostTeam)
                {
                    if (f.Online && f.FType == FighterType.Player)
                    {
                        LogVariant log = new LogVariant(ServerLogger.zoneid, Actiontype.PKLoss);
                        log.Value["Killer"] = names;           //对方(名字列表)
                        log.Value["Scene"] = m_scene.ID;       //场景ID
                        log.Value["SceneName"] = m_scene.Name; //场景名字
                        f.Player.WriteLog(log);
                    }
                }
            }
        }
コード例 #2
0
ファイル: FightBusinessFamilyBoss.cs プロジェクト: abel/sinan
        protected override void GameOver()
        {
            try
            {
                if (Interlocked.Exchange(ref m_fightState, 11) < 11)
                {
                    //玩家是否胜利
                    bool allOver = m_teamA.All(x => x.Over);
                    if ((!m_taoPao) && m_teamB.All(x => (x.Over || x.FType == FighterType.BB)))
                    {
                        playerWin = true;
                        //取打怪奖励
                        GiveAwards();
                        //记副本打怪
                        ProcessBos();
                    }
                    else
                    {
                        //还原状态...
                        FamilyBossAccess.Instance.ChangeState(m_familyID + m_npcID, 1, 0);
                    }
                    //发送奖励结果.
                    FightEnd(playerWin);
                    if (playerWin)
                    {
                        Variant playerIDs = CreateBossAward();
                        //保存奖励
                        FamilyBossAccess.Instance.Win(m_familyID + m_npcID, playerIDs);

                        PlayerBusiness leader = m_teamA[0].Player;
                        try
                        {
                            // 通知所有家族成员
                            // [{0}]家族领袖[{1}]带队击杀了家族Boss,全族成员都获得了一次抽奖机会,赶快打开家族按钮,去抽取奖励吧!
                            string msg = string.Format(TipManager.GetMessage(FamilyReturn.KillFamilyBoss), leader.FamilyName, leader.Name);
                            PlayersProxy.CallAll(ClientCommand.SendActivtyR, new object[] { "T02", msg });
                        }
                        catch { }
                        finally
                        {
                            //写日志
                            LogVariant log = new LogVariant(ServerLogger.zoneid, Actiontype.KillFamilyBoss);
                            var names = m_players.Where(x => x != null).Select(x => x.Name).ToList();
                            log.Value["Killer"] = names;
                            var p = GameConfigAccess.Instance.FindOneById(m_npcID);
                            log.Value["Boss"] = p.Name;
                            log.Value["Npc"] = m_npcID;
                            leader.WriteLog(log);
                        }
                    }
                    if (allOver)
                    {
                        LogDead();
                    }
                }
            }
            finally
            {
                base.Close();
            }
        }
コード例 #3
0
ファイル: PetAbsorb.cs プロジェクト: abel/sinan
        /// <summary>
        /// 吸星魔法
        /// </summary>
        /// <param name="note"></param>
        public void Absorb(UserNote note)
        {
            string playerid = note.GetString(0); //被吸人ID
            string soleid = note.GetString(1);   //被吸宠,正在放养的宠物

            PlayerBusiness player = note.Player;

            //吸星魔法等级
            IList levels = player.PetBook.Value.GetValueOrDefault<IList>(AbsorbSkillID);
            if (levels == null || levels.Count == 0)
            {
                note.Call(PetsCommand.PetAbsorbR, false, string.Empty, TipManager.GetMessage(PetsReturn.Absorb1));
                return;
            }
            int level = Convert.ToInt32(levels[levels.Count - 1]);

            //正在放养的宠物
            Pet p = PetAccess.Instance.FindOneById(soleid);
            if (p == null)
            {
                note.Call(PetsCommand.PetAbsorbR, false, string.Empty, TipManager.GetMessage(PetsReturn.NoExists));
                return;
            }

            ////用于吸星的宠物不能高于角色5级
            //if (p.Value.GetIntOrDefault("PetsLevel") - 5 > note.Player.Level)
            //{
            //    note.Call(PetsCommand.PetAbsorbR, false, string.Empty, "用于吸星的宠物不能高于角色5级");
            //    return;
            //}

            //被吸宠当前生命值
            int hp = p.Value.GetValueOrDefault<Variant>("ShengMing").GetIntOrDefault("V");
            if (hp < 1)
            {
                note.Call(PetsCommand.PetAbsorbR, false, string.Empty, TipManager.GetMessage(PetsReturn.StockingNo));
                return;
            }

            //放养宠主人
            PlayerBusiness loster = PlayersProxy.FindPlayerByID(playerid);
            if (loster == null)
            {
                note.Call(PetsCommand.PetAbsorbR, false, string.Empty, TipManager.GetMessage(PetsReturn.NoExists));
                return;
            }

            PlayerEx b2 = loster.B2;
            IList c = b2.Value.GetValue<IList>("C");
            Variant m = null;
            foreach (Variant v in c)
            {
                if (v.GetStringOrDefault("E") == soleid)
                {
                    m = v;
                    break;
                }
            }
            if (m == null)
            {
                //宠物不在家园中
                note.Call(PetsCommand.PetAbsorbR, false, string.Empty, TipManager.GetMessage(PetsReturn.NoExists));
                return;
            }

            //可以得到的奖励
            Variant award = m.GetValueOrDefault<Variant>("T");
            if (award == null)
            {
                //奖励不存在
                note.Call(PetsCommand.PetAbsorbR, false, string.Empty, TipManager.GetMessage(PetsReturn.NoExists));
                return;
            }

            //是否到领奖时间
            DateTime endTime = award.GetDateTimeOrDefault("EndTime");
            if (DateTime.UtcNow < endTime)
            {
                note.Call(PetsCommand.PetAbsorbR, false, string.Empty, TipManager.GetMessage(PetsReturn.NoCareTime));
                return;
            }

            //收益比
            double xishoulv = PetXiShou(note, p, level);
            if (xishoulv <= 0) return;

            int score = (int)(award.GetIntOrDefault("Score") * xishoulv);
            int exp1 = (int)(award.GetIntOrDefault("P1exp") * xishoulv);
            int exp2 = (int)(award.GetIntOrDefault("P2exp") * xishoulv);

            award["Score"] = score;
            award["P1exp"] = exp1;
            award["P2exp"] = exp2;

            //获取奖励
            if (score > 0)
            {
                player.AddScore(score, FinanceType.StockingAward0);
            }
            if (exp1 > 0)
            {
                player.AddExperience(exp1, FinanceType.StockingAward0);
            }
            if (exp2 > 0)
            {
                player.AddPetExp(player.Pet, exp2, true, (int)FinanceType.StockingAward0);
            }

            award.Remove("EndTime");
            b2.Save();
            player.Call(PetsCommand.PetAbsorbR, true, PetAccess.Instance.GetPetModel(m), award);

            string msg = string.Format(TipManager.GetMessage(PetsReturn.Absorb2),
                DateTime.Now, p.Name, note.Player.Name);
            loster.AddBoard(msg);

            //添加吸星日志
            LogVariant log = new LogVariant(ServerLogger.zoneid, Actiontype.Absorb);
            log.Value["Loster"] = loster.PID; //被吸者
            log.Value["Score"] = score;       //石币
            log.Value["P1exp"] = exp1;        //角色经验
            log.Value["P2exp"] = exp2;        //战宠经验
            log.Value["Lv"] = xishoulv;       //吸收率
            player.WriteLog(log);
        }
コード例 #4
0
ファイル: PlayerBusiness_Package.cs プロジェクト: abel/sinan
        /// <summary>
        /// 动态日志记录
        /// </summary>
        /// <param name="t">类型</param>
        /// <param name="us">使用道具数量</param>
        /// <param name="gs">得到的道具</param>        
        /// <param name="os">其它</param>
        public void AddLogVariant(Actiontype t, Variant us, Variant gs, Variant os)
        {
            Variant info = new Variant();
            if (us != null && us.Count > 0)
            {
                info["UseGoods"] = us;
            }
            if (gs != null && gs.Count > 0)
            {
                info["GetGoods"] = gs;
            }
            if (os != null && os.Count > 0)
            {
                foreach (var item in os)
                {
                    info[item.Key] = item.Value;
                }
            }

            LogVariant log = new LogVariant(ServerLogger.zoneid, t);
            log.Value = info;
            WriteLog(log);
        }
コード例 #5
0
ファイル: FightBusiness.cs プロジェクト: abel/sinan
        protected void LogDead()
        {
            List<string> names = new List<string>(m_teamB.Length);

            foreach (FightObject f in m_teamB)
            {
                names.Add(f.Name);
            }
            //记录死亡日志
            foreach (FightPlayer f in m_teamA)
            {
                if (f.Online && f.FType == FighterType.Player)
                {
                    LogVariant log = new LogVariant(ServerLogger.zoneid, Actiontype.APCLoss);
                    log.Value["Killer"] = names;
                    log.Value["Scene"] = m_scene.ID;
                    log.Value["SceneName"] = m_scene.Name;
                    f.Player.WriteLog(log);
                }
            }
        }