Esempio n. 1
0
        public void Before_Each_Test()
        {
            console = MockRepository.GenerateMock<IConsoleFacade>();
            repository = MockRepository.GenerateMock<IRepository<GameObject>>();
            player = MockRepository.GenerateMock<IPlayer>();

            dbPlayer = new GameObject() { GameObjectId = 3, Location = dbHallway, Location_Id = 8, Description = "Just some dude." };
            player.Stub(qq => qq.Id).Return(3);
            dbHallway = new GameObject() { Name = "Hallway", Description = " It's a hallway", GameObjectId = 8 };
            dbBall = new GameObject() { Name = "Ball", Description = "A shiny rubber ball", Location = dbPlayer, Location_Id = 3 };
            dbRing = new GameObject() { Name = "Ring", Description = "A simple gold ring", Location = dbHallway, Location_Id = 8 };
            dbExit = new GameObject() {Name = "Exit", Description ="", Location= dbHallway, Location_Id = 8, GameObjectId = 16, Type = "Exit", Destination = 8 };

            dbPlayer.Inventory.Add(dbBall);
            dbHallway.Inventory.Add(dbPlayer);
            dbHallway.Inventory.Add(dbRing);
            dbHallway.Inventory.Add(dbExit);
            dbList = new List<GameObject>() { dbPlayer, dbBall, dbRing, dbExit, dbHallway };
            repository.Stub(qq => qq.AsQueryable()).Return(dbList.AsQueryable());

            exit = new ExitAlias() { AliasId = 2, ExitId = 16, Alais = "North" };
            exit2 = new ExitAlias() { AliasId = 2, ExitId = 16, Alais = "Hall" };
            dbExit.ExitAliases.Add(exit);
            dbExit.ExitAliases.Add(exit2);
            aliasList = new List<ExitAlias> { exit, exit2 };
        }
 public Move GetNextFigureMove(IPlayer player,IBoard board)
 {
     Console.Write("{0} is next ", player.Name);
     var command = Console.ReadLine();
     Move move = player.Move(command,board);
     return move;
 }
Esempio n. 3
0
        public void ActionRound(IPlayer attacker, IPlayer defender)
        {
            Random dodge = new Random();

            if (attacker.SelectAction == ActionSelection.Attack)
            {
                if (defender.SelectAction == ActionSelection.Defend)
                {
                    if (dodge.Next(0, 2) == 0)
                    {
                        Console.Write(String.Format(
                                      ApplicationSettings.ActionDodgePrompt));
                    }
                    else
                    {
                        defender.Health -= (attacker.WeaponValue - defender.ArmorValue);
                    }
                }
                else
                {
                    defender.Health -= (attacker.WeaponValue - defender.ArmorValue);
                }
            }
            else
            {
                attacker.SelectAction = ActionSelection.Defend;
            }
        }
Esempio n. 4
0
 public void Dispose()
 {
     if(objBGPlayer!=null)
     {
         objBGPlayer.OnShotBoxStatus -= objPlayer1_OnShotBoxStatus;
         objBGPlayer.OnShotBoxControllerStatus -= objPlayer1_OnShotBoxStatus;
         objBGPlayer.Dispose();
         objBGPlayer = null;
     }
     if (objScorePlayer != null)
     {
         objScorePlayer.OnShotBoxStatus -= objPlayer1_OnShotBoxStatus;
         objScorePlayer.OnShotBoxControllerStatus -= objPlayer1_OnShotBoxStatus;
         objScorePlayer.Dispose();
         objScorePlayer = null;
     }
     if(AppLink!=null)
     {
         AppLink.Dispose();
         AppLink = null;
     }
     if (FileHandler != null)
     {
         FileHandler.Dispose();
         FileHandler = null;
     }
 }
Esempio n. 5
0
 public ChessEngine( IBoard board, IPlayer white, IPlayer black, ConfigChess config )
 {
     this.board = board;
     this.white = white;
     this.black = black;
     this.config = config;
 }
Esempio n. 6
0
File: Shot.cs Progetto: jmaxxz/Ares
 /// <summary>
 /// Instantiates a new object representing a shot fired by <see cref="shooter"/>
 /// at <see cref="target"/>.
 /// </summary>
 /// <param name="shooter">The player who fired the shot</param>
 /// <param name="target">The player who is being shot at</param>
 /// <param name="id">A unique id identifying this shot</param>
 /// <param name="image">An optional jpeg snap shot of the <see cref="shooter"/>'s video feed at the time the shot was fired</param>
 public Shot(IPlayer shooter, IPlayer target, Guid id, byte[] image)
 {
     Shooter = shooter;
     Target = target;
     Id = id;
     Image = image;
 }
        public ISpecialEventResult Execute(IPlayer player)
        {
            var result = SpecialEventResult.Create();

            var firstDice = Dice.Throw();
            var secondDice = Dice.Throw();

            result.Dices.Add(firstDice);
            result.Dices.Add(secondDice);

            result.Success = IsMagicLessThanTwoDices(firstDice, secondDice, player);

            if (result.Success)
            {
                var position = player.Game.Board.GoFromInnerToMiddle();
                result.Player = player.SetPosition(position);
            }
            else
            {
                CommandHelper.RemoveOnePointOfLife(player);
            }

            result.Message =
                "Aby przeby� Trz�sawiska musisz u�y� Magii. Rzu� dwoma kostkami: wynik mniejszy lub r�wny twojej Magii - przeprawi�e� si� na drug� stron�." +
                " Wi�kszy wynik oznacza pora�k� (tracisz 1 �ycie). Nie mo�esz kontynuowa� podr�y dop�ki nie przejdziesz przez Trz�sawiska.";

            return result;
        }
Esempio n. 8
0
 public Seat(int seatNumber, string playerName, double chips, IPlayer brain)
 {
     this.name = playerName;
     this.seat = seatNumber;
     this.chips = chips;
     this.brain = brain;
 }
Esempio n. 9
0
        public double GetDesirablity(IPlayer attacker, IHexa hexa)
        {
            if (map.GetPlayerOthers().Count == 0)
                return 0.0f;

            if (hexa.GetCapturedIPlayer() == attacker)
                return 0.0f;

            int enemySum = 0;
            int attackerSum = hexa.GetNormalProductivity(attacker);

            foreach (IPlayer player in map.GetPlayerOthers())
            {
                if (player == attacker)
                {
                    enemySum += hexa.GetNormalProductivity(map.GetPlayerMe());
                }
                else
                    enemySum += hexa.GetNormalProductivity(player);
            }

            if (hexa.GetCaptured() && hexa.GetCapturedIPlayer() != attacker)
            {
                return (enemySum + attackerSum) / 144.0f;
            }

            return (enemySum) / 144.0f;
        }
 /// <summary>
 /// Indicates that the current player gives up on the current round. He cannot participate in the round any more and losses the raised or called chips.
 /// </summary>
 public void Fold(IPlayer currentPlayer, ref bool isRaisingActivated)
 {
     isRaisingActivated = false;
     currentPlayer.Status.Text = "Fold";
     currentPlayer.OutOfChips = true;
     currentPlayer.CanPlay = false;
 }
Esempio n. 11
0
            public ISpecialEventResult Execute(IPlayer player)
            {
                var result = SpecialEventResult.Create();
                result.Success = true;

                var dice = Dice.Throw();
                result.Dices.Add(dice);

                switch (dice)
                {
                    case 1:
                    case 2:
                        CommandHelper.RemoveOnePointOfMight(player);
                        break;
                    case 3:
                    case 4:
                        CommandHelper.AddOnePointOfMight(player);
                        break;
                    case 5:
                        CommandHelper.AddOnePointOfMagic(player);
                        break;
                }

                result.Message =
                    "Rzuæ kostk¹ 1,2 - tracisz 1 punkt Miecza; 3,4 - zyskujesz 1 punkt Miecza; 5 - zyskujesz 1 punkt Magii; 6 - zosta³eœ zignorowany.";

                return result;
            }
Esempio n. 12
0
        public DefaultPiece(IPlayer player)
        {
            if (player == null)
                throw new ArgumentNullException(nameof(player));

            this.Player = player.Name;
        }
        public ISpecialEventResult Execute(IPlayer player)
        {
            var result = SpecialEventResult.Create();
            var dice = Dice.Throw();
            result.Success = true;
            result.Dices.Add(dice);

            switch (dice)
            {
                case 1:
                    var straznik = StandardCreature.New("Stra¿nik Krêgu", 5);

                    var fightResult = straznik.Fight(player);
                    result.Success = fightResult.Success;

                    result.Dices.Add(fightResult.PlayerDice);
                    result.Dices.Add(fightResult.CreatureDice);

                    break;
                case 2:
                case 3:
                    CommandHelper.WaitOneTurn(player);
                    break;
                case 6:
                    CommandHelper.AddOnePointOfMagic(player);
                    break;
            }

            result.Message =
                "Musisz rzuciæ kostk¹: 1 - zosta³eœ zaatakowany przez Stra¿nika Krêgu (Miecz 5);" +
                " 2, 3 - tracisz 1 ture; 4, 5 - nic siê nie dzieje; 6 - zyskujesz 1 punkt Magii.";

            return result;
        }
 public static void Load()
 {
     prevVisitedTiles = new List<KeyValuePair<int, int>>();
     tileList = TileLoader.Load("Tiles");
     player = new PlayerCharacter();
     tile = tileList[new KeyValuePair<int,int>(1,1)];
 }
Esempio n. 15
0
        /// <summary>
        /// Puts current player in score board. Determines position comparing player's scores with other entries in score board.
        /// </summary>
        /// <param name="player">Current players that plays the game.</param>
        public void PlacePlayerInScoreBoard(IPlayer player)
        {
            this.LoadTopPlayers(Globals.BestScoresPath);
            int emptyPosition = this.GetFirstFreePosition();

            if (this.scoreBoardTable.TopPlayers[emptyPosition] == null || player.Score >= this.scoreBoardTable.TopPlayers[emptyPosition].Score)
            {
                this.scoreBoardTable.TopPlayers[emptyPosition] = player;
                        
                for (int i = 0; i < emptyPosition; i++)
                {
                    IPlayer firstPlayer = this.scoreBoardTable.TopPlayers[i];
                    IPlayer secondPlayer = this.scoreBoardTable.TopPlayers[i + 1];

                    if (firstPlayer.Score < secondPlayer.Score)
                    {
                        this.scoreBoardTable.TopPlayers[i] = secondPlayer;
                        this.scoreBoardTable.TopPlayers[i + 1] = firstPlayer;
                    }
                }
            }

            this.export = new FileExporter(this.scoreBoardTable);
            this.export.Save(Globals.BestScoresPath);
        }
Esempio n. 16
0
 private Game(IPlayer player, IRenderer renderer, IScoreBoardObserver scoreboard, LabyrinthProcesor processor)
 {
     this.renderer = renderer;
     this.player = player;
     this.scoreBoardHandler = scoreboard;
     this.processor = processor;
 }
Esempio n. 17
0
 public Game(IPlayer player, DelegateCreateRaceLineup createRaceLineup, DelegateAggregateSnails aggregateSnails, IBookie bookie)
 {
     this.player           = player;
     this.createRaceLineup = createRaceLineup;
     this.aggregateSnails  = aggregateSnails;
     this.bookie           = bookie;
 }
Esempio n. 18
0
 // BigBang sample implementation
 private Move MakeBigBangMove(IPlayer you, IPlayer opponent, GameRules rules)
 {
     if (you.NumberOfDecisions < 5)
         return Moves.Dynamite;
     else
         return Moves.GetRandomMove();
 }
Esempio n. 19
0
 public void Attack(IPlayer player)
 {
     int damage = power - player.Armor;
     if (damage > 0)
         player.Health -= damage;
     Writer.WriteLine("Enemy damages player for " + damage);
 }
        public TwoPlayersTexasHoldemGame(IPlayer firstPlayer, IPlayer secondPlayer, int initialMoney = 1000)
        {
            if (firstPlayer == null)
            {
                throw new ArgumentNullException(nameof(firstPlayer));
            }

            if (secondPlayer == null)
            {
                throw new ArgumentNullException(nameof(secondPlayer));
            }

            if (initialMoney <= 0 || initialMoney > 200000)
            {
                throw new ArgumentOutOfRangeException(nameof(initialMoney), "Initial money should be greater than 0 and less than 200000");
            }

            // Ensure the players have unique names
            if (firstPlayer.Name == secondPlayer.Name)
            {
                throw new ArgumentException($"Both players have the same name: \"{firstPlayer.Name}\"");
            }

            this.firstPlayer = new InternalPlayer(firstPlayer);
            this.secondPlayer = new InternalPlayer(secondPlayer);
            this.allPlayers = new List<InternalPlayer> { this.firstPlayer, this.secondPlayer };
            this.initialMoney = initialMoney;
            this.HandsPlayed = 0;
        }
Esempio n. 21
0
        /// <summary>
        /// Create a game
        /// You pass in two IPlayers
        /// At least one player must be a ComputerPlayer
        /// </summary>
        /// <param name="player1"></param>
        /// <param name="player2"></param>
        public Game(IPlayer player1, IPlayer player2)
        {
            if ((player1 == null) || (player2 == null))
            {
                throw new EUndefinedPlayer();
            }

            if ((player1 is HumanPlayer) && (player2 is HumanPlayer))
            {
                throw new ETwoHumanPlayers();
            }

            Player1 = player1;
            Player2 = player2;

            if ( string.IsNullOrEmpty(Player1.PlayerName))
            {
                Player1.PlayerName = "Player1";
            }

            if (string.IsNullOrEmpty(Player2.PlayerName))
            {
                Player1.PlayerName = "Player2";
            }
        }
 // Use this for initialization
 void Start()
 {
     lightning = GetComponent<Lightning>();
     lightning.enabled = false;
     player = GetComponent<IPlayer>();
     lightning.maxLength = 200f;
 }
Esempio n. 23
0
 private void MovePlayer(IPlayer player, int rollValue)
 {
     if (player.Location + rollValue > board.Locations.Count())
         player.Location = (player.Location + rollValue) % board.Locations.Count();
     else
         player.Location += rollValue;
 }
 public MastAdapter(IPlayer player)
 {
     if (player == null) throw new NullReferenceException("Player cannot be null.");
     if (!(player is FrameworkElement)) throw new NullReferenceException("Player must be a FrameworkElement.");
     this.player = player;
     HookPlayerEvents();
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            Console.Title = "TicTacToe";
            var players = new IPlayer[] { new HumanConsolePlayer(), new AlphaBetaMinimaxPlayer() };
            int current = 0;
            var alternante = 0;

            Grid g = Grid.Empty;
            while (true)
            {
                g = players[current].MakeMove(g);
                current = (current + 1) % 2;

                if (g.IsFinished)
                {
                    ConsoleGridRenderer.Render(g);
                    if (!g.IsDraw)
                        Console.WriteLine("{0} win!", g.CurrentIsO ? "X" : "O");
                    else
                        Console.WriteLine("Draw!");
                    current = (++alternante % 2);
                    g = Grid.Empty;
                }
                Console.WriteLine("\n");
            }
        }
 private static string GetDescription(IPlayer player, uint numberOfCards)
 {
     if (numberOfCards == 1)
         return string.Format("{0} draws 1 card", player.Name);
     else
         return string.Format("{0} draws {1} cards", player.Name, numberOfCards);
 }
Esempio n. 27
0
 public PlayerPositionPacket(IPlayer player)
 {
     PlayerId = player.Id;
     X = player.Position.X;
     Y = player.Position.Y;
     Z = 0f;
 }
Esempio n. 28
0
 public RaiseAction(IPlayer player, int raiseAmount, List<IPlayer> players, int playerIndex)
     : base(player, Actions.Raise)
 {
     this.RaiseAmount = raiseAmount;
     this.Players = players;
     this.PlayerIndex = playerIndex;
 }
        /// <summary>
        /// Generete game field
        /// </summary>
        /// <param name="grid">Field member</param>
        /// <param name="player"Player member></param>
        /// <returns>Genereted game filed</returns>
        public IGrid GenerateGrid(IPlayer player, IGrid grid)
        {
            DefaultRandomGenerator random = DefaultRandomGenerator.Instance();
            int percentageOfBlockedCells = random.Next(GlobalConstants.MinimumPercentageOfBlockedCells, GlobalConstants.MaximumPercentageOfBlockedCells);

            for (int row = 0; row < grid.TotalRows; row++)
            {
                for (int col = 0; col < grid.TotalCols; col++)
                {
                    int num = random.Next(0, 100);
                    if (num < percentageOfBlockedCells)
                    {
                        grid.SetCell(row, col, GlobalConstants.BlockedCellSymbol);
                    }
                    else
                    {
                        grid.SetCell(row, col, GlobalConstants.FreeCellSymbol);
                    }
                }
            }

            grid.SetCell(grid.TotalRows / 2, grid.TotalCols / 2, GlobalConstants.PlayerSignSymbol);

            this.MakeAtLeastOneExitReachable(grid, player);
            return grid;
        }
Esempio n. 30
0
        public override void Update(GameTime gameTime, IPlayer currentPlayer)
        {
            if (this.SpecialtyFired)
            {
                // TODO moje da se izvede v private method void Move() i Atack() primerno..
                // nqkak da se porazkachi Update() (ako ima vreme)
                if (currentPlayer is FirstPlayer)
                {
                    Collide = SpecialtyCollision.Collide(SecondPlayer.Instance.Ship, this);
                    if (Collide)
                    {
                        currentPlayer.Ship.SpecialtyAttack(SecondPlayer.Instance.Ship);
                    }

                    this.AddToPosition(Direction.Positive, CoordsDirections.Abscissa, HURRICANE_SPEED);
                }
                else
                {
                    Collide = SpecialtyCollision.Collide(FirstPlayer.Instance.Ship, this);
                    if (Collide)
                    {
                        currentPlayer.Ship.SpecialtyAttack(FirstPlayer.Instance.Ship);
                    }

                    this.AddToPosition(Direction.Negative, CoordsDirections.Abscissa, HURRICANE_SPEED);
                }
            }
        }
Esempio n. 31
0
        public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        {
            if (byEntity.Attributes.GetInt("aimingCancel") == 1)
            {
                return;
            }
            byEntity.Attributes.SetInt("aiming", 0);
            byEntity.AnimManager.StopAnimation("bowaim");

            if (byEntity.World is IClientWorldAccessor)
            {
                slot.Itemstack.TempAttributes.RemoveAttribute("renderVariant");
            }

            slot.Itemstack.Attributes.SetInt("renderVariant", 0);

            if (secondsUsed < 0.35f)
            {
                return;
            }

            ItemSlot arrowSlot = GetNextBall(byEntity);

            if (arrowSlot == null)
            {
                return;
            }

            string arrowMaterial = arrowSlot.Itemstack.Collectible.FirstCodePart(1);
            float  damage        = 0;

            // Bow damage
            if (slot.Itemstack.Collectible.Attributes != null)
            {
                damage += slot.Itemstack.Collectible.Attributes["damage"].AsFloat(0);
            }

            // Arrow damage
            if (arrowSlot.Itemstack.Collectible.Attributes != null)
            {
                damage += arrowSlot.Itemstack.Collectible.Attributes["damage"].AsFloat(0);
            }

            ItemStack stack = arrowSlot.TakeOut(1);

            arrowSlot.MarkDirty();

            IPlayer byPlayer = null;

            if (byEntity is EntityPlayer)
            {
                byPlayer = byEntity.World.PlayerByUid(((EntityPlayer)byEntity).PlayerUID);
            }
            byEntity.World.PlaySoundAt(new AssetLocation("sounds/bow-release"), byEntity, byPlayer, false, 8);

            // float breakChance = 0.5f;
            // if (stack.ItemAttributes != null) breakChance = stack.ItemAttributes["breakChanceOnImpact"].AsFloat(0.5f);

            EntityProperties type   = byEntity.World.GetEntityType(new AssetLocation("ball-" + stack.Collectible.Variant["material"]));
            Entity           entity = byEntity.World.ClassRegistry.CreateEntity(type);

            ((EntityThrownStone)entity).FiredBy         = byEntity;
            ((EntityThrownStone)entity).Damage          = damage;
            ((EntityThrownStone)entity).ProjectileStack = stack;
            //((EntityThrownStone)entity).DropOnImpactChance = 1 - breakChance;


            float  acc      = Math.Max(0.001f, (1 - byEntity.Attributes.GetFloat("aimingAccuracy", 0)));
            double rndpitch = byEntity.WatchedAttributes.GetDouble("aimingRandPitch", 1) * acc * 0.65;
            double rndyaw   = byEntity.WatchedAttributes.GetDouble("aimingRandYaw", 1) * acc * 0.65;

            Vec3d pos      = byEntity.ServerPos.XYZ.Add(0, byEntity.LocalEyePos.Y, 0);
            Vec3d aheadPos = pos.AheadCopy(1, byEntity.SidedPos.Pitch + rndpitch, byEntity.SidedPos.Yaw + rndyaw);
            Vec3d velocity = (aheadPos - pos) * byEntity.Stats.GetBlended("bowDrawingStrength");


            entity.ServerPos.SetPos(byEntity.SidedPos.BehindCopy(0.21).XYZ.Add(0, byEntity.LocalEyePos.Y, 0));
            entity.ServerPos.Motion.Set(velocity);



            entity.Pos.SetFrom(entity.ServerPos);
            entity.World = byEntity.World;
            ((EntityThrownStone)entity).SetRotation();

            byEntity.World.SpawnEntity(entity);

            slot.Itemstack.Collectible.DamageItem(byEntity.World, byEntity, slot);

            byEntity.AnimManager.StartAnimation("bowhit");
        }
Esempio n. 32
0
 public SlapPlay(IPlayer player) : base(0)
 {
     Player = player;
 }
Esempio n. 33
0
 /// <summary>
 /// Handles a chat message
 /// </summary>
 /// <param name="player"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public bool HandleChatMessage(IPlayer player, string message) => commandHandler.HandleChatMessage(player, message);
Esempio n. 34
0
        private bool ChatCommandCallback(IPlayer caller, string command, string[] args)
        {
            CommandCallback callback;

            return(registeredCommands.TryGetValue(command, out callback) && callback(caller, command, args));
        }
 public void Join(IPlayer player)
 {
     this.players.Add(player);
 }
 public bool IsAlreadyJoined(IPlayer player)
 {
     return(IsAlreadyJoined(player.ConnectionId));
 }
Esempio n. 37
0
 public bool PlayerHasHand(IPlayer player)
 {
     return(true);
 }
Esempio n. 38
0
 public void AddPlayer(IPlayer player)
 {
     Players.Add(player);
     player.PlayerHasBeenUpdated += Player_PlayerHasBeenUpdated;
     ((Player)player).Upgrades    = UpgradesBundle;
 }
Esempio n. 39
0
 public override void GetDeployed(IPlayer playerReceiving)
 {
     playerReceiving.ReplaceEquippable(this);
 }
Esempio n. 40
0
 private TurnResult(IPlayer player, IGameSquare gameSquare = default)
 {
     Player     = player;
     GameSquare = gameSquare;
 }
 public void SetPlayer(IPlayer player)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 42
0
 public override void TakeEffect(IPlayer playerPlaying, IPlayer playerReceiving, List <ICard> cardsExtra)
 {
 }
Esempio n. 43
0
 public int GetHashCode(IPlayer obj)
 {
     return(((INativePointer)obj).Pointer.GetHashCode());
 }
Esempio n. 44
0
 public AIPlayerMoveController(AIPlayer aiPlayer)
 {
     webPlayer = new WebPlayer("Player 1", 'X');
     aiPlyaer  = aiPlayer;
 }
Esempio n. 45
0
 public BluntForceTrauma(IPlayer player, string args = null)
 {
     WeaponType = WeaponType.Hammer;
     SpellType  = SpellType.Passive;
     // Attack 4 times with Hammer 10% Crit BaseDamage 3s
 }
        internal void OnUseOver(IPlayer byPlayer, Vec3i voxelPos, BlockFacing facing, bool mouseMode)
        {
            if (voxelPos == null)
            {
                // DidBeginUse = Math.Max(0, DidBeginUse - 1);
                return;
            }

            // Send a custom network packet for server side, because
            // serverside blockselection index is inaccurate
            if (api.Side == EnumAppSide.Client)
            {
                SendUseOverPacket(byPlayer, voxelPos, facing, mouseMode);
            }

            ItemSlot slot = byPlayer.InventoryManager.ActiveHotbarSlot;

            if (slot.Itemstack == null)
            {
                //      DidBeginUse = Math.Max(0, DidBeginUse - 1);
                return;
            }

            int toolMode = slot.Itemstack.Collectible.GetToolMode(slot, byPlayer, new BlockSelection()
            {
                Position = pos
            });

            float       yaw         = GameMath.Mod(byPlayer.Entity.Pos.Yaw, 2 * GameMath.PI);
            BlockFacing towardsFace = BlockFacing.HorizontalFromAngle(yaw);


            //if (DidBeginUse > 0)
            {
                bool didRemove = mouseMode && OnRemove(voxelPos, facing, toolMode, byPlayer);

                if (mouseMode && (didRemove || Voxels[voxelPos.X, voxelPos.Z]))
                {
                    api.World.PlaySoundAt(new AssetLocation("sounds/player/knap" + (api.World.Rand.Next(2) > 0 ? 1 : 2)), lastRemovedLocalPos.X, lastRemovedLocalPos.Y, lastRemovedLocalPos.Z, byPlayer, true, 12, 1);
                }

                if (didRemove)
                {
                    //byPlayer.Entity.GetBehavior<EntityBehaviorHunger>()?.ConsumeSaturation(1f);
                }

                if (didRemove && api.Side == EnumAppSide.Client)
                {
                    Random rnd = api.World.Rand;
                    for (int i = 0; i < 3; i++)
                    {
                        api.World.SpawnParticles(new SimpleParticleProperties()
                        {
                            minQuantity = 1,
                            addQuantity = 2,
                            color       = BaseMaterial.Collectible.GetRandomColor(api as ICoreClientAPI, BaseMaterial),
                            minPos      = new Vec3d(lastRemovedLocalPos.X, lastRemovedLocalPos.Y + 1 / 16f + 0.01f, lastRemovedLocalPos.Z),
                            addPos      = new Vec3d(1 / 16f, 0.01f, 1 / 16f),
                            minVelocity = new Vec3f(0, 1, 0),
                            addVelocity = new Vec3f(
                                4 * ((float)rnd.NextDouble() - 0.5f),
                                1 * ((float)rnd.NextDouble() - 0.5f),
                                4 * ((float)rnd.NextDouble() - 0.5f)
                                ),
                            lifeLength    = 0.2f,
                            gravityEffect = 1f,
                            minSize       = 0.1f,
                            maxSize       = 0.4f,
                            model         = EnumParticleModel.Cube,
                            SizeEvolve    = new EvolvingNatFloat(EnumTransformFunction.LINEAR, -0.15f)
                        });
                    }
                }



                RegenMeshAndSelectionBoxes();
                api.World.BlockAccessor.MarkBlockDirty(pos);
                api.World.BlockAccessor.MarkBlockEntityDirty(pos);

                if (!HasAnyVoxel())
                {
                    api.World.BlockAccessor.SetBlock(0, pos);
                    return;
                }
            }

            // DidBeginUse = Math.Max(0, DidBeginUse - 1);
            CheckIfFinished(byPlayer);
            MarkDirty();
        }
 public bool Contains(IPlayer player) => scores.ContainsKey(player);
Esempio n. 48
0
 public Beatdown(IPlayer player, string args = null)
 {
     WeaponType = WeaponType.Hammer;
     SpellType  = SpellType.Passive;
     // Blindside: Successfully interrupt 6s 75% generate 1 energy for the weapon used.
 }
Esempio n. 49
0
 public bool IsBlankMovePosition(IPlayer player)
 {
     return(Labyrinth[player.XPosition, player.YPosition] == -1);
 }
 public IReadOnlyReactiveProperty <int> GetScore(IPlayer player) => scores[player];
Esempio n. 51
0
 public void MessageDoCMD(IPlayer player, string message)
 {
     player.SendChatMessageToNearbyPlayers(message, ChatType.Do);
 }
 public bool TryGetScore(IPlayer player, out IntReactiveProperty score) => scores.TryGetValue(player, out score);
Esempio n. 53
0
 public Katacombs(IPlayer startingPlayer)
 {
     _player = startingPlayer;
 }
 public void Update(IPlayer player)
 {
     this.scoreboard.AddToScoreBoard(player);
     this.ShowScoreboard();
 }
Esempio n. 55
0
        /// <summary>
        /// Decides the nex <see cref="IState"/>
        /// </summary>
        /// <param name="player">Represents the current <see cref="IPlayer"/>.</param>
        /// <param name="preview">Represents the preview <see cref="IState"/></param>
        /// <returns></returns>
        public override IState QuickDecide(IPlayer player, IState preview)
        {
            var match = player.Match;

            if (player.Status.Hasball == false)
            {
                return(OffBallState.Instance);
            }
            else
            {
                if (player.Status.Holdball == false)
                {
                    return(ChaceState.Instance);
                }

                if (player.Status.NeedRedecide == false)
                {
                    return(ActionState.Instance);
                }

                #region 处理传球来源
                int          round       = player.Match.Status.Round;
                var          subState    = player.Status.SubState;
                EnumSubState subStateVal = subState.GetSubState(round);
                if (subStateVal == EnumSubState.LongPassAccepting ||
                    subStateVal == EnumSubState.ShortPassAccepting)
                {
                    var passFrom = player.Status.PassStatus.PassFrom;
                    if (null == passFrom)
                    {
                        subState.SetSubState(EnumSubState.None, round);
                    }
                    else
                    {
                        if (subStateVal == EnumSubState.LongPassAccepting)
                        {
                            passFrom.Status.SetDoneState(AI.States.Pass.LongPassState.Instance, SkillEngine.Extern.Enum.EnumDoneStateFlag.Succ);
                            subState.SetSubState(EnumSubState.LongPassAccepted, round + 1);
                        }
                        else if (subStateVal == EnumSubState.ShortPassAccepting)
                        {
                            passFrom.Status.SetDoneState(AI.States.Pass.ShortPassState.Instance, SkillEngine.Extern.Enum.EnumDoneStateFlag.Succ);
                            subState.SetSubState(EnumSubState.None, round);
                        }
                    }
                }
                #endregion

                #region 守门员传球
                if (player.Input.AsPosition == Position.Goalkeeper)
                {
                    return(PassState.Instance);
                }
                #endregion

                #region 验证射门
                var shootRegion = (player.Side == Side.Home) ?
                                  player.Match.Pitch.AwayShootRegion :
                                  player.Match.Pitch.HomeShootRegion;

                if (shootRegion.IsCoordinateInRegion(player.Current))
                {
                    if (subStateVal != EnumSubState.HeadBall)
                    {
                        player.AddFinishingBuff(1);
                    }
                    return(ShootState.Instance);
                }


                // while the player is not in the shooting area, can't to shoot
                if (subStateVal == EnumSubState.HeadBall && player.PropCore.CanHeadShoot(player.Manager.Opponent.Side) ||
                    subStateVal != EnumSubState.HeadBall && player.PropCore.CanShoot(player.Manager.Opponent.Side))
                {
                    if (match.RandomPercent() < player.PropCore.ShootChooseRate())
                    {
                        return(ShootState.Instance);
                    }
                }
                #endregion

                if (subStateVal != EnumSubState.HeadBall)
                {
                    #region  底传中
                    if (player.Status.IsForceCross)
                    {
                        if (null != player.DecideCrossTarget())
                        {
                            player.DecideEnd();
                            return(Pass.LongPassState.Instance);
                        }
                    }
                    #endregion

                    #region 单刀球
                    if (Decides.Utility.IfSolo(player))
                    {
                        player.SetTarget(Decides.Utility.GetSoloPosition(player));
                        return(Dribble.DefaultDribbleState.Instance);
                    }
                    #endregion
                }

                #region 验证传球
                //region = (player.Side == Side.Home) ? player.Match.Pitch.AwayForcePassRegion : player.Match.Pitch.HomeForcePassRegion;
                //if (region.IsCoordinateInRegion(player.Current))
                //{
                //    if (RandomHelper.GetPercentage() < 40)
                //    {
                //        return PassState.Instance;
                //    }
                //}
                double rawPassRate = 0;
                if (player.Input.AsPosition == Position.Midfielder || player.Input.AsPosition == Position.Forward)
                {
                    if (player.PropCore[PlayerProperty.Dribble] - player.PropCore[PlayerProperty.Passing] >= 18)
                    {
                        rawPassRate = 30;
                    }
                }
                double passRate    = player.PropCore.PassChooseRate(rawPassRate);
                double dribbleRate = player.PropCore.DribbleChooseRate();
                if (dribbleRate >= 100 && passRate < dribbleRate)
                {
                    passRate = 0;
                }
                else if (dribbleRate < 100 && passRate < 100)
                {
                    passRate = (3 * passRate + 2 * (100 - dribbleRate)) / 5;
                }
                if (passRate >= 100 || passRate > 0 && match.RandomPercent() <= passRate)
                {
                    if (subStateVal == EnumSubState.HeadBall)
                    {
                        if (null != player.DecideShortPassTarget())
                        {
                            return(Pass.ShortPassState.Instance);
                        }
                        return(DribbleState.Instance);
                    }
                    return(PassState.Instance);
                }
                #endregion

                return(DribbleState.Instance);
            }
        }
        //----------------------------------------------------------------------------------------------------------

        #region Game Events

        void IStartGame.OnStartGame(IPlayer starter)
        {
            var nextState = Fsm.GetPlayerController(starter);

            Fsm.Handler.MonoBehaviour.StartCoroutine(NextStateRoutine(nextState));
        }
Esempio n. 57
0
 public override BlockDropItemStack[] GetDropsForHandbook(ItemStack handbookStack, IPlayer forPlayer)
 {
     return(GetHandbookDropsFromBreakDrops(handbookStack, forPlayer));
 }
Esempio n. 58
0
        public (IPlayer scorer, int score) Calculate(IPlayer player)
        {
            var score = handDatabase.SearchHands(player.GetPieceList()).Sum(hand => hand.Score);

            return(player, score);
        }
Esempio n. 59
0
 public override WorldInteraction[] GetPlacedBlockInteractionHelp(IWorldAccessor world, BlockSelection selection, IPlayer forPlayer)
 {
     return(new WorldInteraction[]
     {
         new WorldInteraction()
         {
             ActionLangCode = LastCodePart(1) == "populated" ? "blockhelp-skep-putinbagslot" : "blockhelp-skep-pickup",
             MouseButton = EnumMouseButton.Right
         }
     }.Append(base.GetPlacedBlockInteractionHelp(world, selection, forPlayer)));
 }
Esempio n. 60
0
 public FirstItemCommand(IPlayer Iplayer)
 {
     this.Iplayer = Iplayer;
 }