Социальная интеллектуальная игра «ЗаБотань!»

Автор работы: Пользователь скрыл имя, 18 Декабря 2013 в 18:34, курсовая работа

Описание работы

Идея совместить популярные игровые механики и интеллектуальное развитие пришла ко мне ещё в 8-ом классе. Для реализации мечты не хватало опыта и единомышленников. БГУИР дал мне и то, и то другое. Я знал, что проект должен быть прост в реализации, а порог входа на выбранный рынок должен быть как можно ниже. И я выбрал рынок социальных игр.

Содержание работы

Введение 3
Классификация игры, сюжет и миссия 4
Структура программы 5
Диаграмма классов 6
Основные алгоритмы 7
Описание игрового процесса 9
Описание игровых вещей Ошибка! Закладка не определена.12
Описание игрового баланса Ошибка! Закладка не определена.13
Заключение 14
Литература 15
Исходный код…………………………………………….…………………………………………….16

Файлы: 1 файл

Пояснительная записка Заботань!.docx

— 739.55 Кб (Скачать файл)

                                        }

                                        #endregion

                                        #region EndFight

                                        else if (thisclient.Fight.Status == FightStatus.End)

                                        {

                                            Client enemy = (Client)thisclient.Fight.Enemy;

                                            //new

                                            //lock (enemy)

                                            //{

                                            //    while (enemy.isproccess) ;

                                            //    enemy.isproccess = true;

                                            //}

 

 

                                            #region Если противник вышел

                                            if (enemy == null || !WorldServer.world_players.Contains(enemy))

                                            {

                                                Arena.GoArena(thisclient);

                                                byte fwin = 1;

                                                if (thisclient.CurrentHP == 0f)

                                                    fwin = 0;

                                                if (fwin == 1)

                                                {

                                                    thisclient.CountFightFvfWin++;

 

                                                    thisclient.SendFightEnd(PlayerFlags.FVF, fwin, 0, 0);

 

                                                    AwardsManager.UA_KillFvf(thisclient);

                                                }

                                                else

                                                {

                                                    thisclient.CountFightFvfLose++;

                                                    thisclient.SendFightEnd(PlayerFlags.FVF, fwin, 0, 0);

                                                }

 

                                                thisclient.Fight.Reset();

                                                thisclient.CurrentHP = thisclient.MaxHP;

                                                thisclient.SendAttributes();

                                                break;

                                            }

                                            #endregion

                                            byte win1 = 0;

                                            byte win2 = 1;

                                            Arena.GoArena(thisclient);

                                            Arena.GoArena(enemy);

                                            #region ничья

                                            if (thisclient.CurrentHP == 0f && enemy.CurrentHP == 0f)

                                            {

                                                win1 = win2 = 2;

                                                thisclient.SendFightEnd(PlayerFlags.FVF, win1, 0, 0);

                                                thisclient.CountFightFvfTie++;

                                                enemy.SendFightEnd(PlayerFlags.FVF, win2, 0, 0);

                                                enemy.CountFightFvfTie++;

                                            }

                                            #endregion

                                            #region игрок выйграл

                                            else if (enemy.CurrentHP == 0f)

                                            {

                                                win1 = 1;

                                                win2 = 0;

 

                                                enemy.CountFightFvfLose++;

                                                enemy.SendFightEnd(PlayerFlags.FVF, win2, 0, 0);

                                                thisclient.CountFightFvfWin++;

                                                thisclient.SendFightEnd(PlayerFlags.FVF, win1, 0, 0);

 

                                                AwardsManager.UA_KillFvf(thisclient);

                                            }

                                            #endregion

                                            else

                                            {

                                                enemy.CountFightFvfWin++;

                                                enemy.SendFightEnd(PlayerFlags.FVF, win2, 0, 0);

 

                                                AwardsManager.UA_KillFvf(enemy);

 

                                                thisclient.CountFightFvfLose++;

                                                thisclient.SendFightEnd(PlayerFlags.FVF, win1, 0, 0);

                                            }

                                            thisclient.CurrentHP = thisclient.MaxHP;

                                            enemy.CurrentHP = enemy.MaxHP;

                                            thisclient.SendAttributes();

                                            enemy.SendAttributes();

 

                                            thisclient.Fight.Reset();

                                            enemy.Fight.Reset();

 

 

                                            thisclient.Fight.IsFriendInviteSend = false;

                                            enemy.Fight.IsFriendInviteSend = false;

                                            thisclient.Fight.FriendInvite = null;

                                            enemy.Fight.FriendInvite = null;

                                            //new

                                            //enemy.isproccess = false;

                                        }

                                        #endregion

                                        break;

                                    #endregion

                                    //default: continue;

                                }

                                sw.Stop();

                                if (sw.ElapsedMilliseconds > 30)

                                    Log.Write(EType.Notice, "{0} [{1}]TIME2-->{2}, {3}, after flag:{4}, fight:{5}", thisclient.ID, Thread.CurrentThread.Name, sw.ElapsedMilliseconds, startTimerStr, thisclient.Flag, thisclient.Fight.Status);

 

                                //thisclient.isproccess = false;

                            }

                        }

                    }

                    catch (Exception e)

                    {

                        Log.Write(EType.Warning, "{0} terminated due to an exception.", Thread.CurrentThread.Name);

                        Log.Write(EType.Warning, "Error message: " + e.Message);

                        Log.Write(EType.Warning, "Stack trace: " + e);

 

                        if (ClientManager.IsRun)

                        {

                            Log.Write(EType.Notice, "Restarting {0}.", Thread.CurrentThread.Name);

                            Update();

                            return;

                        }

                    }

                if (!IsRun)

                {

                    while(WorldThreads.ThreadsCalculationEnabled)

                        for (int i = 0; i < WorldServer.world_players.Count; i++)

                        {

                            thisclient = WorldServer.world_players[i];

                            //Test on DC

                            thisclient.Destruct("ClientManager dc - server exit!");

                        }

                    Log.Write(EType.Notice, "CM Close!");

                    return;

                }

                Thread.Sleep(Config.threadDelay_ClientManager + WorldThreads.ThreadsIdleSleepAddition);

            }

        }

 

        public static void Add(Client client)

        {

            lock (synObj)

            {

                WorldServer.world_players.Add(client);

            }

        }

        public static void Remove(Client client)

        {

            lock (synObj)

            {

                WorldServer.world_players.Remove(client);

            }

        }

    }

}

 

Класс Arena

    public class Arena

    {

        private enum SendFvfMessage : byte

        {

            OK = 0,

            FRIEND_OFFLINE = 1,

            FRIEND_INFIGHT = 2,

            YOU_INFIGHT = 3,

            FRIEND_ISINVITED = 4,

            FRIEND_CANCEL = 5//чел отказался

        }

        /// <summary>

        /// GoArena - Метод перемещает игрока в арену, либо из боя в арену.

        /// </summary>

        /// <param name="c">Игрок, которого нужно переместить.</param>

        public static void GoArena(Client c)

        {

            if (c.Flag != PlayerFlags.MAP &&

                c.Flag != PlayerFlags.PVP && c.Flag != PlayerFlags.FVF && c.Flag != PlayerFlags.ARENA)

            {

                Log.Write(EType.Hack, "{0}: GoArena() - Flag not valid!", c.ID);

                return;

            }

 

            if (c.Fight.Status == FightStatus.Wait)

            {

                if (c.Flag == PlayerFlags.FVF)

                {

                    for (int i = 0; i < WorldServer.world_players.Count; i++)

                    {

                        Client cl = WorldServer.world_players[i];

                        if (cl.Fight.FriendInvite == c)

                            cl.Fight.FriendInvite = null;

                    }

                }

                if (c.Fight.Enemy != null && !c.Fight.Enemy.IsBot)

                {

                    Client cl = (Client)c.Fight.Enemy;

                    cl.Fight.Reset();

                }

               

                c.Fight.Reset();

            }

            else if (c.Fight.Status == FightStatus.Start)

            {

                c.CurrentHP = 0f;

                c.Fight.End();

                if (!c.Fight.Enemy.IsBot)

                {

                    Client cl = (Client)c.Fight.Enemy;

                    cl.Fight.End();

                }

                return;

            }

            else if (c.Fight.Status == FightStatus.Fighting)

            {

                c.CurrentHP = 0f;

                c.Fight.End();

                if (!c.Fight.Enemy.IsBot)

                {

                    Client cl = (Client)c.Fight.Enemy;

                    cl.Fight.End();

                }

                return;

            }

            Packet pak = c.pak;

            pak.Clear();

            pak.Addint16(PacketCommand.SEND_LOCATION_GOARENA);

            pak.Send(c);

            c.SetFlag(PlayerFlags.ARENA);

            Log.Write(EType.Packet, "{0} {1}", c.ID, "<-GoArena");

           

        }

        /// <summary>

        /// GoPvp - Метод перемещает игрока в бой на арену.

        /// </summary>

        /// <param name="c">Игрок, которого нужно переместить.</param>

        public static void GoPvp(Client c)

        {

            #region valid

            if (c.Flag != PlayerFlags.ARENA)

            {

                Log.Write(EType.Hack, "{0}: GoPvp() - Flag not valid!", c.ID);

                return;

            }

            if (c.CurrentEP - Config.EnergyForFight < 0) //Send Message, that don't another energy

            {

                Log.Write(EType.Hack, "{0}: GoPvp() - Недостаточно энергии!", c.ID);

                return;

            }

            if (c.Money - Config.MoneyForFight < 0) //Send Message, that don't another energy

            {

                Log.Write(EType.Hack, "{0}: GoPvp() - Недостаточно денег!", c.ID);

                return;

            }

            #endregion

 

            //c.Fight.Reset();//15.04

            c.Fight.BeginWeit();

 

            Packet pak = c.pak;

            pak.Clear();

            pak.Addint16(PacketCommand.SEND_LOCATION_GOPVP);

            pak.Send(c);

            c.SetFlag(PlayerFlags.PVP);

            Log.Write(EType.Packet, "{0} {1}", c.ID, "<-GoPvp");

 

            Client enemy = WorldServer.GetEnemy(c);

            if (enemy != null)

            {

                c.Fight.BeginFight(enemy);

                enemy.Fight.BeginFight(c);

 

                Log.Write(EType.Player, "{0} User conn fight with {1}", c.ID, enemy.ID);

            }

 

        }

        /// <summary>

        /// GoFvf - Метод перемещает игрока в бой с другом (при нажатии на кнопку "Вызвать на дуэль").

        /// </summary>

        /// <param name="c">Игрок, которого нужно переместить.</param>

        public static void GoFvf(Client c, DataPacket dp)

        {

            #region valid - если игрок не свободен

            if (c.Fight.Status != FightStatus.None)

            {

                Packet pak = c.pak;

                pak.Clear();

                pak.Addint16(PacketCommand.SEND_LOCATION_GOFVF);

                pak.Addbyte((byte)SendFvfMessage.YOU_INFIGHT);

                pak.Send(c);

 

                Log.Write(EType.Packet, "{0} {1}, message: {2}", c.ID, "<-GoFvf",SendFvfMessage.YOU_INFIGHT);

                return;

            }

            #endregion

 

            int friendId = dp.Readint32();

            Client friend = null;   //кого приглашаем

            for (int i = 0; i < WorldServer.world_players.Count; i++)

            {

                Client cl = WorldServer.world_players[i];

                if (cl.ID == friendId)

                {

                    friend = cl;

                    break;

                }

            }

            #region valid - если не друга в онлайне

            if (friend == null || !friend.Online)

            {

                Packet pak = c.pak;

                pak.Clear();

                pak.Addint16(PacketCommand.SEND_LOCATION_GOFVF);

                pak.Addbyte((byte)SendFvfMessage.FRIEND_OFFLINE);

                pak.Send(c);

 

                Log.Write(EType.Packet, "{0} {1}, message: {2}", c.ID, "<-GoFvf", SendFvfMessage.FRIEND_OFFLINE);

Информация о работе Социальная интеллектуальная игра «ЗаБотань!»