Пример #1
0
        protected override bool HandleStaticCollision(FieldCell other)
        {
            if (other.IsFlame())
            {
                return(HandleCollision(other.AsFlame()));
            }

            if (other.IsPowerup())
            {
                return(HandleCollision(other.AsPowerup()));
            }

            return(base.HandleStaticCollision(other));
        }
        private void WriteFieldState(NetBuffer buffer, Field field)
        {
            int bitsForPlayerIndex = NetUtility.BitsToHoldUInt((uint)(field.GetPlayers().GetCount() - 1));

            FieldCellSlot[] slots = field.GetCells().slots;
            for (int i = 0; i < slots.Length; ++i)
            {
                FieldCell staticCell = slots[i].staticCell;

                bool shouldWrite = staticCell != null && !staticCell.IsSolid();
                buffer.Write(shouldWrite);

                if (shouldWrite)
                {
                    switch (staticCell.type)
                    {
                    case FieldCellType.Brick:
                    {
                        BrickCell brick = staticCell.AsBrick();
                        buffer.Write(CELL_BRICK, BITS_FOR_STATIC_CELL);
                        break;
                    }

                    case FieldCellType.Powerup:
                    {
                        PowerupCell powerup = staticCell.AsPowerup();
                        buffer.Write(CELL_POWERUP, BITS_FOR_STATIC_CELL);
                        buffer.Write(powerup.powerup, BITS_FOR_POWERUP);
                        break;
                    }

                    case FieldCellType.Flame:
                    {
                        FlameCell flame = staticCell.AsFlame();
                        buffer.Write(CELL_FLAME, BITS_FOR_STATIC_CELL);
                        buffer.Write(flame.player.GetIndex(), bitsForPlayerIndex);
                        break;
                    }
                    }
                }
            }
        }