private void player_MissionOver(AbstractGame game, int missionId, int turnCount)
 {
     if ((missionId == this.m_info.Para1 || this.m_info.Para1 == -1) && turnCount <= this.m_info.Para2 && base.Value > 0)
     {
         base.Value = 0;
     }
 }
예제 #2
0
 public StraightStick(Point center, AbstractGame gameState) : base(center, gameState)
 {
     _figures.Add(new Rectangle(center.Shift(-CellSize, CellSize * 2), CellSize, CellSize));
     _figures.Add(new Rectangle(center.Shift(-CellSize, CellSize), CellSize, CellSize));
     _figures.Add(new Rectangle(center.Shift(-CellSize, 0), CellSize, CellSize));
     _figures.Add(new Rectangle(center.Shift(-CellSize, -CellSize), CellSize, CellSize));
 }
예제 #3
0
 private void player_AfterKillingLiving(AbstractGame game, int type, int id, bool isLiving, int demage, bool isSpanArea)
 {
     if (!isLiving && type == 1)
     {
         this.m_player.AchievementInventory.UpdateUserAchievement(this.m_type, 1);
     }
 }
예제 #4
0
 public Player(Board b, bool w, EntityType ptype, ref AbstractGame.StepHandler onStep)
 {
     type = ptype;
     white = w;
     board = b;
     callback    = onStep;
 }
예제 #5
0
        public static AbstractFallingObject CreateInstance(AbstractGame gameState, FallingObjectType fallingObjectType)
        {
            var startFallingObjectRotationCenter = new Point
                                                       (gameState.Width / 2 - (gameState.Width / 2) % Tetris.CellSize, gameState.Height + Tetris.CellSize);

            switch (fallingObjectType)
            {
            case FallingObjectType.CrookedStick:
                return(new CrookedStick(startFallingObjectRotationCenter, gameState));

            case FallingObjectType.Cube:
                return(new Cube(startFallingObjectRotationCenter, gameState));

            case FallingObjectType.Hanger:
                return(new Hanger(startFallingObjectRotationCenter, gameState));

            case FallingObjectType.StraightStick:
                return(new StraightStick(startFallingObjectRotationCenter, gameState));

            case FallingObjectType.Thunder:
                return(new Thunder(startFallingObjectRotationCenter, gameState));

            default:
                throw new ArgumentOutOfRangeException(nameof(fallingObjectType), $"Unknown type {nameof(fallingObjectType)}.");
            }
        }
예제 #6
0
        public static void CheckCreatePlayerOwnerCallBack(AbstractGame game)
        {
            if (Catched)
            {
                return;
            }

            FieldInfo createPlayerOwnerInfo = LocalGameUtils.GetCreatePlayerOwnerFunc(game);

            if (createPlayerOwnerInfo == null)
            {
                return;
            }

            if (!(createPlayerOwnerInfo.GetValue(game) is Func <Player, HideoutPlayerOwner> createPlayerOwnerFunc))
            {
                return;
            }

            if (createPlayerOwnerFunc.Method.Name == "CreateOwner")
            {
                return;
            }

            _createOwnerFunc = createPlayerOwnerFunc;
            createPlayerOwnerInfo.SetValue(game, new Func <Player, HideoutPlayerOwner>(CreateOwner));
            Catched = true;
        }
 private void QuestDropItem(AbstractGame game, int copyId, int npcId, bool playResult)
 {
     if (this.m_player.GetItemCount(this.m_info.Para1) < this.m_info.Para2)
     {
         List <ItemInfo> list   = null;
         int             value  = 0;
         int             num    = 0;
         int             value2 = 0;
         int             value3 = 0;
         if (game is PVEGame)
         {
             DropInventory.PvEQuestsDrop(npcId, ref list);
         }
         if (game is PVPGame)
         {
             DropInventory.PvPQuestsDrop(game.RoomType, playResult, ref list);
         }
         if (list != null)
         {
             foreach (ItemInfo current in list)
             {
                 ItemInfo.FindSpecialItemInfo(current, ref value, ref num, ref value2, ref value3);
                 if (current != null)
                 {
                     this.m_player.TempBag.AddTemplate(current, current.Count);
                 }
             }
             this.m_player.AddGold(value);
             this.m_player.AddGiftToken(value2);
             this.m_player.AddMoney(num);
             this.m_player.AddMedal(value3);
             LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Drop, this.m_player.PlayerCharacter.ID, num, this.m_player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
         }
     }
 }
예제 #8
0
        public static AbstractFallingObject CreateRandom(AbstractGame gameState)
        {
            var rnd = _random.Next(TypesCount);

            switch (rnd)
            {
            case 0:
                return(CreateInstance(gameState, FallingObjectType.CrookedStick));

            case 1:
                return(CreateInstance(gameState, FallingObjectType.Cube));

            case 2:
                return(CreateInstance(gameState, FallingObjectType.Hanger));

            case 3:
                return(CreateInstance(gameState, FallingObjectType.StraightStick));

            case 4:
                return(CreateInstance(gameState, FallingObjectType.Thunder));

            default:
                return(null);
            }
        }
 private void player_GameOver(AbstractGame game, bool isWin, int gainXp)
 {
     if (base.Value < this.m_info.Para1)
     {
         base.Value++;
     }
 }
예제 #10
0
 void player_MissionOver(AbstractGame game, int missionId, int turnCount)
 {
     if (((missionId == m_info.Para1) || (m_info.Para1 == -1))&&(turnCount<=m_info.Para2) && (Value > 0))
     {
         Value=0;
     }
 }
예제 #11
0
 private void QuestDropItem(AbstractGame game, int copyId, int npcId, bool playResult)
 {
     if (m_player.GetItemCount(m_info.Para1) < m_info.Para2)
     {
         List <ItemInfo> infos = null;
         int             golds = 0, moneys = 0, gifttokens = 0;
         if (game is PVEGame)
         {
             DropInventory.PvEQuestsDrop(npcId, ref infos);
         }
         if (game is PVPGame)
         {
             DropInventory.PvPQuestsDrop(game.RoomType, playResult, ref infos);
         }
         if (infos != null)
         {
             foreach (ItemInfo info in infos)
             {
                 ItemInfo.FindSpecialItemInfo(info, ref golds, ref moneys, ref gifttokens);
                 if (info != null)
                 {
                     m_player.TempBag.AddTemplate(info, info.Count);
                 }
             }
             m_player.AddGold(golds);
             m_player.AddGiftToken(gifttokens);
             m_player.AddMoney(moneys);
             LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Drop, m_player.PlayerCharacter.ID, moneys, m_player.PlayerCharacter.Money, 0, 0, 0, "", "", "");//添加日志
         }
     }
 }
예제 #12
0
        void player_AfterKillingLiving(AbstractGame game, int type, int id, bool isLiving, int demage)
        {
            Console.WriteLine("是否活" + isLiving.ToString() + ":房间类型" + game.RoomType.ToString());
            if ((!isLiving) && (type == 1))
            {
                switch (game.RoomType)
                {
                case eRoomType.Match:
                    if (((m_info.Para1 == 0) || (m_info.Para1 == -1)) && (Value > 0))
                    {
                        Value = Value - 1;
                    }
                    break;

                case eRoomType.Freedom:
                    if (((m_info.Para1 == 1) || (m_info.Para1 == -1)) && (Value > 0))
                    {
                        Value = Value - 1;
                    }
                    break;

                default:
                    break;
                }
                if (Value < 0)
                {
                    Value = 0;
                }
            }
        }
예제 #13
0
 public void AddToGame(AbstractGame game, PlayerType playerType)
 {
     _game = game;
     _playerType = playerType;
     AbstractGame.StepHandler stepHandler = AlfaBetaStepHandler;
     game.RegisterAsPlayer(ref stepHandler, playerType);
 }
예제 #14
0
 public DemoState(AbstractGame game)
 {
     this.game = game;
     if (this.game.IsPause)
     {
     }
 }
 private void player_MissionOver(AbstractGame game, int missionId, bool isWin)
 {
     if (isWin && missionId == this.m_info.Para1 && base.Value > 0)
     {
         base.Value--;
     }
 }
예제 #16
0
 public GameCompleteState(AbstractGame game)
 {
     this.game = game;
     if (this.game.IsPause)
     {
     }
 }
예제 #17
0
        public GameViewModel(AbstractGame game)
        {
            _game                     = game;
            _petViewModel             = new PetViewModel(_game.Pet);
            _game.GameTimeChanged    += OnGameTimeChanged;
            _game.Pet.PetDied        += PetDiedHandler;
            Application.Current.Exit += (s, e) => _game.StopGame();
            _gameTime                 = game.GameTime;
            _gameDay                  = game.GameTime.Days;
            _gameHour                 = game.GameTime.Hours;
            _gameMinutes              = game.GameTime.Minutes;

            var currentType = GetType();

            _newGameCommand      = Command.CreateCommand("New", "NewGame", currentType, () => NewGameMessage(null, EventArgs.Empty));
            _startGameCommand    = Command.CreateAsyncCommand("Start", "StartGame", currentType, StartGameAsync, () => !_game.IsActive);
            _restartGameCommand  = Command.CreateAsyncCommand("Restart", "RestartGame", currentType, RestartGameAsync);
            _stopGameCommand     = Command.CreateAsyncCommand("Stop", "StopGame", currentType, StopGameAsync, () => !(_game.IsStopped || _game.IsFinished));
            _pauseGameCommand    = Command.CreateAsyncCommand("Pause", "PauseGame", currentType, PauseGameAsync, () => _game.IsActive);
            _saveGameCommand     = Command.CreateAsyncCommand("Save", "SaveGame", currentType, SaveGameAsync);
            _feedPetCommand      = Command.CreateAsyncCommand("Feed pet", "FeedPet", currentType, FeedPetAsync, () => _game.IsActive);
            _playWithPetCommand  = Command.CreateAsyncCommand("Play with pet", "PlayWithPet", currentType, PlayWithPetAsync, () => _game.IsActive);
            _cleanAviaryCommand  = Command.CreateAsyncCommand("Clean aviary", "CleanAviary", currentType, CleanAviaryAsync, () => _game.IsActive);
            _euthanizePetCommand = Command.CreateAsyncCommand("Euthanize pet", "EuthanizePet", currentType, EuthanizePetAsync, () => _game.IsActive);
            _exitCommand         = Command.CreateCommand("Exit", "ExitCommand", currentType, Exit);
            _closeCommand        = Command.CreateCommand("Close", "CloseCommand", currentType, _game.StopGame);
        }
예제 #18
0
 public Thunder(Point center, AbstractGame gameState) : base(center, gameState)
 {
     _figures.Add(new Rectangle(center.Shift(-CellSize, CellSize * 2), CellSize, CellSize));
     _figures.Add(new Rectangle(center.Shift(-CellSize, CellSize), CellSize, CellSize));
     _figures.Add(new Rectangle(center.Shift(0, CellSize), CellSize, CellSize));
     _figures.Add(new Rectangle(center.Shift(0, 0), CellSize, CellSize));
 }
예제 #19
0
 void player_MissionOver(AbstractGame game, int missionId, bool isWin)
 {
     if (((missionId == m_info.Para1) || (m_info.Para1 == -1)) && (Value > 0))
     {
         Value--;
     }
 }
예제 #20
0
 void player_MissionOver(AbstractGame game, int missionId, bool isWin)
 {
     if ((isWin == true) && (missionId == m_info.Para1) && (Value > 0))
     {
         Value--;
     }
 }
예제 #21
0
        void player_GameOver(AbstractGame game, bool isWin, int gainXp)
        {
            if (isWin == true)
            {
                switch (game.RoomType)
                {
                case eRoomType.Match:
                    if (((m_info.Para1 == 0) || (m_info.Para1 == -1)) && (Value > 0))
                    {
                        Value--;
                    }
                    break;

                case eRoomType.Freedom:
                    if (((m_info.Para1 == 1) || (m_info.Para1 == -1)) && (Value > 0))
                    {
                        Value--;
                    }
                    break;

                default:
                    break;
                }
            }
        }
예제 #22
0
 public void StartGame(AbstractGame game)
 {
     if (this.m_game != null)
     {
         List <GamePlayer> list = this.GetPlayers();
         foreach (GamePlayer player in list)
         {
             this.m_game.RemovePlayer(player, false);
         }
         this.m_game_GameStopped(this.m_game);
     }
     this.OldGameType = game.GameType;
     this.m_game      = game;
     if (this.m_host != null && this.RoomType == eRoomType.Match)
     {
         if (this.IsAllSameGuild())
         {
             this.GameType = this.OldGameType;
             GSPacketIn pkg = this.m_host.Out.SendRoomType(this.m_host, this);
             this.SendToAll(pkg);
         }
     }
     this.IsPlaying           = true;
     this.m_game.GameStopped += new GameEventHandle(this.m_game_GameStopped);
     if (this.PickUpNPC)
     {
         this.m_game.RoomRest += new GameEventHandle(this.m_game_RoomRest);
     }
 }
예제 #23
0
 private void player_GameOver(AbstractGame game, bool isWin, int gainXp, bool isSpanArea, bool isCouple)
 {
     if (game.GameType == eGameType.Free && isWin)
     {
         this.m_player.AchievementInventory.UpdateUserAchievement(this.m_type, 1);
     }
 }
예제 #24
0
 private void player_AfterKillingLiving(AbstractGame game, int type, int id, bool isLiving, int demage, bool isSpanArea)
 {
     if (type == 2 && id == this.m_info.Para1 && base.Value > 0 && !isLiving)
     {
         base.Value--;
     }
 }
예제 #25
0
        public bool UsePropItem(AbstractGame game, int bag, int place, int templateId, bool isLiving)
        {
            m_client.SendPlayerUsePropInGame(PlayerCharacter.ID, bag, place, templateId, isLiving);
            //等待服务器处理
            game.Pause(500);

            return(false);
        }
예제 #26
0
        public FalledObject(Point center, AbstractGame gameState) : base(center, gameState)
        {
            _figures.Add(new Rectangle(
                             new Point(center.X - center.X % CellSize, center.Y - center.Y % CellSize), CellSize, CellSize));

            _fallingTime = 0;
            _priority    = 1;
        }
예제 #27
0
 private void Host_GameOver(AbstractGame game, bool isWin, int gainXp, bool isSpanArea, bool isCouple)
 {
     this.m_room.Host.GameOver -= new GamePlayer.PlayerGameOverEventHandle(this.Host_GameOver);
     if (isWin)
     {
         this.m_room.Host.Out.SendPickUpNPC();
     }
 }
        private void player_GameOver(AbstractGame game, bool isWin, int gainXp, bool isSpanArea, bool isCouple)
        {
            switch (game.GameType)
            {
            case eGameType.Free:
                if ((this.m_info.Para1 == 0 || this.m_info.Para1 == -1) && base.Value > 0)
                {
                    base.Value--;
                }
                break;

            case eGameType.Guild:
                if ((this.m_info.Para1 == 1 || this.m_info.Para1 == -1) && base.Value > 0)
                {
                    base.Value--;
                }
                break;

            case eGameType.Training:
                if ((this.m_info.Para1 == 2 || this.m_info.Para1 == -1) && base.Value > 0)
                {
                    base.Value--;
                }
                break;

            case eGameType.ALL:
                if ((this.m_info.Para1 == 4 || this.m_info.Para1 == -1) && base.Value > 0)
                {
                    base.Value--;
                }
                break;

            case eGameType.Exploration:
                if ((this.m_info.Para1 == 5 || this.m_info.Para1 == -1) && base.Value > 0)
                {
                    base.Value--;
                }
                break;

            case eGameType.Boss:
                if ((this.m_info.Para1 == 6 || this.m_info.Para1 == -1) && base.Value > 0)
                {
                    base.Value--;
                }
                break;

            case eGameType.Treasure:
                if ((this.m_info.Para1 == 7 || this.m_info.Para1 == -1) && base.Value > 0)
                {
                    base.Value--;
                }
                break;
            }
            if (base.Value < 0)
            {
                base.Value = 0;
            }
        }
예제 #29
0
        public Bullet(Point leftTop, AbstractGame gameState, Direction direction) :
            base(new Point(leftTop.X + Width / 2, leftTop.Y - Height / 2), gameState)
        {
            Contour = new Rectangle(leftTop, Width - 1, Height - 1);

            Direction = direction;

            _figures.Add(new Rectangle(leftTop, Width - 1, Height - 1));
        }
예제 #30
0
        public void SendPlayerOnKillingLiving(int playerId, AbstractGame game, int type, int id, bool isLiving, int demage)
        {
            GSPacketIn gSPacketIn = new GSPacketIn(40, playerId);

            gSPacketIn.WriteInt(type);
            gSPacketIn.WriteBoolean(isLiving);
            gSPacketIn.WriteInt(demage);
            this.SendTCP(gSPacketIn);
        }
예제 #31
0
        public void SendPlayerOnMissionOver(int playerId, AbstractGame game, bool isWin, int MissionID, int turnNum)
        {
            GSPacketIn pkg = new GSPacketIn(41, playerId);

            pkg.WriteBoolean(isWin);
            pkg.WriteInt(MissionID);
            pkg.WriteInt(turnNum);
            this.SendTCP(pkg);
        }
예제 #32
0
 private void player_MissionOver(AbstractGame game, int missionId, bool isWin)
 {
     if (game.GameType == eGameType.FightLab && isWin)
     {
         if (missionId == 103 || missionId == 113 || missionId == 123)
         {
             this.m_player.AchievementInventory.UpdateUserAchievement(this.m_type, 1);
         }
     }
 }
예제 #33
0
 public UserControl getGameGUI(AbstractGame game)
 {
     var gamegui = GameDict[game.GetType().Name].GameGuiFunc();
     var gui = gamegui.GetGameGUI();
     gamegui.AddToGame(game, PlayerType.PlayerOne);
     return gui;
 }
예제 #34
0
        public AbstractGame StartNetworkGame(string gameType, PlayerType playerType)
        {
            currentGame = GameDict[gameType].GameFunc();
            var gamegui = GameDict[currentGame.GetType().Name].GameGuiFunc();
            currentGameGUI = gamegui.GetGameGUI();
            gamegui.AddToGame(currentGame, playerType);

            currentPlayerType = playerType;
            otherPlayerType = (playerType == PlayerType.PlayerOne) ? PlayerType.PlayerTwo : PlayerType.PlayerOne;

            AbstractGame.StepHandler stepHandler = StepHandler;
            currentGame.RegisterAsPlayer(ref stepHandler, otherPlayerType);

            return currentGame;
        }
 void game_GameStarted(AbstractGame game)
 {
     game.GameStarted -= new GameEventHandle(game_GameStarted);
     m_isFinished = true;
 }
예제 #36
0
        //játékosok regisztrációja
        public override void RegisterAsPlayer(ref AbstractGame.StepHandler onStep, PlayerType playerType)
        {
            int index = 0;
                // Index in the players list
                if (activeBoard.Player[0] != null)
                {
                    index = 1;
                }
                   activeBoard.Player[index] = new Player();
                    activeBoard.Player[index].PlayerType = playerType;

                    activeBoard.Player[index].Callback = onStep;
                 if (activeBoard.Player[0] != null && activeBoard.Player[1] != null )
                {
                    StartGame();
                }
        }